# 导入头文件
import pandas as pd
import numpy as np
from sklearn.linear_model import LogisticRegression
from sklearn.tree import DecisionTreeClassifier
from sklearn.svm import SVC
import matplotlib.pyplot as plt
data = pd.read_csv('data.csv')
np.array(data['y'])
# 分解数据中的
X = np.array(data[['x1', 'x2']])
y = np.array(data['y'])
plt.scatter(X[:,0],X[:,1],c=y)
# Logistic Regression Classifier
lg_classifier = LogisticRegression()
lg_classifier.fit(X,y)
y_p = lg_classifier.predict(X)
plt.scatter(X[:,0],X[:,1],c=y_p)
Dt_classifier = DecisionTreeClassifier()
Dt_classifier.fit(X, y)
y_Dp = Dt_classifier.predict(X)
plt.scatter(X[:,0],X[:,1],c=y_Dp)
svc_classifier = SVC()
svc_classifier.fit(X, y)
y_sp = svc_classifier.predict(X)
plt.scatter(X[:,0],X[:,1],c=y_sp)
svc_classifier1 = SVC(kernel = 'poly', degree=8)
svc_classifier1.fit(X, y)
y_sp1 = svc_classifier1.predict(X)
plt.scatter(X[:,0],X[:,1],c=y_sp1)
svc_classifier1 = SVC(kernel = 'rbf', gamma=200)
svc_classifier1.fit(X, y)
y_sp1 = svc_classifier1.predict(X)
plt.scatter(X[:,0],X[:,1],c=y_sp1)
svc_classifier1 = SVC(kernel = 'linear')
svc_classifier1.fit(X, y)
y_sp1 = svc_classifier1.predict(X)
plt.scatter(X[:,0],X[:,1],c=y_sp1)