Machine learning sklearn:';布尔';对象没有属性';任何';

Machine learning sklearn:';布尔';对象没有属性';任何';,machine-learning,scikit-learn,random-forest,sklearn-pandas,gridsearchcv,Machine Learning,Scikit Learn,Random Forest,Sklearn Pandas,Gridsearchcv,我正在构建一个管道,然后使用GridSearchCV确定最佳参数。但是,当我使用管道对象时,我不断得到错误:“bool”对象没有属性“any” 下面是我的代码片段。此外,GridSearchCV只能用于查找最佳参数,然后我必须创建一个具有最佳参数的新模型,并使用该模型进行预测,或者是否有更好的方法解决此问题 column_trans = make_column_transformer((OneHotEncoder(handle_unknown='ignore'),['violation_stre

我正在构建一个管道,然后使用GridSearchCV确定最佳参数。但是,当我使用管道对象时,我不断得到错误:“bool”对象没有属性“any” 下面是我的代码片段。此外,GridSearchCV只能用于查找最佳参数,然后我必须创建一个具有最佳参数的新模型,并使用该模型进行预测,或者是否有更好的方法解决此问题

column_trans = make_column_transformer((OneHotEncoder(handle_unknown='ignore'),['violation_street_name','zip_code', 'violation_code','disposition']),
                                       remainder= 'passthrough')
column_trans.fit_transform(X)

# ------------------------------ Finding the best classifier ---------------------------------

rf = RandomForestClassifier()
params = {'randomforestclassifier__n_estimators':[10,20,50,100], 'randomforestclassifier__max_depth':[3, 5, 7, 10]}


pipeline = make_pipeline(column_trans, rf)
grid = GridSearchCV(pipeline, param_grid= params, cv=5)

cm = cross_val_score(pipe, X, y, cv=3, scoring='accuracy', n_jobs=-1)
print(cm)

grid.fit(X,y)
print(grid.best_params_)

# ---------------------------- end of finding the best classifier ------------------------------------

# -------------------------- define new pipeline with best params ------------------------------------
rfbest = RandomForestClassifier(max_depth=3, n_estimators=10)
pipelinebest = make_pipeline(column_trans, rfbest)

bfit = pipelinebest.fit(X,y)
print(bfit)
y_proba_lr = bfit.predict(X_test)
y_proba_list = list(zip(X_test['ticket_id'][0:20], y_proba_lr[0:20,1]))
print(y_proba_list)