这个例子令我感到非常不解,从散点图来看,准确率大概应该有个90%左右。当最高次项为5的时候,也并没有出现过拟合的特征,当然也没有欠拟合。 我尝试加正则,表现也并不好。
从数据上来看,最高次项为3以后就开始出现过拟合了,但是为什么我加正则之后表现仍然不算好呢?
# -*-coding:utf-8-*-
import matplotlib.pyplot as plt
import pandas as pd
df = pd.read_csv('data/data2.txt', names=['1', '2', 'admit'])
df_positive = df[df['admit'] == 1]
df_negative = df[df['admit'] == 0]
plt.scatter(df_positive['1'], df_positive['2'], marker='o')
plt.scatter(df_negative['1'], df_negative['2'], marker='x')
plt.show()
df = df.as_matrix()
col = df.shape[1]
print col
X = df[:, 0:col - 1]
y = d