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

fix _preprocess_data to align with sklearn refactor #638

Merged
merged 5 commits into from
Jun 22, 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
5 changes: 3 additions & 2 deletions econml/sklearn_extensions/linear_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from econml.utilities import ndim, shape, reshape, _safe_norm_ppf, check_input_arrays
from sklearn import clone
from sklearn.linear_model import LinearRegression, LassoCV, MultiTaskLassoCV, Lasso, MultiTaskLasso
from sklearn.linear_model._base import _preprocess_data
from sklearn.metrics import r2_score
from sklearn.model_selection import KFold, StratifiedKFold
# TODO: consider working around relying on sklearn implementation details
Expand Down Expand Up @@ -102,7 +103,7 @@ def _fit_weighted_linear_model(self, X, y, sample_weight, check_input=None):
)

# Normalize inputs
X, y, X_offset, y_offset, X_scale = self._preprocess_data(
X, y, X_offset, y_offset, X_scale = _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)
Expand Down Expand Up @@ -731,7 +732,7 @@ def fit(self, X, y, sample_weight=None, check_input=True):
# Fit weighted lasso with user input
super().fit(X, y, sample_weight, check_input)
# Center X, y
X, y, X_offset, y_offset, X_scale = self._preprocess_data(
X, y, X_offset, y_offset, X_scale = _preprocess_data(
X, y, fit_intercept=self.fit_intercept, normalize=False,
copy=self.copy_X, check_input=check_input, sample_weight=sample_weight)

Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ packages = find_namespace:
install_requires =
numpy
scipy > 1.4.0
scikit-learn > 0.22.0, < 1.1
scikit-learn > 0.22.0, < 1.2
sparse
joblib >= 0.13.0
statsmodels >= 0.10
Expand Down