[PYTHON] What is Multinomial Logistic Regression Analysis?

Multinomial logistic regression

-** Logistic regression that enables multi-class classification **

--A model that attempts to transform the linear predictor so that the range is [0,1] and the sum is 1.

--Largely divided into ** "nominal logistic regression" ** and ** "order logistic regression" **

(1) Name logistic: Multi-class classification when there is no special order between classes ** ex) Men = 0, Women = 1 **

(2) Order logistic: Multi-class classification when there is a special order between classes. ** ex) Like = 0, I don't like it so much = 1, I hate = 2 **

For multi-class classification

データデータ

What if p1 = 〇?

データ

What is the optimization method?

データデータ

Experiment

** This time I would like to analyze using the dataset of the sklearn library. ** **

import numpy as np
import matplotlib.pyplot as plt
from sklearn.datasets import load_digits

digits = load_digits()
X=digits.data
y=digits.target

images_with_labels = list(zip(digits.images,digits.target))

plt.figure(figsize=(15,6))

for idx,(image,label) in enumerate(images_with_labels[:10]):
    plt.subplot(2,5,idx+1)
    plt.imshow(image,cmap=plt.cm.gray_r,interpolation="nearest")
    plt.title("{}".format(label),fontsize=25)
plt.show()
データ
from sklearn.metrics import confusion_matrix
from sklearn.linear_model import LogisticRegression
from sklearn.preprocessing import StandardScaler
from sklearn.model_selection import train_test_split

scaler=StandardScaler()
X_scaled=scaler.fit_transform(X)

X_train,X_test,y_train,y_test=train_test_split(X_scaled,y,random_state=0)

print(log_reg.score(X_train,y_train))
print(log_reg.score(X_test,y_test))

prediction=log_reg.predict(X_test)
confusion = confusion_matrix(prediction,y_test) #Mixed matrix generation
print(confusinon)
データ データ

Recommended Posts

What is Multinomial Logistic Regression Analysis?
What is Logistic Regression Analysis?
What is Reduced Rank Ridge Regression?
Logistic regression
Logistic regression
Logistic regression analysis Self-made with python
What is copy.copy ()
What is Django? .. ..
What is dotenv?
What is POSIX?
What is Linux
What is klass?
What is SALOME?
What is Linux?
What is python
What is hyperopt?
Regression analysis method
What is pyvenv
What is __call__
What is Linux
What is Python
What is a distribution?
What is Piotroski's F-Score?
What is Raspberry Pi?
[Python] What is Pipeline ...
Machine learning logistic regression
What is Calmar Ratio?
What is a terminal?
[PyTorch Tutorial ①] What is PyTorch?
What is hyperparameter tuning?
What is a hacker?
What is JSON? .. [Note]
What is Linux for?
What is a pointer?
What is ensemble learning?
What is TCP / IP?
Basics of regression analysis
What is Python's __init__.py?
Regression analysis with NumPy
What is an iterator?
What is UNIT-V Linux?
[Python] What is virtualenv
Regression analysis in Python
What is machine learning?
2. Multivariate analysis spelled out in Python 5-3. Logistic regression analysis (stats models)
Challenges for future sales forecasts: (1) What is time series analysis?
What is Minisum or Minimax?
What is Linux? [Command list]
What is the activation function?
Multiple regression analysis with Keras
What is the Linux kernel?
What is an instance variable?
What is a decision tree?
Time-series analysis Implementation is stuck-Notes-
What is a Context Switch?
What is Google Cloud Dataflow?
[DL] What is weight decay?
[Python] Python and security-① What is Python?
What is a super user?
Competitive programming is what (bonus)
[Python] * args ** What is kwrgs?