Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x 梯度增强分类器_Python 3.x_Gbm - Fatal编程技术网

Python 3.x 梯度增强分类器

Python 3.x 梯度增强分类器,python-3.x,gbm,Python 3.x,Gbm,在使用roc AUC选择一些特征并使用基线删除我不需要的特征后,我尝试在使用梯度增强机器中拟合一个模型。然后我尝试使用GBM安装列车组,但收到错误消息 我实现了GBM # lets drop roc-auc values below 0.54 baseline x_train.drop(labels=removed_roc_values, axis=1, inplace=True) x_test.drop(labels=removed_roc_values, axis=1, inplace=

在使用roc AUC选择一些特征并使用基线删除我不需要的特征后,我尝试在使用梯度增强机器中拟合一个模型。然后我尝试使用GBM安装列车组,但收到错误消息

我实现了GBM

# lets drop roc-auc values below 0.54 baseline

x_train.drop(labels=removed_roc_values, axis=1, inplace=True)

x_test.drop(labels=removed_roc_values, axis=1, inplace=True)


x_train.shape, x_test.shape

The output of shape after dropping baseline features:((4930, 17), (2113, 23))


# using baseline GBM without tunning

from sklearn.ensemble import GradientBoostingClassifier

from sklearn.metrics import classification_report

from sklearn.grid_search import GridSearchCV


baseline = GradientBoostingClassifier(learning_rate=0.1, 

n_estimators=100,max_depth=3, min_samples_split=2, min_samples_leaf=1, 

subsample=1,max_features='sqrt', random_state=10)

baseline.fit(x_train,y_train)

predictors=list(x_train)

feat_imp = pd.Series(baseline.feature_importances_, 

predictors).sort_values(ascending=False)

feat_imp.plot(kind='bar', title='Importance of Features')

plt.ylabel('Feature Importance Score')

print('Accuracy of the GBM on test set: {:.3f}'.format(baseline.score(x_test, 

y_test)))

pred=baseline.predict(x_test)

print(classification_report(y_test, pred))
我希望得到分类报告,但是,我得到了下面的错误

ValueError:模型的特征数必须与输入匹配。 模型

n_特征为17,输入n_特征为23

谢谢