Это мой код:
import numpy as np
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
import os
from sklearn import preprocessing
df_train = pd.read_csv('Iris_train.csv')
df_test = pd.read_csv('Iris_test.csv')
X_train = df_train.drop(['TYPE'],axis=1).values
y_train = df_train_fixed[['TYPE']].values
X_test = df_test.values
from sklearn import preprocessing
std_scaler = preprocessing.StandardScaler()
std_scaler.fit(X_train)
X_train_std_sk = std_scaler.transform(X_train)
X_test_std_sk = std_scaler.transform(X_test)
from sklearn.linear_model import LogisticRegression
logreg = LogisticRegression(penalty='l2',
solver='saga',
multi_class='ovr')
logreg.fit(X_train_std_sk,y_train.ravel() )
y_pred = logreg.predict(X_test_std_sk)
y_pred
y_real = pd.read_csv('Iris_test_labels.csv').values
from sklearn.metrics import confusion_matrix
confusion_matrix(y_real,y_pred)
from sklearn.metrics import accuracy_score
accuracy_score(y_real,y_pred)
y_prob=logreg.predict_proba(X_test_std_sk)
y_score=logreg.predict_proba(X_test_std_sk)[:,1]
from sklearn.metrics import roc_curve
y_real
fpr,tpr,thresholds=roc_curve(y_real, y_score)
после этого кода приходит ошибка. Я не знаю почему. Подробная ошибка
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-178-2d9f99ac1496> in <module>
----> 1 fpr,tpr,thresholds=roc_curve(y_real, y_score)
~\Anaconda3\lib\site-packages\sklearn\metrics\_ranking.py in roc_curve(y_true, y_score, pos_label, sample_weight, drop_intermediate)
769 """
770 fps, tps, thresholds = _binary_clf_curve(
--> 771 y_true, y_score, pos_label=pos_label, sample_weight=sample_weight)
772
773 # Attempt to drop thresholds corresponding to points in between and
~\Anaconda3\lib\site-packages\sklearn\metrics\_ranking.py in _binary_clf_curve(y_true, y_score, pos_label, sample_weight)
534 if not (y_type == "binary" or
535 (y_type == "multiclass" and pos_label is not None)):
--> 536 raise ValueError("{0} format is not supported".format(y_type))
537
538 check_consistent_length(y_true, y_score, sample_weight)
ValueError: multiclass format is not supported
То есть я не знаю, как решить эту проблему.