import numpy as np
from sklearn.datasets import load_iris #导入数据集iris
import matplotlib.pyplot as plt
plt.rcParams['font.sans-serif'] = ['SimHei'] # 中文显示
plt.rcParams['axes.unicode_minus'] = False # 负号显示
iris=load_iris()
# print(iris)
train_x=iris.data
# print(train_x)
train_y=iris.target
# print(train_y)
def data_deal(x,y):
x-=np.mean(x,axis=0)
x/=np.std(x,axis=0)
x1 = x[:, 0]
x2 = x[:, 1]
x3 = x[:, 2]
x4 = x[:, 3]
x=np.c_[np.ones(len(x)),x1+x2,x3+x4]
# 0.1*x1+0.2*x2,0.1*x3+0.05*x4]
y=np.c_[y]
return x,y
[X,Y]=data_deal(train_x,train_y)
# print(X,Y)
#0,1,1
X1=X
Y1=np.c_[[np.zeros(50)]
,[np.ones(50)],[np.ones(50)]]
Y1=Y1.reshape(150,1)
# print(Y1)
#1,0,1
X2=X
Y2=np.c_[[np.ones(50)]
,[np.zeros(50)],[np.ones(50)]]
Y2=Y2.reshape(150,1)
# print(Y2)
#1,1,0
X3=X
Y3=np.c_[[np.ones(
|