【发布时间】:2021-02-21 14:58:08
【问题描述】:
我有一个问题,我试图将转换应用于我的分类特征“国家”和我的其余数字列。我该怎么做,因为我在下面尝试:
preprocess = make_column_transformer(
(numeric_cols, make_pipeline(MinMaxScaler())),
(categorical_cols, OneHotEncoder()))
model = make_pipeline(preprocess,XGBClassifier())
model.fit(X_train, y_train)
注意 numeric_cols 作为列表传递,categorical_cols 也是如此。
但是i get this error: TypeError: All estimators should implement fit and transform, or can be 'drop' or 'passthrough' specifiers. 以及我所有数字列的列表(type <class 'list'>) doesn't.
我做错了什么,我该如何处理列国家/地区中看不见的类别?
【问题讨论】:
标签: python pandas scikit-learn pipeline one-hot-encoding