赞
踩
参考:https://machinelearningmastery.com/feature-selection-for-regression-data/
利用pandas对Excel.CSV提取出数据,然后用numpy把它变成矩阵x和y。
import pandas as pd import numpy as np tab = pd.read_csv('D:/DICOM/train1.csv') x_Weeks = tab['Weeks'] x_Weeks = np.array(x_Weeks) x_Percent = tab['Percent'] x_Percent = np.array(x_Percent) x_Age = tab['Age'] x_Age = np.array(x_Age) x_Sex = tab['Sex'] x_Sex = np.array(x_Sex) x_SmokingStatus = tab['SmokingStatus'] x_SmokingStatus = np.array(x_SmokingStatus) y = tab['FVC'] y = np.array(y) #变成列向量 x_Weeks = x_Weeks[:, np.newaxis] x_Percent = x_Percent[:, np.newaxis] x_Age = x_Age[:, np.newaxis] x_Sex = x_Sex[:, np.newaxis] x_SmokingStatus = x_SmokingStatus[:, np.newaxis] y = y[:,np.newaxis] #多个向量组合 X = np.concatenate((x_Weeks,x_Percent,x_Age,x_Sex,x_SmokingStatus),axis=1)
得到X和Y。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。