Skip to content

Commit

Permalink
Create new extras
Browse files Browse the repository at this point in the history
  • Loading branch information
kbattocchi committed Feb 19, 2021
1 parent f3e46f4 commit 9f093c3
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 13 deletions.
4 changes: 3 additions & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ jobs:

- script: 'python setup.py build_sphinx -b doctest'
displayName: 'Run doctests'
package: '-e .[automl]'
package: '-e .[all]'

- job: 'Notebooks'
dependsOn: 'EvalChanges'
Expand Down Expand Up @@ -106,6 +106,7 @@ jobs:
testResultsFiles: '**/test-results.xml'
testRunTitle: 'Notebooks'
condition: succeededOrFailed()
package: '-e .[tf,interpret]'

# - job: 'AutoML'
# dependsOn: 'EvalChanges'
Expand Down Expand Up @@ -216,3 +217,4 @@ jobs:
inputs:
codeCoverageTool: Cobertura
summaryFileLocation: '$(System.DefaultWorkingDirectory)/**/coverage.xml'
package: '-e .[tf,interpret]'
8 changes: 7 additions & 1 deletion econml/cate_interpreter/_interpreters.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,15 @@
from io import StringIO
from sklearn.tree import DecisionTreeRegressor, DecisionTreeClassifier
from sklearn.utils.validation import check_is_fitted
import graphviz
from ._tree_exporter import _CateTreeDOTExporter, _CateTreeMPLExporter, _PolicyTreeDOTExporter, _PolicyTreeMPLExporter

try:
import graphviz
except ImportError as exn:
raise ImportError("matplotlib and graphviz are no longer dependencies of the main econml package;\n"
"install econml[interpret] or econml[all] to require them, or install them separately, "
"to use the tree interpreters") from exn


class _SingleTreeInterpreter(metaclass=abc.ABCMeta):

Expand Down
12 changes: 9 additions & 3 deletions econml/cate_interpreter/_tree_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,15 @@

import numpy as np
import re
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
try:
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
except ImportError as exn:
raise ImportError("matplotlib and graphviz are no longer dependencies of the main econml package;\n"
"install econml[interpret] or econml[all] to require them, or install them separately, "
"to use the tree interpreters") from exn


# HACK: We're relying on some of sklearn's non-public classes which are not completely stable.
# However, the alternative is reimplementing a bunch of intricate stuff by hand
Expand Down
14 changes: 10 additions & 4 deletions econml/iv/nnet/_deepiv.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,19 @@
"""Deep IV estimator and related components."""

import numpy as np
import keras
from ..._cate_estimator import BaseCateEstimator
from ...utilities import deprecated
from keras import backend as K
import keras.layers as L
from keras.models import Model
from econml.utilities import check_input_arrays, _deprecate_positional
try:
import keras
from keras import backend as K
import keras.layers as L
from keras.models import Model
except ImportError as exn:
raise ImportError("keras and tensorflow are no longer dependencies of the main econml package;\n"
"install econml[tf] or econml[all] to require them, or install them separately, "
"to use DeepIv") from exn


# TODO: make sure to use random seeds wherever necessary
# TODO: make sure that the public API consistently uses "T" instead of "P" for the treatment
Expand Down
16 changes: 12 additions & 4 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,10 @@ install_requires =
numpy
scipy > 1.4.0
scikit-learn >= 0.24
keras < 2.4
sparse
tensorflow > 1.10, < 2.3
joblib >= 0.13.0
numba != 0.42.1
statsmodels >= 0.9
graphviz
matplotlib
pandas
shap ~= 0.38.1
dowhy
Expand All @@ -71,6 +67,18 @@ automl =
; Disabled due to incompatibility with scikit-learn
; azureml-sdk[explain,automl] == 1.0.83
azure-cli
tf =
keras < 2.4
tensorflow > 1.10, < 2.3
interpret =
matplotlib
graphviz
all =
azure-cli
keras < 2.4
tensorflow > 1.10, < 2.3
matplotlib
graphviz

; TODO: exclude tests?
[options.packages.find]
Expand Down

0 comments on commit 9f093c3

Please sign in to comment.