python - ValueError: max_features must be in (0, n_features] in Random Forest
问题描述
没有代码出现或错误:ValueError: max_features must be in (0, n_features]。我已经尝试过 Stack 解决方案,但没有得到解决方案。有人可以帮忙吗?
def predict_RF(x_test_sel, k_vetor, y_train):
model = RandomForestRegressor()
model.fit(k_vetor, y_train)
y_predict = model.predict(x_test_sel)
kf = KFold(n_splits=3)
n_estimators = [25, 50, 75, 100]
max_features = [0.2, 0,7, 0.5, 1.0]
min_samples_leaf = [1, 2, 5, 10]
hyperF = dict (n_estimators = n_estimators, max_features=max_features, min_samples_leaf = min_samples_leaf)
gridF = GridSearchCV(model, hyperF, cv = kf, verbose = 1, n_jobs = -1)
grid_fit = gridF.fit(k_vetor, y_train) #Fit the gridsearch object with X_train, (k_vetor, y_train) -> dar nome x_train para k_vetor
print(grid_fit.best_params_)
return (y_predict)
解决方案
推荐阅读
- email - 从电子邮件别名发送和接收电子邮件
- python - 如何通过 gRPC 流式传输 CSV 数据?
- node.js - 如何在流流之前放置一个音频缓冲区
- node.js - 我想计算 nodejs mongodb 列中的三个字段,需要按月分组
- javascript - 用反应弹簧侧边栏菜单按钮制作动画而不用它制作动画
- terraform - terraform - 变量的天蓝色 vnet
- reactjs - 如何检测 NextJS 项目中的所有 Typescript 和 ESLint 错误,而不仅仅是打开的文件?
- apache-flink - 区间加入功能
- r - ggplot2:如何按颜色将图例拆分为自定义图例
- python - 熊猫数据框中的年龄计算