Skip to content

Commit

Permalink
Merge pull request #371 from BCG-Gamma/dev/2.1rc0
Browse files Browse the repository at this point in the history
BUILD: Release FACET 2.1rc0
  • Loading branch information
j-ittner authored Jul 11, 2023
2 parents bd02c4c + e9efa29 commit c5d7cbf
Show file tree
Hide file tree
Showing 19 changed files with 500 additions and 111 deletions.
29 changes: 28 additions & 1 deletion RELEASE_NOTES.rst
Original file line number Diff line number Diff line change
@@ -1,11 +1,30 @@
Release Notes
\Release Notes
=============

.. |mypy| replace:: :external+mypy:doc:`mypy <index>`
.. |shap| replace:: :external+shap:doc:`shap <index>`
.. |nbsp| unicode:: 0xA0
:trim:

FACET 2.1
---------

FACET 2.1 introduces the :class:`.NativeLearnerInspector` for inspecting native
*scikit-learn* models and pipelines.

We still recommend using :mod:`sklearndf` models and learner pipelines along with FACET's
:class:`.LearnerSelector` for hyperparameter tuning; however the new
:class:`.NativeLearnerInspector` can be useful for inspecting models that have been
trained using *scikit-learn* directly.

2.1.0
~~~~~

- API: new :class:`.NativeLearnerInspector` class for inspecting native *scikit-learn*
regressors, classifiers, and pipelines with a regressor or classifier as the final
estimator


FACET 2.0
---------

Expand All @@ -18,6 +37,14 @@ visualizations.
FACET 2.0 requires :mod:`pytools` |nbsp| 2.0 and :mod:`sklearndf` |nbsp| 2.2, and is now
fully type-checked by |mypy|.

2.0.1
~~~~~

- API: class :class:`.LearnerInspector` now supports inspecting individual regressors
and classifiers; it is no longer necessary to wrap them into a
:class:`.RegressorPipelineDF` or :class:`.ClassifierPipelineDF` instance with empty
preprocessing


2.0.0
~~~~~
Expand Down
32 changes: 28 additions & 4 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,15 @@ stages:
- script: dir $(Build.SourcesDirectory)

- script: |
conda install -y -c anaconda conda-build~=3.21 conda-verify~=3.4 toml~=0.10 flit~=3.6 packaging~=20.9
# install micromamba
curl -Ls https://micro.mamba.pm/api/micromamba/linux-64/latest | tar -xvj bin/micromamba
export MAMBA_ROOT_PREFIX=~/micromamba
eval "$(./bin/micromamba shell hook -s posix)"
# create and activate a build environment, then install the tools we need
micromamba create -n build
micromamba activate build
micromamba install -y -c conda-forge boa~=0.14 toml~=0.10 flit~=3.6 packaging~=20.9
displayName: 'Install conda-build, flit, toml'
condition: eq(variables['BUILD_SYSTEM'], 'conda')
Expand All @@ -261,7 +269,11 @@ stages:
targetType: 'inline'
script: |
set -eux
if [ "$BUILD_SYSTEM" = "conda" ] ; then eval "$(conda shell.bash hook)" ; fi
if [ "$BUILD_SYSTEM" = "conda" ] ; then
export MAMBA_ROOT_PREFIX=~/micromamba
eval "$(./bin/micromamba shell hook -s posix)"
micromamba activate build
fi
export RUN_PACKAGE_VERSION_TEST=$(project_name)
cd $(Build.SourcesDirectory)/$(project_root)
Expand Down Expand Up @@ -330,7 +342,15 @@ stages:
- script: dir $(Build.SourcesDirectory)

