2. SVM


📌
########### 6. SVM(Support Vector Machine)
# SVM(Support Vector Machine) 분류 알고리즘으로 모델 구현하기
# SVM : 공간을 (선/면)으로 분류하는 방식
from sklearn import svm
# kernel='rbf' : 공간분리 방식을 결정하는 함수 지정
# rbf(기본값), linear, poly(곡선)
svm_model = svm.SVC(kernel='rbf') # SVM 객체 설정
svm_model.fit(x_train, y_train) # 학습하기
y_hat = svm_model.predict(x_test) # 예측하기
svm_report = metrics.classification_report(y_test, y_hat)
svm_report
svm_matrix = metrics.confusion_matrix(y_test, y_hat)
svm_matrix
# 함수들을 이용하여 정확도, 정밀도, 재현율, f1_Score 값 출력하기
print("정확도(accuracy): %.3f" %\\
accuracy_score(y_test, y_hat))
print("정밀도(Precision) : %.3f" %\\
precision_score(y_test, y_hat))
print("재현율(Recall) : %.3f" %\\
recall_score(y_test, y_hat))
print("F1-score : %.3f" %\\
f1_score(y_test, y_hat))

'수업(국비지원) > Python' 카테고리의 다른 글
| [Python] 지도학습 예제 - 투수들의 연봉 예측하기2 (0) | 2023.04.26 |
|---|---|
| [Python] 머신러닝 - 지도학습(분류) 3. Decision Tree(의사결정나무) (0) | 2023.04.26 |
| [Python] 머신러닝 - 지도학습(분류) 1. KNN (0) | 2023.04.26 |
| [Python] 머신러닝 - 지도학습(회귀분석)3 (0) | 2023.04.26 |
| [Python] 머신러닝 - 지도학습(회귀분석)1 (0) | 2023.04.26 |