如何使用列名称来插补多个类别变量

时间:2019-03-07 21:52:03

标签: python scikit-learn

>
  

IndexError Traceback(最近一次通话最近)    在()
  2 imputer = Imputer(missing_values ='NaN',strategy ='most_frequent',axis = 0)
  3#X贴花la methode fit sur
  ----> 4次=   imputer.fit(X [[''GarageCond','GarageType',   'GarageFinish','GarageQual','BsmtExposure','BsmtFinType2','BsmtCond','BsmtQual','BsmtFinType1','MasVnrType','MasVnrArea','Electrical']])   5 6#变形金刚不等和有价值的人X索引错误:仅   整数,分片(X = train.iloc[:, :-1].values y = train.iloc[:, -1].values from sklearn.preprocessing import Imputer imputer = Imputer(missing_values = 'NaN', strategy = 'most_frequent', axis = 0) # Appliquer la methode fit sur X imputer = imputer.fit(X[['GarageCond', 'GarageType', 'GarageFinish','GarageQual','BsmtExposure','BsmtFinType2','BsmtCond','BsmtQual','BsmtFinType1','MasVnrType','MasVnrArea','Electrical']]) # Tranformer imputer et affecter la valeur a X X[['GarageCond', 'GarageType', 'GarageFinish','GarageQual','BsmtExposure','BsmtFinType2','BsmtCond','BsmtQual','BsmtFinType1','MasVnrType','MasVnrArea','Electrical']] = imputer.transform(X[:, ['GarageCond', 'GarageType', 'GarageFinish','GarageQual','BsmtExposure','BsmtFinType2','BsmtCond','BsmtQual','BsmtFinType1','MasVnrType','MasVnrArea','Electrical']]) ),省略号(:),numpy.newaxis(...)和   整数或布尔数组是有效索引`**

如何通过列名称而不是索引号来估算多个分类数据。

0 个答案:

没有答案