本文整理汇总了Python中sklearn.ensemble.GradientBoostingRegressor.feature_importances方法的典型用法代码示例。如果您正苦于以下问题:Python GradientBoostingRegressor.feature_importances方法的具体用法?Python GradientBoostingRegressor.feature_importances怎么用?Python GradientBoostingRegressor.feature_importances使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sklearn.ensemble.GradientBoostingRegressor
的用法示例。
在下文中一共展示了GradientBoostingRegressor.feature_importances方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_boosting_regressor
# 需要导入模块: from sklearn.ensemble import GradientBoostingRegressor [as 别名]
# 或者: from sklearn.ensemble.GradientBoostingRegressor import feature_importances [as 别名]
def get_boosting_regressor(x, y, verbose=False):
"""Calculate a GradientBoostingRegressor on predictor and target variables
Parameters
----------
x : numpy.array
Predictor variable
y : numpy.array
Target variable
verbose : bool, optional
If True, output status messages
Returns
-------
classifier : sklearn.ensemble.GradientBoostingRegressor
A fitted classifier of the predictor and target variable
"""
if verbose:
sys.stderr.write('Getting boosting regressor\n')
clf = GradientBoostingRegressor(n_estimators=50, subsample=0.6,
max_features=100,
verbose=0, learning_rate=0.1,
random_state=0).fit(x, y)
clf.feature_importances = pd.Series(clf.feature_importances_,
index=x.columns)
if verbose:
sys.stderr.write('Finished boosting regressor\n')
return clf
示例2: get_boosting_regressor
# 需要导入模块: from sklearn.ensemble import GradientBoostingRegressor [as 别名]
# 或者: from sklearn.ensemble.GradientBoostingRegressor import feature_importances [as 别名]
def get_boosting_regressor(x, y, verbose=False):
if verbose:
sys.stderr.write('getting boosting regressor\n')
clf = GradientBoostingRegressor(n_estimators=50, subsample=0.6,
max_features=100,
verbose=0, learning_rate=0.1,
random_state=0).fit(x, y)
clf.feature_importances = pd.Series(clf.feature_importances_,
index=x.columns)
if verbose:
sys.stderr.write('finished boosting regressor\n')
return clf