Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8eaf698

Browse files
committed
FIX: lars_path -- assure that at least some features get added if necessary
Otherwise can run into situation when max_features == n_active, so add_features becomes == 0, thus no actual resize happens, and then next assignment to coefs fails.
1 parent 67ff4ef commit 8eaf698

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

scikits/learn/linear_model/least_angle.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ def lars_path(X, y, Xy=None, Gram=None, max_features=None,
222222

223223
if n_iter >= coefs.shape[0]:
224224
# resize the coefs and alphas array
225-
add_features = 2 * (max_features - n_active)
225+
add_features = 2 * max(1, (max_features - n_active))
226226
coefs.resize((n_iter + add_features, n_features))
227227
alphas.resize(n_iter + add_features)
228228

0 commit comments

Comments
 (0)