2
2
3
3
|
4
4
5
- Facet is an open source library for human-explainable AI. It combines sophisticated
6
- model inspection and model-based simulation to enable better explanations of your
7
- supervised machine learning models. Facet is composed of the following key components:
8
-
9
- +-------------------+---------------------------------------------------------------------------+
10
- | |pipe | | **Enhanced Machine Learning Workflow ** |
11
- | | |
12
- | | Facet delivers a robust and fail-safe pipelining workflow which allows you|
13
- | | to easily impute and select your features as well as ranking a grid of |
14
- | | different models "competing" against each other. Facet introduces |
15
- | | `sklearndf <https://github.com/BCG-Gamma/sklearndf >`_, an augmented |
16
- | | version of `scikit-learn <https://scikit-learn.org/stable/index.html >`_ |
17
- | | with enhanced support for `pandas <https://pandas.pydata.org/ >`_ |
18
- | | dataframes and pipelining. |
19
- | | |
20
- +-------------------+---------------------------------------------------------------------------+
21
- | |inspect | | **Model Inspection ** |
22
- | | |
23
- | | Local explanations of features and their interactions make up a key |
24
- | | component of understanding feature importance as well as feature |
25
- | | interactions. This is based on a novel method which decomposes |
26
- | | `SHAP values <https://shap.readthedocs.io/en/latest/ >`_ into |
27
- | | two vectors representing **synergy ** and **redundancy **. |
28
- | | |
29
- +-------------------+---------------------------------------------------------------------------+
30
- | |sim | | **Model Simulation ** |
31
- | | |
32
- | | Use your trained model and the insights from the model inspection to |
33
- | | conduct a historical univariate simulation of any feature on your target |
34
- | | in order to identify local optima. |
35
- +-------------------+---------------------------------------------------------------------------+
36
-
5
+ *facet * is an open source library for human-explainable AI.
6
+ It combines sophisticated model inspection and model-based simulation to enable better
7
+ explanations of your supervised machine learning models.
8
+
9
+ *facet * is composed of the following key components:
10
+
11
+ +----------------+---------------------------------------------------------------------+
12
+ | |inspect | | **Model Inspection ** |
13
+ | | |
14
+ | | *facet * introduces a new algorithm to quantify dependencies and |
15
+ | | interactions between features in ML models. |
16
+ | | This new tool for human-explainable AI adds a new, global |
17
+ | | perspective to the observation-level explanations provided by the |
18
+ | | popular `SHAP <https://shap.readthedocs.io/en/latest/ >`_ approach. |
19
+ | | To learn more about *facet*’s model inspection capabilities, see the|
20
+ | | getting started example below. |
21
+ +----------------+---------------------------------------------------------------------+
22
+ | |sim | | **Model Simulation ** |
23
+ | | |
24
+ | | *facet *’s model simulation algorithms use ML models for |
25
+ | | *virtual experiments * to help identify scenarios that optimise |
26
+ | | predicted outcomes. |
27
+ | | To quantify the uncertainty in simulations, *facet* utilises a range|
28
+ | | of bootstrapping algorithms including stationary and stratified |
29
+ | | bootstraps. |
30
+ | | For an example of *facet *’s bootstrap simulations, see the getting |
31
+ | | started example below. |
32
+ +----------------+---------------------------------------------------------------------+
33
+ | |pipe | | **Enhanced Machine Learning Workflow ** |
34
+ | |spacer | | |
35
+ | | *facet * offers an efficient and transparent machine learning |
36
+ | | workflow, enhancing |
37
+ | | `scikit-learn <https://scikit-learn.org/stable/index.html >`_'s |
38
+ | | tried and tested pipelining paradigm with new capabilities for model|
39
+ | | selection, inspection, and simulation. |
40
+ | | *facet * also introduces |
41
+ | | `sklearndf <https://github.com/BCG-Gamma/sklearndf >`_, an augmented |
42
+ | | version of *scikit-learn * with enhanced support for *pandas * data |
43
+ | | frames that ensures end-to-end traceability of features. |
44
+ +----------------+---------------------------------------------------------------------+
37
45
38
46
|azure_pypi | |azure_conda | |azure_devops_master_ci | |code_cov |
39
47
|python_versions | |code_style | |made_with_sphinx_doc | |License_badge |
40
48
41
49
Installation
42
50
---------------------
43
51
44
- Facet supports both PyPI and Anaconda.
52
+ * facet * supports both PyPI and Anaconda.
45
53
46
54
Anaconda
47
55
~~~~~~~~~~~~~~~~~~~~~
@@ -61,9 +69,9 @@ Quickstart
61
69
----------------------
62
70
63
71
The following quickstart guide provides a minimal example workflow to get up and running
64
- with Facet .
72
+ with * facet * .
65
73
66
- Enhanced machine learning workflow
74
+ Enhanced Machine Learning Workflow
67
75
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
68
76
69
77
.. code-block :: Python
@@ -83,45 +91,52 @@ Enhanced machine learning workflow
83
91
84
92
# load Boston housing dataset
85
93
boston = load_boston()
86
- df = pd.DataFrame(data = boston.data, columns = boston.feature_names).assign(
94
+ boston_df = pd.DataFrame(data = boston.data, columns = boston.feature_names).assign(
87
95
MEDIAN_HOUSE_PRICE = boston.target
88
96
)
89
97
90
98
# create FACET sample object
91
- boston_obs = Sample(observations = df , target_name = " MEDIAN_HOUSE_PRICE" )
99
+ boston_sample = Sample(observations = boston_df , target_name = " MEDIAN_HOUSE_PRICE" )
92
100
93
- # create pipeline for random forest regressor
94
- rforest_reg = RegressorPipelineDF(regressor = RandomForestRegressorDF(random_state = 42 ))
101
+ # create a (trivial) pipeline for a random forest regressor
102
+ rnd_forest_reg = RegressorPipelineDF(
103
+ regressor = RandomForestRegressorDF(random_state = 42 )
104
+ )
95
105
96
106
# define grid of models which are "competing" against each other
97
- rforest_grid = [
107
+ rnd_forest_grid = [
98
108
LearnerGrid(
99
- pipeline = rforest_reg, learner_parameters = {" min_samples_leaf" : [8 , 11 , 15 ]}
100
- )
109
+ pipeline = rnd_forest_reg,
110
+ learner_parameters = {
111
+ " min_samples_leaf" : [8 , 11 , 15 ]
112
+ }
113
+ ),
101
114
]
102
115
103
116
# create repeated k-fold CV iterator
104
117
rkf_cv = RepeatedKFold(n_splits = 5 , n_repeats = 10 , random_state = 42 )
105
118
106
119
# rank your models by performance (default is variance explained)
107
- ranker = LearnerRanker(grids = rforest_grid, cv = rkf_cv, n_jobs = - 3 ).fit(sample = boston_obs)
120
+ ranker = LearnerRanker(
121
+ grids = rnd_forest_grid, cv = rkf_cv, n_jobs = - 3
122
+ ).fit(sample = boston_sample)
108
123
109
124
# get summary report
110
125
ranker.summary_report()
111
126
112
127
.. image :: _static/ranker_summary.png
113
- :width: 600
128
+ :width: 600
114
129
115
130
Model Inspection
116
131
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
117
132
118
- Facet implements several model inspection methods for
133
+ * facet * implements several model inspection methods for
119
134
`scikit-learn <https://scikit-learn.org/stable/index.html >`_ estimators.
120
135
Fundamentally, facet enables post-hoc model inspection by breaking down the interaction
121
136
effects of the features used for model training:
122
137
123
138
- **Redundancy **
124
- represents how much information is shared between two features contributions to
139
+ represents how much information is shared between two features' contributions to
125
140
the model predictions. For example, temperature and pressure in a pressure cooker are
126
141
redundant features for predicting cooking time since pressure will rise relative to
127
142
the temperature, and vice versa. Therefore, knowing just one of either temperature or
@@ -214,46 +229,47 @@ Model Simulation
214
229
215
230
.. image :: _static/simulation_output.png
216
231
217
- Download the getting started tutorial and explore Facet for yourself here: |binder |
232
+ Download the getting started tutorial and explore * facet * for yourself here: |binder |
218
233
219
234
Contributing
220
235
---------------------------
221
236
222
- Facet is stable and is being supported long-term.
237
+ * facet * is stable and is being supported long-term.
223
238
224
- Contributions to Facet are welcome and appreciated.
239
+ Contributions to * facet * are welcome and appreciated.
225
240
For any bug reports or feature requests/enhancements please use the appropriate
226
241
`GitHub form <https://github.com/BCG-Gamma/facet/issues >`_, and if you wish to do so,
227
242
please open a PR addressing the issue.
228
243
229
244
We do ask that for any major changes please discuss these with us first via an issue or
230
- at our team email: FacetTeam <at> bcg <dot> com.
245
+ using our team email: FacetTeam <at> bcg <dot> com.
231
246
232
247
For further information on contributing please see our :ref: `contribution-guide `.
233
248
234
249
License
235
250
---------------------------
236
251
237
- Facet is licensed under Apache 2.0 as described in the
252
+ * facet * is licensed under Apache 2.0 as described in the
238
253
`LICENSE <https://github.com/BCG-Gamma/facet/LICENSE >`_ file.
239
254
240
255
Acknowledgements
241
256
---------------------------
242
257
243
- Facet is built on top of two popular packages for Machine Learning:
258
+ * facet * is built on top of two popular packages for Machine Learning:
244
259
245
260
The `scikit-learn <https://github.com/scikit-learn/scikit-learn >`_ learners and
246
261
pipelining make up implementation of the underlying algorithms. Moreover, we tried
247
262
to design the facet API to align with the scikit-learn API.
248
263
249
264
The `shap <https://github.com/slundberg/shap >`_ implementation is used to estimate the
250
- shapley vectors which are being decomposed into the synergy, redundancy, and
251
- independence vectors.
265
+ shapley vectors which * facet * then decomposes into synergy, redundancy, and independence
266
+ vectors.
252
267
253
268
BCG GAMMA
254
269
---------------------------
255
270
256
- If you would like to know more about the team behind Facet please see our :ref: `about_us ` page.
271
+ If you would like to know more about the team behind *facet * please see our
272
+ :ref: `about_us ` page.
257
273
258
274
We are always on the lookout for passionate and talented data scientists to join the
259
275
BCG GAMMA team. If you would like to know more you can find out about BCG GAMMA
@@ -262,27 +278,42 @@ or have a look at
262
278
`career opportunities <https://www.bcg.com/en-gb/beyond-consulting/bcg-gamma/careers >`_.
263
279
264
280
.. |pipe | image :: _static/icons/pipe_icon.png
265
- :class: facet_icon
281
+ :width: 64px
282
+ :class: facet_icon
283
+
266
284
.. |inspect | image :: _static/icons/inspect_icon.png
267
- :class: facet_icon
285
+ :width: 64px
286
+ :class: facet_icon
287
+
268
288
.. |sim | image :: _static/icons/sim_icon.png
289
+ :width: 64px
269
290
:class: facet_icon
270
291
292
+ .. |spacer | unicode :: 0x2028 0x2003 0x2003 0x2003 0x2003 0x2003 0x2003
293
+
271
294
.. |azure_conda | image :: https://
272
- :target: https://
295
+ :target: https://
296
+
273
297
.. |azure_pypi | image :: https://
274
- :target: https://
298
+ :target: https://
299
+
275
300
.. |azure_devops_master_ci | image :: https://
276
- :target: https://
301
+ :target: https://
302
+
277
303
.. |code_cov | image :: https://
278
- :target: https://
304
+ :target: https://
305
+
279
306
.. |python_versions | image :: https://img.shields.io/badge/python-3.7|3.8-blue.svg
280
- :target: https://www.python.org/downloads/release/python-380/
307
+ :target: https://www.python.org/downloads/release/python-380/
308
+
281
309
.. |code_style | image :: https://img.shields.io/badge/code%20style-black-000000.svg
282
- :target: https://github.com/psf/black
310
+ :target: https://github.com/psf/black
311
+
283
312
.. |made_with_sphinx_doc | image :: https://img.shields.io/badge/Made%20with-Sphinx-1f425f.svg
284
- :target: https://www.sphinx-doc.org/
313
+ :target: https://www.sphinx-doc.org/
314
+
285
315
.. |license_badge | image :: https://img.shields.io/badge/License-Apache%202.0-olivegreen.svg
286
- :target: https://opensource.org/licenses/Apache-2.0
316
+ :target: https://opensource.org/licenses/Apache-2.0
317
+
287
318
.. |binder | image :: https://mybinder.org/badge_logo.svg
288
- :target: https://mybinder.org/
319
+ :target: https://mybinder.org/
0 commit comments