数据读取
下载csv文件后使用excel进行转存,然后用pandas读取,再把读取后转为numpy,numpy的tensor里。-1代表数组的最大维度,将原始数据集的标签和特征集分开,便于下一步的处理
import pandas as pd import numpy as np def open_File(): file=pd.read_excel(r"E:\NLPTrain\classfiy.xlsx",header=1,engine='openpyxl') # 矩阵转置后转为numpy数组 nplist = file.T.to_numpy() # 除去最后一行的所有数据 lable = nplist[0:-1].T # 取出最后一行,在numpy数组中-1代表数组的最大维度 context = nplist[-1] return lable, context if __name__ == '__main__': lable,contextlib=open_File()
标签:__,NLP,读取,lable,nplist,学习,数组,numpy,日记 From: https://www.cnblogs.com/studyConfig/p/16723303.html