参考 《python machine learning》
代码读的很费劲,应该是没有功底的原因吧然后就挨个的百度不懂的函数,函数记录在了(一)中,
链接为 http://blog.csdn.net/Amy_mm/article/details/79625288
Iris数据集 以及源码 可以在github上下载~~
GIT: https://github.com/xuman-Amy/Perceptron_python
代码及详细注释如下
# load iris dataset
import pandas as pd
df = pd.read_csv("G:\Machine Learning\python machine learning\python-machine-learning-book-2nd-edition-master\code\ch02\iris.data",header = None)
df.tail()
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
# select setosa and versicolor
#iloc()提取某列 ----前100行的第四列,第四例为versicolor和setosa属性
y = df.iloc[0:100,4].values
#进行分类 1 ( versicolor ) and -1 ( setosa )
y = n