Skip to content
This repository has been archived by the owner on Jul 19, 2022. It is now read-only.

Commit

Permalink
rcond
Browse files Browse the repository at this point in the history
  • Loading branch information
Ohjeah committed Feb 15, 2018
1 parent fe2001c commit 1f6483d
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions sparsereg/model/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,15 @@ def print_model(self, input_features=None):


class STRidge(LinearModel, RegressorMixin):
def __init__(self, threshold=0.01, alpha=0.1, max_iter=100, normalize=True, fit_intercept=True, copy_x=True, unbias=True):
def __init__(self, threshold=0.01, alpha=0.1, max_iter=100, normalize=True, fit_intercept=True, copy_x=True, unbias=True, _cond=-1):
self.threshold = threshold
self.max_iter = max_iter
self.fit_intercept = fit_intercept
self.normalize = normalize
self.copy_X = copy_x
self.alpha = alpha
self.unbias = unbias
self._rcond=_rcond

self.history_ = []

Expand All @@ -84,11 +85,11 @@ def _sparse_coefficients(self, dim, ind, coef):
self.history_.append(c)
return c, big_ind

def _regress(self, x, y, alpha, rcond=None):
def _regress(self, x, y, alpha):
if alpha != 0:
coef = np.linalg.lstsq(x.T @ x + alpha * np.eye(x.shape[1]), x.T @ y, rcond=rcond)[0]
coef = np.linalg.lstsq(x.T @ x + alpha * np.eye(x.shape[1]), x.T @ y, rcond=self._rcond)[0]
else:
coef = np.linalg.lstsq(x, y, rcond=rcond)[0]
coef = np.linalg.lstsq(x, y, rcond=self._rcond)[0]
self.iters += 1
return coef

Expand Down

0 comments on commit 1f6483d

Please sign in to comment.