Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Several small fixes #629

Merged
merged 7 commits into from
Jun 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions azure-pipelines-steps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
parameters:
package: '-e .'
images: ['ubuntu-18.04', 'macOS-10.15', 'windows-2019']
versions: ['3.6', '3.7', '3.8', '3.9']
versions: ['3.7', '3.8', '3.9']
job:
job: Job

Expand Down Expand Up @@ -59,7 +59,7 @@ jobs:
condition: and(succeeded(), eq(variables['Agent.OS'], 'Darwin'))

# Install the package
- script: 'python -m pip install --upgrade pip && pip install --upgrade setuptools wheel Cython && pip install ${{ parameters.package }}'
- script: 'python -m pip install --upgrade pip && pip install --upgrade setuptools wheel Cython && pip install ${{ parameters.package }} && pip freeze --exclude-editable'
displayName: 'Install dependencies'

- ${{ parameters.job.steps }}
2 changes: 1 addition & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:

- template: azure-pipelines-steps.yml
parameters:
versions: ['3.6']
versions: ['3.8']
images: ['ubuntu-18.04']
package: '-e .[all]'
job:
Expand Down
4 changes: 2 additions & 2 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = None
language = "en"

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
Expand Down Expand Up @@ -219,7 +219,7 @@
'sklearn': ('https://scikit-learn.org/stable/', None),
'matplotlib': ('https://matplotlib.org/', None),
'shap': ('https://shap.readthedocs.io/en/stable/', None),
'dowhy': ('https://microsoft.github.io/dowhy/', None)}
'dowhy': ('https://py-why.github.io/dowhy/', None)}


# -- Options for todo extension ----------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions doc/spec/estimation/dml.rst
Original file line number Diff line number Diff line change
Expand Up @@ -553,8 +553,8 @@ Usage FAQs
from econml.dml import DML
from sklearn.linear_model import ElasticNetCV
from sklearn.ensemble import RandomForestRegressor
est = DML(model_y=RandomForestRegressor(oob_score=True),
model_t=RandomForestRegressor(oob_score=True),
est = DML(model_y=RandomForestRegressor(),
model_t=RandomForestRegressor(),
model_final=ElasticNetCV(fit_intercept=False), featurizer=PolynomialFeatures(degree=1))
est.fit(y, T, X=X, W=W)
est.score_
Expand Down
18 changes: 9 additions & 9 deletions econml/sklearn_extensions/linear_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def _fit_weighted_linear_model(self, X, y, sample_weight, check_input=None):
X, y, X_offset, y_offset, X_scale = self._preprocess_data(
X, y, fit_intercept=self.fit_intercept, normalize=False,
copy=self.copy_X, check_input=check_input if check_input is not None else True,
sample_weight=sample_weight, return_mean=True)
sample_weight=sample_weight)
# Weight inputs
normalized_weights = X.shape[0] * sample_weight / np.sum(sample_weight)
sqrt_weights = np.sqrt(normalized_weights)
Expand Down Expand Up @@ -207,7 +207,7 @@ def __init__(self, alpha=1.0, fit_intercept=True,
random_state=None, selection='cyclic'):
super().__init__(
alpha=alpha, fit_intercept=fit_intercept,
normalize=False, precompute=precompute, copy_X=copy_X,
precompute=precompute, copy_X=copy_X,
max_iter=max_iter, tol=tol, warm_start=warm_start,
positive=positive, random_state=random_state,
selection=selection)
Expand Down Expand Up @@ -297,11 +297,11 @@ class WeightedMultiTaskLasso(WeightedModelMixin, MultiTaskLasso):

"""

def __init__(self, alpha=1.0, fit_intercept=True, normalize=False,
def __init__(self, alpha=1.0, fit_intercept=True,
copy_X=True, max_iter=1000, tol=1e-4, warm_start=False,
random_state=None, selection='cyclic'):
super().__init__(
alpha=alpha, fit_intercept=fit_intercept, normalize=False,
alpha=alpha, fit_intercept=fit_intercept,
copy_X=copy_X, max_iter=max_iter, tol=tol, warm_start=warm_start,
random_state=random_state, selection=selection)

Expand Down Expand Up @@ -407,13 +407,13 @@ class WeightedLassoCV(WeightedModelMixin, LassoCV):
"""

def __init__(self, eps=1e-3, n_alphas=100, alphas=None, fit_intercept=True,
precompute='auto', max_iter=1000, tol=1e-4, normalize=False,
precompute='auto', max_iter=1000, tol=1e-4,
copy_X=True, cv=None, verbose=False, n_jobs=None,
positive=False, random_state=None, selection='cyclic'):

