Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Logistic Regression Scikit-Learn Getting the coefficients of the classification

I am doing Multiclass Classification and applying Logistic regression on it

When i fitted the data by calling

logistic.fit(InputDATA,OutputDATA)

the estimator "logistic " fits the data.

Now when I call logistic.coef_ it prints a 2D array with 4 rows(I HAD FOUR CLASSES) and n columns(one for each feature)

THIS IS WHAT I SAW ON SCIKIT LEARN SITE:

coef_ : array, shape (n_features, ) or (n_targets, n_features) Estimated coefficients for the linear regression problem. If multiple targets are passed during the fit (y 2D), this is a 2D array of shape (n_targets, n_features), while if only one target is passed, this is a 1D array of length n_features.

Now my query is : Why different coefficients are there for different classes as i need only one hypothesis which would predict the output.

like image 437
Shivam Duggal Avatar asked Jul 22 '15 12:07

Shivam Duggal


1 Answers

As you have a multiclass case (>2 cases) an one-vs-rest strategy is applied. sklearn creates 4 classiefiers, not only 1. Hence you have 4 hypothesis and 4*coefficents.

Note: I have no clue about the logistic regression classifier, but that is how the sklearn SVM work.

like image 146
fgoettel Avatar answered Nov 07 '22 05:11

fgoettel