支持向量机SVM
二分类模型 非线性分类器
学习策略:间隔最大化
学习目标:在特征空间中找到一个超平面
from sklearn.svm import LinearSVC
from sklearn.datasets import load_iris
from sklearn.model_selection import train_test_split
import numpy as np
if __name__ == "__main__":
dataset = load_iris()
X = dataset.data
y = dataset.target
Xd_train, Xd_test, y_train, y_test = train_test_split(X, y, random_state=14)
clf = LinearSVC(random_state=0)
clf = clf.fit(Xd_train, y_train)
y_predicted = clf.predict(Xd_test)
accuracy = np.mean(y_predicted == y_test) * 100
print("y_test ", y_test)
print("y_predicted", y_predicted)
print("accuracy:", accuracy)