線型多項分類器

from sklearn.linear_model import LogisticRegression
from sklearn.datasets import load_iris

X, y = load_iris(return_X_y=True)

clf = LogisticRegression(multi_class='multinomial', solver='lbfgs', max_iter=200)
clf.fit(X, y)

print(clf.predict(X[:5]))

$ python3 linear_classifier.py
/home/vagrant/.local/lib/python3.10/site-packages/sklearn/linear_model/_logistic.py:1272: FutureWarning: ‘multi_class’ was deprecated in version 1.5 and will be removed in 1.7. From then on, it will always use ‘multinomial’. Leave it to its default value to avoid this warning.
warnings.warn(
[0 0 0 0 0]