Skip to content

Commit fab18a1

Browse files
committed
Add sklearn estimators feature_importances_ attribute
TODO: - check whether feature_evaluated_importances_ and feature_used_importances_ should be kept or not - if not, then rename n_features_used_ to n_features_ and feature_used_names_ to feature_names_. - accordingly, update tests and sklearn samples to reflect these changes.
1 parent babb123 commit fab18a1

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

khiops/sklearn/estimators.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1817,8 +1817,13 @@ class KhiopsClassifier(ClassifierMixin, KhiopsPredictor):
18171817
to all features selected by the classifier. It ranges between 0 (little
18181818
contribution to the model) and 1 (large contribution to the model).
18191819
1820-
- Importance: The geometric mean between the Level and the Weight.
1820+
- Importance: Average of the exact Shapley values of each used feature
1821+
across the training data.
18211822
1823+
feature_importances_ : `ndarray <numpy.ndarray>` of shape (n_features_used\_, )
1824+
Importances of the features used by the classifier. The importance of each
1825+
feature is calculated as the average of its exact Shapley values across
1826+
the training data.
18221827
is_multitable_model_ : bool
18231828
``True`` if the model was fitted on a multi-table dataset.
18241829
model_ : `.DictionaryDomain`
@@ -2037,6 +2042,7 @@ def _fit_training_post_process(self, ds):
20372042
)
20382043
self.feature_used_names_ = feature_used_names_
20392044
self.feature_used_importances_ = feature_used_importances_
2045+
self.feature_importances_ = self.feature_used_importances_[:, 2]
20402046
self.n_features_used_ = len(self.feature_used_names_)
20412047

20422048
def predict(self, X):

0 commit comments

Comments
 (0)