Python 从fit_transform检索要素名称?

Python 从fit_transform检索要素名称?,python,scikit-learn,transform,pipeline,Python,Scikit Learn,Transform,Pipeline,我正在使用以下工具: preprocess = make_column_transformer( (MinMaxScaler(),numeric_cols), (OneHotEncoder(handle_unknown='ignore'),['country']) ) pipeline = make_pipeline(preprocess,XGBClassifier()) param_grid = { 'xgbclassifie

我正在使用以下工具:

preprocess = make_column_transformer(
    (MinMaxScaler(),numeric_cols),
    (OneHotEncoder(handle_unknown='ignore'),['country'])
    )
pipeline = make_pipeline(preprocess,XGBClassifier())
param_grid =    { 
                  'xgbclassifier__learning_rate': [0.01,0.005,0.001],
                 
                  }


clf = GridSearchCV(pipeline,param_grid = param_grid,scoring = 'roc_auc',
                                 verbose= 1,iid= True,
                                     refit = True,cv  = 3)
clf.fit(X_train,y_train)


model_best =clf.best_estimator_
当我这样做时:

model_best.fit_transform(X_test)
我得到一个错误:

ValueError: y should be a 1d array, got an array of shape () instead.
当我执行以下操作时

pd.DataFrame(pipeline[0].fit_transform(X_test)) 

我确实得到了一个数据帧,但我如何修复功能名称??由于它包含ohe变量,我不确定如何做,我不能只做x_train.columns.tolist()

我认为您需要尝试以下方法:否则可能更容易使用pd.get_假人首先转换数据帧