From fb652a735a2ba009db14b3987ec99000c5fba52f Mon Sep 17 00:00:00 2001 From: Oege Dijk Date: Tue, 12 Jan 2021 13:47:04 +0100 Subject: [PATCH] fixed ordered_cats tests --- RELEASE_NOTES.md | 16 ++++++++++------ tests/test_cats_only.py | 8 ++++---- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 824e7f6..eeb9b15 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -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 - @@ -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) diff --git a/tests/test_cats_only.py b/tests/test_cats_only.py index 23e2adc..2747e26 100644 --- a/tests/test_cats_only.py +++ b/tests/test_cats_only.py @@ -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) @@ -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)