每个类别的ROC曲线

问题描述

代码

df = pd.read_csv(r"model_data_TBI_3(o).csv",index_col= ["X","Y"])
X = df.drop("class",axis= "columns")
y = df["class"]
array  = y.values
y = array[: :]
  
y = label_binarize(y,classes= [1,2,3],pos_label= 1,neg_label= 0)
n_classes = y.shape[1]
print(n_classes)
X_train,X_test,y_train,y_test = train_test_split(X,y,random_state=45,train_size=0.10)
mm = MinMaxScaler()
mm.fit(X_train)
X_train_mm = mm.transform(X_train)
X_test_mm = mm.transform(X_test)
svm_tuned = SVC(kernel= "rbf",C=2.33,gamma= 0.00046,probability= True,break_ties= False,decision_function_shape="ovo",random_state=1,shrinking=True,tol=0.12,class_weight={1:100,1:75,2:55})
y_score = svm_tuned.fit(X_train_mm,y_train).decision_function(X_test_mm)

结果:

ValueError: y should be a 1d array,got an array of shape (329,3) instead.

我想绘制我的svm模型的ROC曲线。我的数据有1,3个类别。我使用标签二值化器对它们进行二值化,但仍然收到此错误。追溯错误位于y_score。我对那些想要清除我的疑问或解决方案的人的请求,请不要向我发送虹膜数据的代码,我可以在sklearn网站上查找该代码,请给我解释或编写您的代码解决此问题。我真的感谢那些会回答的人。抱歉,如果我在发布问题时犯了任何错误,我是Stackoverflow的新手,也是python和机器学习的新手。 谢谢

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)