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

Commit ce60edf

Browse files
TarenGormanOhjeah
authored andcommitted
bugfix and STRidge test (#14)
1 parent 9767910 commit ce60edf

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

sparsereg/model/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ def fit(self, x_, y, sample_weight=None):
148148
if self.threshold > 0:
149149
self._reduce(x, y)
150150
else:
151-
self.coef_ = self._regress(x[:, ind], y, self.alpha)
151+
self.coef_ = self._regress(x[:, self.ind_], y, self.alpha)
152152

153153
if self.unbias and self.alpha >= 0:
154154
self._unbias(x, y)

test/model/test_stridge.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,9 @@ def test_all_zero(data):
3636
s = STRidge(threshold=10000).fit(x, y)
3737
assert not any(s.coef_)
3838
assert len(s.history_) == 1 # initial guess wipes everything
39+
40+
def test_all_nonzero(data):
41+
x, y = data
42+
s = STRidge(threshold=0).fit(x, y)
43+
assert s.complexity == 3
44+
assert len(s.history_) == 1 # initial guess is final guess

0 commit comments

Comments
 (0)