No code appears or error: ValueError: max_features must be in (0, n_features]. I have already tried the Stack solutions and I did not get a solution. Could anyone help?
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)
I have had the same problem using max_features as float. I suggest max_features list should contain only integers. For instance: max_features = [2, 5, 7, 10]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.