เพิ่มความแม่นยำสำหรับ SVM ด้วยเคอร์เนลเชิงเส้น

ฉันใช้ Support Vector Machines (SVM) กับเคอร์เนล 'เชิงเส้น' สำหรับการจำแนกหลายประเภท อย่างไรก็ตามความแม่นยำยังต่ำมาก เป็นไปได้ไหมที่จะเพิ่มความแม่นยำ?

import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np
from sklearn.model_selection import train_test_split
from sklearn.metrics import accuracy_score,classification_report,confusion_matrix
from sklearn.svm import SVC

#Prepare data for SVM
Diabetes_SVM = Diabetes2[['metformin','repaglinide','nateglinide','chlorpropamide','glimepiride','acetohexamide', 'glipizide', 'glyburide','troglitazone', 'tolazamide', 'examide','citoglipton', 'insulin']]

#Create dummy variables
nominal = ['metformin','repaglinide','nateglinide','chlorpropamide','glimepiride','acetohexamide', 'glipizide', 'glyburide', 
           'tolbutamide', 'pioglitazone', 'rosiglitazone', 'acarbose', 'miglitol', 'troglitazone', 'tolazamide', 'examide',
           'citoglipton']
Diabetes_SVM = pd.get_dummies(Diabetes_SVM,columns=nominal)

#Map data for SVM
Diabetes_SVM['insulin']=Diabetes_SVM['insulin'].map({'Down': 1,'No': 2,
                                                     'Steady': 3,'Up': 4})

#Defining features and target variable for SVM
X_SVM = Diabetes_SVM.drop('insulin', axis=1).values
y_SVM = Diabetes_SVM['insulin'].values

#Split dataset into training set and test set for SVM
X_train, X_test, y_train, y_test = train_test_split(X_SVM, y_SVM, test_size=0.30, random_state=42)

#Fit SVC Class
svclassifier = SVC(kernel='linear')
svclassifier.fit(X_train, y_train)

#Making Predictions
y_pred = svclassifier.predict(X_test)
print(confusion_matrix(y_test,y_pred))
print(classification_report(y_test,y_pred))

ฉันได้ลองใช้ SVM ด้วยตัวแยกประเภทเชิงเส้นที่มีความแม่นยำเพียง 0.47 แล้ว ฉันจะปรับความแม่นยำได้อย่างไร?


person Nith    schedule 21.01.2021    source แหล่งที่มา
comment
ชุดฝึกซ้อมใหญ่แค่ไหน? มันไม่สมดุลเหรอ?   -  person Epimetheus    schedule 21.01.2021
comment
svclassifier = SVC(เคอร์เนล='เชิงเส้น') คุณกำลังใช้เคอร์เนลเชิงเส้น   -  person Epimetheus    schedule 21.01.2021
comment
ชุดฝึกซ้อมมีประมาณ 68,637 รายการ ฉันพยายามตรวจสอบมัน   -  person Nith    schedule 21.01.2021


คำตอบ (1)


ลอง SVC(kernel='poly') และทำให้ข้อมูลของคุณเป็นมาตรฐาน เปรียบเทียบผลลัพธ์ของคุณกับตัวแยกประเภท LogisticRegression() ใช้ตัวแยกประเภทที่ดีที่สุดสำหรับข้อมูลของคุณ ทดสอบข้อมูลของคุณเพื่อดูว่าข้อมูลไม่เป็นเชิงเส้นหรือไม่ ใช้ pytorch หรือ keras หรือ GLM หากข้อมูลไม่เป็นเชิงเส้น

 from sklearn.preprocessing import StandardScaler

 X=df[NUMERIC]
 y=df['Target']

 X_train,X_test,y_train, y_test=train_test_split(X,y,test_size=0.1,random_state=42)

 scaler = MinMaxScaler()
 X_train[X_train.columns] = scaler.fit_transform(X_train[X_train.columns])
 X_test[X_test.columns] = scaler.transform(X_test[X_test.columns])

 model=SVC(kernel='poly', degree=3,C=1E10)
 model.fit(X_train,y_train)
 y_pred=model.predict(X_test)
 print("Accuracy:",metrics.accuracy_score(y_test, y_pred))
person Golden Lion    schedule 09.03.2021
comment
ดูการปรับปรุงความแม่นยำสำหรับเครื่องเวกเตอร์สนับสนุนของฉัน (stackoverflow.com/questions/39001936/) ผู้เขียนแนะนำให้ใช้ BaggingClassifier และแนวทางทั้งมวลเพื่อปรับปรุงความแม่นยำ - person Golden Lion; 09.03.2021
comment
ทำการทดสอบความผิดปกติและค้นหาค่าผิดปกติในข้อมูลของคุณ คุณทำคลัสเตอร์ k-mean เพื่อดูว่ามีการจัดกลุ่มใดบ้างในข้อมูลของคุณ โดยปกติแล้วเมื่อคะแนนของคุณต่ำ ข้อมูลก็จะไม่ดี - person Golden Lion; 09.03.2021
comment
เพิ่ม C เป็นจำนวนมากเพื่อการลู่เข้า - person Golden Lion; 10.03.2021
comment
ดูการแทนที่ svm ด้วย pytorch ฉันสามารถแสดงให้คุณเห็นว่า - person Golden Lion; 10.03.2021