Skip to content

Commit

Permalink
Update regression function following the recent changes
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexeyPechnikov committed Jan 29, 2024
1 parent 3baadaa commit 6535203
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions pygmtsar/pygmtsar/Stack_detrend.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,10 +211,11 @@ def regression_block(data, weight, *args, **kwargs):
return np.nan * np.zeros(data.shape)

# build prediction model with or without plane removal (fit_intercept)
if 'algorithm' in kwargs and kwargs['algorithm'] == 'sgd':
algorithm = kwargs.pop('algorithm', 'linear')
if algorithm == 'sgd':
regr = make_pipeline(StandardScaler(), SGDRegressor(**kwargs))
fit_params = {'sgdregressor__sample_weight': weight_values[~nanmask]} if weight.size > 1 else {}
elif 'algorithm' not in kwargs or kwargs['algorithm'] == 'linear':
elif algorithm == 'linear':
regr = make_pipeline(StandardScaler(), LinearRegression(**kwargs, copy_X=False, n_jobs=1))
fit_params = {'linearregression__sample_weight': weight_values[~nanmask]} if weight.size > 1 else {}
else:
Expand Down Expand Up @@ -265,7 +266,7 @@ def regression_linear(self, data, variables, weight=None, valid_pixels_threshold
yy**2, xx**2, yy*xx,
yy**3, xx**3, yy**2*xx, xx**2*yy], corr_sbas)
"""
return self.regression(data, variables, weight, valid_pixels_threshold, 'linear',
return self.regression(data, variables, weight, valid_pixels_threshold, algorithm='linear',
fit_intercept=fit_intercept)

def regression_sgd(self, data, variables, weight=None, valid_pixels_threshold=1000,
Expand Down Expand Up @@ -306,7 +307,7 @@ def regression_sgd(self, data, variables, weight=None, valid_pixels_threshold=10
yy**2, xx**2, yy*xx,
yy**3, xx**3, yy**2*xx, xx**2*yy], corr_sbas)
"""
return self.regression(data, variables, weight, valid_pixels_threshold, 'sgd',
return self.regression(data, variables, weight, valid_pixels_threshold, algorithm='sgd',
max_iter=max_iter, tol=tol, alpha=alpha, l1_ratio=l1_ratio)

def polyfit(self, data, weight=None, degree=0, count=None):
Expand Down

0 comments on commit 6535203

Please sign in to comment.