首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ValueError: max_features必须在(0,n_features)中

ValueError: max_features必须在(0,n_features)中
EN

Stack Overflow用户
提问于 2020-07-05 19:21:25
回答 1查看 1.3K关注 0票数 0

没有出现任何代码或错误: ValueError: max_features必须在(0,n_features]中。我已经尝试了Stack解决方案,但没有得到解决方案。有人能帮忙吗?

代码语言:javascript
复制
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)
EN

回答 1

Stack Overflow用户

发布于 2022-05-01 13:44:48

我在使用max_features时遇到了与浮点数相同的问题。我建议max_features列表应该只包含整数。例如: max_features = 2、5、7、10

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/62745359

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档