本文整理汇总了Python中sklearn.ensemble.IsolationForest.set_params方法的典型用法代码示例。如果您正苦于以下问题:Python IsolationForest.set_params方法的具体用法?Python IsolationForest.set_params怎么用?Python IsolationForest.set_params使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sklearn.ensemble.IsolationForest
的用法示例。
在下文中一共展示了IsolationForest.set_params方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_iforest_warm_start
# 需要导入模块: from sklearn.ensemble import IsolationForest [as 别名]
# 或者: from sklearn.ensemble.IsolationForest import set_params [as 别名]
def test_iforest_warm_start():
"""Test iterative addition of iTrees to an iForest """
rng = check_random_state(0)
X = rng.randn(20, 2)
# fit first 10 trees
clf = IsolationForest(n_estimators=10, max_samples=20,
random_state=rng, warm_start=True)
clf.fit(X)
# remember the 1st tree
tree_1 = clf.estimators_[0]
# fit another 10 trees
clf.set_params(n_estimators=20)
clf.fit(X)
# expecting 20 fitted trees and no overwritten trees
assert len(clf.estimators_) == 20
assert clf.estimators_[0] is tree_1
示例2: test_iforest_parallel_regression
# 需要导入模块: from sklearn.ensemble import IsolationForest [as 别名]
# 或者: from sklearn.ensemble.IsolationForest import set_params [as 别名]
def test_iforest_parallel_regression():
"""Check parallel regression."""
rng = check_random_state(0)
X_train, X_test, y_train, y_test = train_test_split(boston.data, boston.target, random_state=rng)
ensemble = IsolationForest(n_jobs=3, random_state=0).fit(X_train)
ensemble.set_params(n_jobs=1)
y1 = ensemble.predict(X_test)
ensemble.set_params(n_jobs=2)
y2 = ensemble.predict(X_test)
assert_array_almost_equal(y1, y2)
ensemble = IsolationForest(n_jobs=1, random_state=0).fit(X_train)
y3 = ensemble.predict(X_test)
assert_array_almost_equal(y1, y3)