File tree 1 file changed +5
-1
lines changed
1 file changed +5
-1
lines changed Original file line number Diff line number Diff line change @@ -546,8 +546,10 @@ def rmatvec(b):
546
546
elif (X .shape [1 ] <= 2
547
547
and np .all (np .linalg .eigvals (np .dot (X , np .transpose (X ))) > 0 )):
548
548
n_samples , n_features = X .shape
549
+ ravel = False
549
550
if y .ndim == 1 :
550
551
y = y .reshape (- 1 , 1 )
552
+ ravel = True
551
553
n_samples_ , n_targets = y .shape
552
554
alpha = np .asarray (0 , dtype = X .dtype ).ravel ()
553
555
if alpha .size not in [1 , n_targets ]:
@@ -574,7 +576,9 @@ def rmatvec(b):
574
576
except linalg .LinAlgError :
575
577
# use SVD solver if matrix is singular
576
578
self .coef_ = _solve_svd (X , y , alpha )
577
- self .coef_ = self .coef_ .reshape ((self .coef_ .shape [1 ],))
579
+ if ravel :
<
5B5C
tr class="diff-line-row">
580
+ # When y was passed as a 1d-array, we flatten the coefficients.
581
+ self .coef_ = self .coef_ .ravel ()
578
582
else :
579
583
self .coef_ , self ._residues , self .rank_ , self .singular_ = \
580
584
linalg .lstsq (X , y , check_finite = False )
You can’t perform that action at this time.
0 commit comments