Skip to content

Commit 1b3c2cd

Browse files
committed
fix weird shape issue in logistic regression
1 parent e7a32c3 commit 1b3c2cd

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

mglearn/tools.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ def visualize_coefficients(coefficients, feature_names, n_top_features=25):
2323
positive) and smallest (most negative) n_top_features coefficients,
2424
for a total of 2 * n_top_features coefficients.
2525
"""
26-
if coefficients.ndim > 1 and coefficients.shape[1] > 1:
26+
coefficients = coefficients.squeeze()
27+
if coefficients.ndim > 1:
2728
# this is not a row or column vector
2829
raise ValueError("coeffients must be 1d array or column vector, got"
2930
" shape {}".format(coefficients.shape))
30-
coefficients = coefficients.ravel()
3131

3232
if len(coefficients) != len(feature_names):
3333
raise ValueError("Number of coefficients {} doesn't match number of"

0 commit comments

Comments
 (0)