8000 DOC add minimal example to ensemble.isolationforest class (#15205) · amueller/scikit-learn@b47a18c · GitHub
[go: up one dir, main page]

Skip to content

Commit b47a18c

Browse files
SimonCWqinhanmin2014
authored andcommitted
DOC add minimal example to ensemble.isolationforest class (scikit-learn#15205)
1 parent a53956e commit b47a18c

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

sklearn/ensemble/_iforest.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,14 @@ class IsolationForest(OutlierMixin, BaseBagging):
143143
is defined in such a way we obtain the expected number of outliers
144144
(samples with decision function < 0) in training.
145145
146+
Examples
147+
--------
148+
>>> from sklearn.ensemble import IsolationForest
149+
>>> X = [[-1.1], [0.3], [0.5], [100]]
150+
>>> clf = IsolationForest(random_state=0).fit(X)
151+
>>> clf.predict([[0.1], [0], [90]])
152+
array([ 1, 1, -1])
153+
146154
Notes
147155
-----
148156
The implementation is based on an ensemble of ExtraTreeRegressor. The

0 commit comments

Comments
 (0)
0