super().__init__(
eps=eps, n_alphas=n_alphas, alphas=alphas,
fit_intercept=fit_intercept, normalize=False,
fit_intercept=fit_intercept,
precompute=precompute, max_iter=max_iter, tol=tol, copy_X=copy_X,
cv=cv, verbose=verbose, n_jobs=n_jobs, positive=positive,
random_state=random_state, selection=selection)
Expand Down Expand Up @@ -518,13 +518,13 @@ class WeightedMultiTaskLassoCV(WeightedModelMixin, MultiTaskLassoCV):
"""

def __init__(self, eps=1e-3, n_alphas=100, alphas=None, fit_intercept=True,
normalize=False, max_iter=1000, tol=1e-4,
max_iter=1000, tol=1e-4,
copy_X=True, cv=None, verbose=False, n_jobs=None,
random_state=None, selection='cyclic'):

super().__init__(
eps=eps, n_alphas=n_alphas, alphas=alphas,
fit_intercept=fit_intercept, normalize=False,
fit_intercept=fit_intercept,
max_iter=max_iter, tol=tol, copy_X=copy_X,
cv=cv, verbose=verbose, n_jobs=n_jobs,
random_state=random_state, selection=selection)
Expand Down Expand Up @@ -733,7 +733,7 @@ def fit(self, X, y, sample_weight=None, check_input=True):
# Center X, y
X, y, X_offset, y_offset, X_scale = self._preprocess_data(
X, y, fit_intercept=self.fit_intercept, normalize=False,
copy=self.copy_X, check_input=check_input, sample_weight=sample_weight, return_mean=True)
copy=self.copy_X, check_input=check_input, sample_weight=sample_weight)

# Calculate quantities that will be used later on. Account for centered data
y_pred = self.predict(X) - self.intercept_
Expand Down
4 changes: 2 additions & 2 deletions econml/tests/test_dml.py
Original file line number Diff line number Diff line change
Expand Up @@ -1143,13 +1143,13 @@ def test_groups(self):
# test nested grouping
class NestedModel(LassoCV):
def __init__(self, eps=1e-3, n_alphas=100, alphas=None, fit_intercept=True,
precompute='auto', max_iter=1000, tol=1e-4, normalize=False,
precompute='auto', max_iter=1000, tol=1e-4,
copy_X=True, cv=None, verbose=False, n_jobs=None,
positive=False, random_state=None, selection='cyclic'):

super().__init__(
eps=eps, n_alphas=n_alphas, alphas=alphas,
fit_intercept=fit_intercept, normalize=normalize,
fit_intercept=fit_intercept,
precompute=precompute, max_iter=max_iter, tol=tol, copy_X=copy_X,
cv=cv, verbose=verbose, n_jobs=n_jobs, positive=positive,
random_state=random_state, selection=selection)
Expand Down
4 changes: 2 additions & 2 deletions econml/tests/test_drlearner.py
Original file line number Diff line number Diff line change
Expand Up @@ -801,13 +801,13 @@ def test_groups(self):
# test nested grouping
class NestedModel(LassoCV):
def __init__(self, eps=1e-3, n_alphas=100, alphas=None, fit_intercept=True,
precompute='auto', max_iter=1000, tol=1e-4, normalize=False,
precompute='auto', max_iter=1000, tol=1e-4,
copy_X=True, cv=None, verbose=False, n_jobs=None,
positive=False, random_state=None, selection='cyclic'):

super().__init__(
eps=eps, n_alphas=n_alphas, alphas=alphas,
fit_intercept=fit_intercept, normalize=normalize,
fit_intercept=fit_intercept,
precompute=precompute, max_iter=max_iter, tol=tol, copy_X=copy_X,
cv=cv, verbose=verbose, n_jobs=n_jobs, positive=positive,
random_state=random_state, selection=selection)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1066,7 +1066,7 @@
}
],
"source": [
"res_random = est_dw.refute_estimate(method_name=\"random_common_cause\", num_simulations=10)\n",
"res_random = est_dw.refute_estimate(method_name=\"random_common_cause\", num_simulations=5)\n",
"print(res_random)"
]
},
Expand Down
5 changes: 4 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ project_urls =
Source Code=https://github.com/Microsoft/EconML
Documentation=https://econml.azurewebsites.net/
classifiers =
Programming Language :: Python :: 3.6
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Expand Down Expand Up @@ -57,13 +56,17 @@ tf =
; This extra is not currently compatible with python 3.9 or above because of tensorflow breaking changes
keras < 2.4;python_version < '3.9'
tensorflow > 1.10, < 2.3;python_version < '3.9'
; Version capped due to tensorflow incompatibility
protobuf < 4
plt =
graphviz
matplotlib
all =
azure-cli
keras < 2.4
tensorflow > 1.10, < 2.3
; Version capped due to tensorflow incompatibility
protobuf < 4
matplotlib

[options.packages.find]
Expand Down