本文整理汇总了Python中sklearn.linear_model.RidgeCV.get_params方法的典型用法代码示例。如果您正苦于以下问题:Python RidgeCV.get_params方法的具体用法?Python RidgeCV.get_params怎么用?Python RidgeCV.get_params使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sklearn.linear_model.RidgeCV
的用法示例。
在下文中一共展示了RidgeCV.get_params方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: RandomForestRegressor
# 需要导入模块: from sklearn.linear_model import RidgeCV [as 别名]
# 或者: from sklearn.linear_model.RidgeCV import get_params [as 别名]
'min_samples_split':(2,3,4),
'min_samples_leaf':(1,2,3)}
rfr = RandomForestRegressor(random_state=seed, warm_start=True)
score = make_scorer(mean_squared_error, greater_is_better=False)
grid_obj = GridSearchCV(rfr, param_grid=parameters, scoring=score, verbose=1, n_jobs=4, cv=5)
grid_obj= grid_obj.fit(X_train, y_train)
rfr = grid_obj.best_estimator_
print rfr.get_params(), '\n'
print "Tuned model has a training RMSE score of {:.4f}.".format(predict_labels(rfr, X_train, y_train))
print "Tuned model has a testing RMSE score of {:.4f}.".format(predict_labels(rfr, X_valid, y_valid))
# RidgeCV
ridge = RidgeCV(alphas=(1e-8, 1e-7, 1e-6, 1e-5, 1e-4, 1e-3, 1e-2, 0.1, 1.0, 10.0), cv=5)
ridge = ridge.fit(X_train, y_train)
print ridge.get_params(), '\n'
print "Tuned model has a training RMSE score of {:.4f}.".format(predict_labels(ridge, X_train, y_train))
print "Tuned model has a testing RMSE score of {:.4f}.".format(predict_labels(ridge, X_valid, y_valid))
# Save regressors
pickle_file = 'regressor.pickle'
try:
f = open(pickle_file, 'wb')
save = {
'random_forest_regressor': rfr,
'ridge': ridge,
}
pickle.dump(save, f, pickle.HIGHEST_PROTOCOL)
f.close()
except Exception as e: