Softmax Regression

In [1]:
import numpy as np
from sklearn import datasets
iris = datasets.load_iris()
In [5]:
X = iris["data"][:, (2, 3)]
Y = iris["target"]
In [6]:
from sklearn.linear_model import LogisticRegression
softmax_reg = LogisticRegression(penalty = "l2", multi_class = "multinomial", solver="lbfgs", C=10)
softmax_reg.fit(X, Y)
Out[6]:
LogisticRegression(C=10, class_weight=None, dual=False, fit_intercept=True,
                   intercept_scaling=1, l1_ratio=None, max_iter=100,
                   multi_class='multinomial', n_jobs=None, penalty='l2',
                   random_state=None, solver='lbfgs', tol=0.0001, verbose=0,
                   warm_start=False)
In [11]:
print(softmax_reg.predict([[5, 2]]))
print(softmax_reg.predict_proba([[5, 2]]))
[2]
[[6.38014896e-07 5.74929995e-02 9.42506362e-01]]