我想使用 scikit-learn 对我的回归问题应用像递归特征消除这样的包装方法。使用交叉验证的递归特征消除很好地概述了如何自动调整特征数量。
我试过这个:
modelX = LogisticRegression()
rfecv = RFECV(estimator=modelX, step=1, scoring='mean_absolute_error')
rfecv.fit(df_normdf, y_train)
print("Optimal number of features : %d" % rfecv.n_features_)
# Plot number of features VS. cross-validation scores
plt.figure()
plt.xlabel("Number of features selected")
plt.ylabel("Cross validation score (nb of correct classifications)")
plt.plot(range(1, len(rfecv.grid_scores_) + 1), rfecv.grid_scores_)
plt.show()`
但我收到一条错误消息,例如
`The least populated class in y has only 1 members, which is too few.
The minimum number of labels for any class cannot be less than n_folds=3. % (min_labels, self.n_folds)), Warning)
警告听起来像是我有分类问题,但我的任务是回归问题。我该怎么做才能得到结果?出了什么问题?