- script: |
conda install -y -c anaconda conda-build~=3.21 conda-verify~=3.4 toml~=0.10 flit~=3.6 packaging~=20.9
# install micromamba
curl -Ls https://micro.mamba.pm/api/micromamba/linux-64/latest | tar -xvj bin/micromamba
export MAMBA_ROOT_PREFIX=~/micromamba
eval "$(./bin/micromamba shell hook -s posix)"
# create and activate a build environment, then install the tools we need
micromamba create -n build
micromamba activate build
micromamba install -y -c conda-forge boa~=0.14 toml~=0.10 flit~=3.6 packaging~=20.9
displayName: 'Install conda-build, flit, toml'
condition: eq(variables['BUILD_SYSTEM'], 'conda')
Expand All @@ -348,7 +368,11 @@ stages:
targetType: 'inline'
script: |
set -eux
if [ "$BUILD_SYSTEM" = "conda" ] ; then eval "$(conda shell.bash hook)" ; fi
if [ "$BUILD_SYSTEM" = "conda" ] ; then
export MAMBA_ROOT_PREFIX=~/micromamba
eval "$(./bin/micromamba shell hook -s posix)"
micromamba activate build
fi
export RUN_PACKAGE_VERSION_TEST=$(project_name)
cd $(Build.SourcesDirectory)/$(project_root)
Expand Down
2 changes: 2 additions & 0 deletions condabuild/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ test:
# additional requirements of shap
- ipython {{ environ.get('FACET_V_IPYTHON', '[False]') }}
- numba {{ environ.get('FACET_V_NUMBA', '[False]') }}
# additional requirements for testing
- zipp {{ environ.get('FACET_V_ZIPP', '[False]') }}
commands:
- conda list
- python -c 'import facet;
Expand Down
26 changes: 8 additions & 18 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,25 @@ channels:
- bcg_gamma
dependencies:
# run
- boruta_py ~= 0.3
- gamma-pytools ~= 2.1
- joblib ~= 1.2
- lightgbm ~= 3.3
- matplotlib ~= 3.7
- numpy ~= 1.23
- numpy ~= 1.24
- pandas ~= 2.0
- python ~= 3.9
- scikit-learn ~= 1.2.0
- scipy ~= 1.10
- shap ~= 0.41
- sklearndf ~= 2.2
- typing_extensions ~= 4.3
# build/test
- conda-build ~= 3.23.3
- conda-verify ~= 3.1.1
- docutils ~= 0.17.1
- flit ~= 3.8.0
- jinja2 ~= 2.11.3
- markupsafe ~= 2.0.1 # markupsafe 2.1 breaks support for jinja2
- m2r ~= 0.3.1
- pluggy ~= 0.13.1
- pre-commit ~= 2.21.0
- pytest ~= 7.2.1
- pytest-cov ~= 2.12.1
- pyyaml ~= 5.4.1
- toml ~= 0.10.2
- tox ~= 3.27.1
- yaml ~= 0.2.5
# additional packages for notebooks etc.
- pip ~= 23.0
- pip:
- arfs ~= 1.1
# test
- pytest ~= 7.2.1
- pytest-cov ~= 2.12.1
# sphinx
- nbsphinx ~= 0.8.9
- sphinx ~= 4.5.0
Expand Down
13 changes: 8 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ requires = [
"pandas >=1.0",
"scipy ~=1.2",
"shap >=0.39",
"scikit-learn ~=1.0",
"sklearndf ~=2.2",
"typing_extensions ~=4.0",
]
Expand Down Expand Up @@ -85,14 +86,16 @@ typing_extensions = "~=4.0.0"
# additional minimum requirements of sklearndf
boruta = "~=0.3.0"
lightgbm = "~=3.0.0"
scikit-learn = "~=0.24.2"
xgboost = "~=1.5"
scikit-learn = "~=1.0.2"
xgboost = "~=1.5.0"
# additional minimum requirements of gamma-pytools
joblib = "~=0.14.1"
typing_inspect = "~=0.4.0"
# additional minimum requirements of shap
ipython = "==7.0"
numba = "~=0.55" # required to support numpy 1.21
numba = "~=0.55.2" # required to support numpy 1.21
# additional requirements for testing
zipp = "<3.16" # required to support python 3.7

[build.matrix.max]
# direct requirements of gamma-facet
Expand All @@ -109,14 +112,14 @@ typing_extensions = "~=4.3"
# additional maximum requirements of sklearndf
boruta = "~=0.3"
lightgbm = "~=3.3"
scikit-learn = "~=1.1"
scikit-learn = "~=1.2"
xgboost = "~=1.5"
# additional maximum requirements of gamma-pytools
joblib = "~=1.1"
typing_inspect = "~=0.7"
# additional maximum requirements of shap
ipython = ">=7"
numba = ">=0.55.2" # required to support numpy 1.22
numba = "~=0.56"

[tool.black]
# quiet = "True"
Expand Down
2 changes: 1 addition & 1 deletion src/facet/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"""


__version__ = "2.0.0"
__version__ = "2.1rc0"

__logo__ = (
r"""
Expand Down
1 change: 1 addition & 0 deletions src/facet/explanation/_explanation.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,7 @@ def to_expression(self) -> Expression:
# Exact explainer factory
#


# noinspection PyPep8Naming
class _ExactExplainer(
shap.explainers.Exact, # type: ignore
Expand Down
12 changes: 6 additions & 6 deletions src/facet/explanation/base/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import numpy as np
import pandas as pd
from packaging.version import Version
from shap import Explainer, Explanation

from pytools.api import AllTracker
Expand All @@ -26,14 +27,13 @@
# shap relies on the np.bool, np.int, and np.float types, which were deprecated in
# numpy 1.20 and removed in numpy 1.24.
#
# We check if the types are defined and, if not, define them as an alias
# for the corresponding type with a trailing underscore.
# We define these types as an alias for the corresponding type with a trailing
# underscore.


for __attr in ("bool", "int", "float"):
if not hasattr(np, __attr):
if Version(np.__version__) >= Version("1.20"):
for __attr in ("bool", "int", "float"):
setattr(np, __attr, getattr(np, f"{__attr}_"))
del __attr
del __attr


#
Expand Down
Loading

0 comments on commit c5d7cbf

Please sign in to comment.