generated from LufsX/Challenge-SVM
This commit is contained in:
+10
-2
@@ -33,6 +33,13 @@ name = "邓龙树"
|
|||||||
|
|
||||||
|
|
||||||
# 这里写自己的代码实现
|
# 这里写自己的代码实现
|
||||||
|
import numpy as np
|
||||||
|
from sklearn.svm import SVC
|
||||||
|
from sklearn.model_selection import train_test_split, KFold
|
||||||
|
from sklearn.metrics import classification_report, accuracy_score
|
||||||
|
from sklearn.preprocessing import StandardScaler
|
||||||
|
|
||||||
|
|
||||||
def load_data(filepath):
|
def load_data(filepath):
|
||||||
"""
|
"""
|
||||||
从文件中加载数据,若不自行正确实现,则无法通过评测,**不记录成绩**。
|
从文件中加载数据,若不自行正确实现,则无法通过评测,**不记录成绩**。
|
||||||
@@ -165,7 +172,8 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
# 使用在交叉验证中选出的最佳模型在最终测试集上进行评估
|
# 使用在交叉验证中选出的最佳模型在最终测试集上进行评估
|
||||||
evaluate_model(best_model, X_final_test, y_final_test)
|
evaluate_model(best_model, X_final_test, y_final_test)
|
||||||
|
|
||||||
# 测试单个数据
|
# 测试单个数据
|
||||||
test_sample = X_final_test[11] # 选择第12个样本(从0开始计数)
|
test_sample = X_final_test[11] # 选择第12个样本(从0开始计数)
|
||||||
predict_single_sample(best_model, test_sample, y_final_test[11])
|
predict_single_sample(best_model, test_sample, y_final_test[11])
|
||||||
|
|
||||||
Reference in New Issue
Block a user