Python sklearn.tree 模块,ExtraTreeRegressor() 实例源码
我们从Python开源项目中,提取了以下2个代码示例,用于说明如何使用sklearn.tree.ExtraTreeRegressor()。
def ext(X,y):
X_train,X_validation,y_train,y_validation = train_test_split(X,y,random_state=0)
ext = ExtraTreeRegressor(random_state=1)
ext.fit(X_train,y_train.ravel())
print 'training error:',1.0 - ext.score(X_train,y_train)
print 'validation error:',1.0 - ext.score(X_validation,y_validation)
time_fit(ext,X_train,y_train.ravel())
def __init__(self, base_estimator=None, n_estimators=50, max_features=1.0,
max_depth=6, learning_rate=1.0, loss='linear', random_state=None):
if base_estimator and base_estimator == 'etr':
base_estimator = ExtraTreeRegressor(max_depth=max_depth,
max_features=max_features)
else:
base_estimator = DecisionTreeRegressor(max_depth=max_depth,
max_features=max_features)
self.model = sklearn.ensemble.AdaBoostRegressor(
base_estimator=base_estimator,
n_estimators=n_estimators,
learning_rate=learning_rate,
random_state=random_state,
loss=loss)
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。