算法优化

问题描述 投票:0回答:0

我有一个像这样但更大的数据框。

            JAN                 Feb            
            PRICE AMOUNT NAME   PRICE AMOUNT NAME
 2011-03-31     2      7    3       6      0    5
 2011-04-01     6      2    5       0      4    2
 2011-04-04     9      0    7       2      7    9
 2011-04-05     5      3    5       7      9    9

我正在尝试应用随机森林模型,为了找到最佳参数,我应用了我在这个链接上找到的代码:https://medium.com/@maryamuzakariya/project-predict-stock-prices-在 python-fbe4edf01664 中使用随机森林回归模型

model = RandomForestRegressor() 
grid_rf = {
    'n_estimators': [500],  
    'max_depth': [5,10,15,20,25,30],  
    'min_samples_split': [2,5,10,15,20,25,30], 
    'min_samples_leaf': [1,5,10,15,20,25,30]
}
rscv = RandomizedSearchCV(estimator=model, param_distributions=grid_rf, cv=3, n_jobs=-1, verbose=2, n_iter=200)
rscv_fit = rscv.fit(x_train, y_train)
best_parameters = rscv_fit.best_params_
print(best_parameters)

grid_rf 和 recv 中的所有输入都被选中并且必须保持不变。 当我运行它时,我收到很多警告说:

FutureWarning: Feature names only support names that are all strings. Got feature names with dtypes: ['tuple']. An error will be raised in 1.2. warnings.warn(

警告不是问题,因为,最终,它起作用了。 我的问题是它很慢。有什么办法让它更快吗?

谢谢你的建议

python optimization parameters random-forest
© www.soinside.com 2019 - 2024. All rights reserved.