Multi-Class Logistic Regression in SciKit Learn
<p>I am having trouble with the proper call of Scikit's Logistic Regression for the multi-class case. I am using the lbgfs solver, and I do have the multi_class parameter set to multinomial. </p>

<p>It is unclear to me how to pass the true class labels in fitting the model. I had assumed that it was similar/same as for the random forest classifier multi-class, where you pass [n_samples, m_classes] dataframe. However, in doing this, I get an error that the data is of a bad shape. ValueError: bad input shape (20, 5)  -- in this tiny example, there were 5 classes, 20 samples. </p>

<p>On inspection, the documentation for the fit method says that the truth values are passed as [n_samples, ] -- which matches the error i'm getting -- however, I have no idea then how to train the model with multiple classes. So, this is my question: how do i pass the full set of class labels to the fit function?</p>

<p>i've been unable to find sample code on the Internet to model, nor this question on StackOverflow.. but i feel certain someone must know how to do it! </p>

<p>in the code below, train_features = [n_samples, nn_features], truth_train = [n_samples, m_classes]</p>

<pre><code>clf = LogisticRegressionCV(class_weight='balanced', multi_class='multinomial', solver='lbfgs')
clf.fit(train_features, truth_train)
pred = clf.predict(test_features)
</code></pre>