资源简介
鸢尾花卉数据集,是一类多重变量分析的数据集。通过花萼长度,花萼宽度,花瓣长度,花瓣宽度4个属性预测鸢尾花卉属于(Setosa,Versicolour,Virginica)三个种类中的哪一类。是机器学习基础学习的典型案例。

代码片段和文件信息
# coding :utf-8
import pandas as pd
import numpy as np
from sklearn.linear_model import LogisticRegression
from sklearn.model_selection import train_test_split
import matplotlib as mpl
import matplotlib.pyplot as plt
from sklearn import svm
import matplotlib.patches as mpatches
from sklearn.preprocessing import StandardScaler PolynomialFeatures
from sklearn.pipeline import Pipeline
def iris_type(s):
it = {b‘Iris-setosa‘: 0
b‘Iris-versicolor‘: 1
b‘Iris-virginica‘: 2}
return it[s]
if __name__==“__main__“:
data=np.loadtxt(‘.\\iris.data‘delimiter=‘‘converters={4:iris_type})
x=data[:0:2]
y=data[:4]
x_trainx_testy_trainy_test=train_test_split(xytest_size=0.2random_state=1)
#Ir = Pipeline([(‘sc‘ StandardScaler()) ‘poly‘ PolynomialFeatures(degree=2))(‘clf‘ LogisticRegression()) ])
# Ir=LogisticRegression(C=4.6)
Ir=svm.SVC(C=1kernel=‘rbf‘decision_function_shape=‘ovo‘)
Ir.fit(x_trainy_train)
y_hat=Ir.predict(x_test)
print(‘训练集准确度:‘ Ir.score(x_trainy_train))
print(‘测试集准确度:‘ Ir.score(x_testy_test))
err_y = y_test[y_test != y_hat]
print(y_test)
print(err_y)
#画图
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 4551 2018-05-17 11:58 鸢尾花线性回归\iris.data
文件 1250 2018-10-15 15:47 鸢尾花线性回归\test3_LG.py
目录 0 2018-12-07 12:50 鸢尾花线性回归
----------- --------- ---------- ----- ----
5801 3
- 上一篇:机房批量修改ip脚本
- 下一篇:数据的导入与预处理课程设计附带报告书
相关资源
- pywin32_python3.6_64位
- python+ selenium教程
- PycURL(Windows7/Win32)Python2.7安装包 P
- 英文原版-Scientific Computing with Python
- 7.图像风格迁移 基于深度学习 pyt
- 基于Python的学生管理系统
- A Byte of Python(简明Python教程)(第
- Python实例174946
- Python 人脸识别
- Python 人事管理系统
- 基于python-flask的个人博客系统
- 计算机视觉应用开发流程
- python 调用sftp断点续传文件
- python socket游戏
- 基于Python爬虫爬取天气预报信息
- python函数编程和讲解
- Python开发的个人博客
- 基于python的三层神经网络模型搭建
- python实现自动操作windows应用
- python人脸识别(opencv)
- python 绘图(方形、线条、圆形)
- python疫情卡UN管控
- python 连连看小游戏源码
- 基于PyQt5的视频播放器设计
- 一个简单的python爬虫
- csv文件行列转换python实现代码
- Python操作Mysql教程手册
- Python Machine Learning Case Studies
- python获取硬件信息
- 量化交易(附python常见函数的使用方
评论
共有 条评论