Skip to content Skip to sidebar Skip to footer

How To Get Coefficients Of Multinomial Logistic Regression?

I need to calculate coefficients of a multiple logistic regression using sklearn: X = x1 x2 x3 x4 x5 x6 0.300000 0.100000 0.0 0.0000 0.5

Solution 1:

Check the online documentation:

coef_ : array, shape (1, n_features) or (n_classes, n_features)

Coefficient of the features in the decision function.

coef_ is of shape (1, n_features) when the given problem is binary.

As @Xochipilli has already mentioned in comments you are going to have (n_classes, n_features) or in your case (4,6) coefficients and 4 intercepts (one for each class)

Probably I am doing something wrong, because y_pred = logreg.predict(X) gives me the value of 1 for all rows.

yes, you shouldn't try to use data that you've used for training your model for prediction. Split your data into training and test data sets, train your model using train data set and check it's accuracy using test data set.


Post a Comment for "How To Get Coefficients Of Multinomial Logistic Regression?"