# 把train_data 中的Class 转变为数值类型
Class = train_data['Class'].unique()
Class
np.argwhere(Class=='SEKER')[0][0]
def conver(x):
return np.argwhere(Class==x)[0,0]
train_data['Class'] = train_data['Class'].map(conver)
train_data.columns
clos = ['Class']
for clo in clos:
u = train_data[clo].unique()
def conver(x):
return np.argwhere(u==x)[0,0]
train_data[clo] = train_data[clo].map(conver)
train_data.tail()
网页上学到的
原来的Dataframe
from sklearn.neighbors import KNeighborsClassifier
from sklearn.model_selection import StratifiedKFold,KFold
Class = train_data['Class'].unique()
Class
np.argwhere(Class=='SEKER')[0][0]
def conver(x):
return np.argwhere(Class==x)[0,0]
train_data['Class'] = train_data['Class'].map(conver)
train_data.columns
clos = ['Class']
for clo in clos:
u = train_data[clo].unique()
def conver(x):
return np.argwhere(u==x)[0,0]
train_data[clo] = train_data[clo].map(conver)
train_data.tail()