本文整理汇总了Python中sklearn.ensemble.ExtraTreesRegressor.set_params方法的典型用法代码示例。如果您正苦于以下问题:Python ExtraTreesRegressor.set_params方法的具体用法?Python ExtraTreesRegressor.set_params怎么用?Python ExtraTreesRegressor.set_params使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sklearn.ensemble.ExtraTreesRegressor
的用法示例。
在下文中一共展示了ExtraTreesRegressor.set_params方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: GridSearchCV
# 需要导入模块: from sklearn.ensemble import ExtraTreesRegressor [as 别名]
# 或者: from sklearn.ensemble.ExtraTreesRegressor import set_params [as 别名]
from sklearn.grid_search import GridSearchCV
from sklearn.ensemble import ExtraTreesRegressor
import ch9util
from tempfile import mkdtemp
import os
import joblib
X_train, X_test, y_train, y_test = ch9util.temp_split()
params = {'min_samples_split': [1, 3],
'bootstrap': [True, False],
'min_samples_leaf': [3, 4]}
gscv = GridSearchCV(ExtraTreesRegressor(random_state=41),
param_grid=params, cv=5)
gscv.fit(X_train, y_train)
preds = gscv.predict(X_test)
ch9util.npy_save('etr.npy', preds)
dir = mkdtemp()
pkl = os.path.join(dir, 'params.pkl')
joblib.dump(gscv.best_params_, pkl)
params = joblib.load(pkl)
print('Best params', gscv.best_params_)
print('From pkl', params)
est = ExtraTreesRegressor(random_state=41)
est.set_params(**params)
est.fit(X_train, y_train)
preds2 = est.predict(X_test)
print('Max diff', (preds - preds2).max())