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 double fit crash in preprocessing models #4040

Merged
merged 1 commit into from
Jul 11, 2021
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
26 changes: 13 additions & 13 deletions python/cuml/_thirdparty/sklearn/preprocessing/_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,12 +303,12 @@ def _reset(self):
# Checking one attribute is enough, becase they are all set together
# in partial_fit
if hasattr(self, 'scale_'):
self.scale_ = None
self.min_ = None
self.n_samples_seen_ = None
self.data_min_ = None
self.data_max_ = None
self.data_range_ = None
del self.scale_
del self.min_
del self.n_samples_seen_
del self.data_min_
del self.data_max_
del self.data_range_

def get_param_names(self):
return super().get_param_names() + [
Expand Down Expand Up @@ -628,10 +628,10 @@ def _reset(self):
# Checking one attribute is enough, becase they are all set together
# in partial_fit
if hasattr(self, 'scale_'):
self.scale_ = None
self.n_samples_seen_ = None
self.mean_ = None
self.var_ = None
del self.scale_
del self.n_samples_seen_
del self.mean_
del self.var_

def get_param_names(self):
return super().get_param_names() + [
Expand Down Expand Up @@ -931,9 +931,9 @@ def _reset(self):
# Checking one attribute is enough, becase they are all set together
# in partial_fit
if hasattr(self, 'scale_'):
self.scale_ = None
self.n_samples_seen_ = None
self.max_abs_ = None
del self.scale_
del self.n_samples_seen_
del self.max_abs_

def get_param_names(self):
return super().get_param_names() + [
Expand Down
5 changes: 5 additions & 0 deletions python/cuml/test/test_preprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ def test_minmax_scaler(failure_logger, clf_dataset, # noqa: F811

scaler = cuMinMaxScaler(feature_range=feature_range, copy=True)
t_X = scaler.fit_transform(X)
scaler.fit_transform(X)
r_X = scaler.inverse_transform(t_X)
assert type(t_X) == type(X)
assert type(r_X) == type(t_X)
Expand Down Expand Up @@ -111,6 +112,7 @@ def test_standard_scaler(failure_logger, clf_dataset, # noqa: F811
with_std=with_std,
copy=True)
t_X = scaler.fit_transform(X)
scaler.fit_transform(X)
r_X = scaler.inverse_transform(t_X)
assert type(t_X) == type(X)
assert type(r_X) == type(t_X)
Expand All @@ -133,6 +135,7 @@ def test_standard_scaler_sparse(failure_logger,

scaler = cuStandardScaler(with_mean=False, with_std=with_std, copy=True)
t_X = scaler.fit_transform(X)
scaler.fit_transform(X)
r_X = scaler.inverse_transform(t_X)
# assert type(t_X) == type(X)
# assert type(r_X) == type(t_X)
Expand Down Expand Up @@ -204,6 +207,7 @@ def test_maxabs_scaler(failure_logger, clf_dataset): # noqa: F811

scaler = cuMaxAbsScaler(copy=True)
t_X = scaler.fit_transform(X)
scaler.fit_transform(X)
r_X = scaler.inverse_transform(t_X)
assert type(t_X) == type(X)
assert type(r_X) == type(t_X)
Expand All @@ -222,6 +226,7 @@ def test_maxabs_scaler_sparse(failure_logger,

scaler = cuMaxAbsScaler(copy=True)
t_X = scaler.fit_transform(X)
scaler.fit_transform(X)
r_X = scaler.inverse_transform(t_X)
# assert type(t_X) == type(X)
# assert type(r_X) == type(t_X)
Expand Down