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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With