python 实现 Peceptron Learning Algorithm ( 三) 感知机模型应用于Iris数据集

本文介绍了使用Python实现感知机学习算法,并将其应用于经典的Iris数据集。作者通过阅读《Python Machine Learning》并理解相关函数,逐步解析了感知机模型的实现过程,代码可在GitHub上找到。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

参考 《python machine learning》

代码读的很费劲,应该是没有功底的原因吧然后就挨个的百度不懂的函数,函数记录在了(一)中,

链接为 http://blog.youkuaiyun.com/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 = np.where(y == 'Iris-setosa',-1, +1)  

# first feature column (s
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值