Skip to content

Commit

Permalink
fixed ordered_cats tests
Browse files Browse the repository at this point in the history
  • Loading branch information
oegedijk committed Jan 12, 2021
1 parent 6106425 commit fb652a7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
16 changes: 10 additions & 6 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
### Breaking Changes
- `WhatIfComponent` deprecated. Use `WhatIfComposite` or connect components
yourself to a `FeatureInputComponent`
-
- renaming properties:
`explainer.cats` -> `explainer.onehot_cols`
`explainer.cats_dict` -> `explainer.onehot_dict`

### New Features
- Adds support for model with categorical features that were not onehot encoded
(e.g. CatBoost)
- Adds filter on number of categories to display in violin plots, and how to sort
the categories (alphabetical, by frequency or by mean abs shap)
- Adds filter on number of categories to display in violin plots and pdp plot,
and how to sort the categories (alphabetical, by frequency or by mean abs shap)

### Bug Fixes
-
Expand All @@ -20,12 +22,14 @@
### Improvements
- No longer dependening on PDPbox dependency: built own partial dependence
functions with categorical feature support
- autodetect xgboost.cor.Booster or lightgbm.Booster and give ValueError to
- autodetect xgboost.core.Booster or lightgbm.Booster and give ValueError to
use the sklearn compatible wrappers instead.

### Other Changes
-
-
- Introduces list of categorical columns: `explainer.categorical_cols`
- Introduces dictionary with categorical columns categories: `explainer.categorical_dict`
- Introduces list of all categorical features: `explainer.cat_cols`

## 0.2.19
### Breaking Changes
- ExplainerHub: parameter `user_json` is now called `users_file` (and default to a `users.yaml` file)
Expand Down
8 changes: 4 additions & 4 deletions tests/test_cats_only.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ def test_equivalent_col(self):
self.assertIsNone(self.explainer.equivalent_col("random"))

def test_ordered_cats(self):
self.assertEqual(self.explainer.ordered_cats("Sex"), ['female', 'male'])
self.assertEqual(self.explainer.ordered_cats("Deck", topx=2), ['A', 'B'])
self.assertEqual(self.explainer.ordered_cats("Sex"), ['Sex_female', 'Sex_male'])
self.assertEqual(self.explainer.ordered_cats("Deck", topx=2, sort='alphabet'), ['Deck_A', 'Deck_B'])

self.assertIsInstance(self.explainer.ordered_cats("Deck", sort='freq'), list)
self.assertIsInstance(self.explainer.ordered_cats("Deck", topx=3, sort='freq'), list)
Expand Down Expand Up @@ -381,8 +381,8 @@ def test_random_index(self):
self.assertIsInstance(self.explainer.random_index(return_str=True), str)

def test_ordered_cats(self):
self.assertEqual(self.explainer.ordered_cats("Sex"), ['female', 'male'])
self.assertEqual(self.explainer.ordered_cats("Deck", topx=2), ['A', 'B'])
self.assertEqual(self.explainer.ordered_cats("Sex"), ['Sex_female', 'Sex_male'])
self.assertEqual(self.explainer.ordered_cats("Deck", topx=2, sort='alphabet'), ['Deck_A', 'Deck_B'])

self.assertIsInstance(self.explainer.ordered_cats("Deck", sort='freq'), list)
self.assertIsInstance(self.explainer.ordered_cats("Deck", topx=3, sort='freq'), list)
Expand Down

0 comments on commit fb652a7

Please sign in to comment.