Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update IForest model #533

Merged
merged 2 commits into from
Nov 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions pyod/models/iforest.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,27 @@ def max_samples_(self):
Decorator for scikit-learn Isolation Forest attributes.
"""
return self.detector_.max_samples_

@property
def estimators_features_(self):
"""The indeces of the subset of features used to train the estimators.
Decorator for scikit-learn Isolation Forest attributes.
"""
return self.detector_.estimators_features_

@property
def n_features_in_(self):
"""The number of features seen during the fit.
Decorator for scikit-learn Isolation Forest attributes.
"""
return self.detector_.n_features_in_

@property
def offset_(self):
"""Offset used to define the decision function from the raw scores.
Decorator for scikit-learn Isolation Forest attributes.
"""
return self.detector_.offset_

@property
def feature_importances_(self):
Expand Down
7 changes: 7 additions & 0 deletions pyod/test/test_iforest.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@ def test_parameters(self):
self.clf.estimators_samples_ is not None)
assert (hasattr(self.clf, 'max_samples_') and
self.clf.max_samples_ is not None)
assert (hasattr(self.clf, 'estimators_features_') and
self.clf.estimators_features_ is not None)
assert (hasattr(self.clf, 'n_features_in_') and
self.clf.n_features_in_ is not None)
assert (hasattr(self.clf, 'offset_') and
self.clf.offset_ is not None)


def test_train_scores(self):
assert_equal(len(self.clf.decision_scores_), self.X_train.shape[0])
Expand Down
Loading