关住 公 纵 号 “ 阿蒙课程分享 ” 获得学习资料及趣味分享
import sys
from class_vis import prettyPicturefrom prep_terrain_data import makeTerrainData
import matplotlib.pyplot as plt
import copy
import numpy as np
import pylab as pl
features_train, labels_train, features_test, labels_test = makeTerrainData()
########################## SVM #################################
### we handle the import statement and SVC creation for you here
from sklearn.svm import SVC
clf = SVC(kernel="linear")
#### now your job is to fit the classifier
#### using the training features/labels, and to
#### make a set of predictions on the test data
clf.fit(features_train, labels_train)
#### store your predictions in a list named pred
pred = clf.predict(features_test)
from sklearn.metrics import accuracy_score
acc = accuracy_score(pred, labels_test)
def submitAccuracy():
return acc
本文通过使用Python的scikit-learn库实现支持向量机(SVM)分类器,并在地形数据集上进行训练与测试。从数据准备到模型训练、预测直至评估准确率,详细展示了SVM的工作流程。
936

被折叠的 条评论
为什么被折叠?



