Skip to content

Commit

Permalink
Define _estimator_has()
Browse files Browse the repository at this point in the history
  • Loading branch information
GegznaV committed Aug 13, 2023
1 parent 1a0ff42 commit 66f8f9b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions eli5/lime/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
from eli5.utils import vstack
from eli5.sklearn.utils import sklearn_version

def _estimator_has(attr):
def check(self):
return hasattr(self.estimator, attr)

return check

def fit_proba(clf, X, y_proba, expand_factor=10, sample_weight=None,
shuffle=True, random_state=None,
Expand Down
6 changes: 6 additions & 0 deletions eli5/sklearn/permutation_importance.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@
from eli5.permutation_importance import get_score_importances
from eli5.sklearn.utils import pandas_available

def _estimator_has(attr):
def check(self):
return hasattr(self.estimator, attr)

return check

if pandas_available:
import pandas as pd

Expand Down

0 comments on commit 66f8f9b

Please sign in to comment.