探索Iris鸢尾花数据集:从入门到进阶

学习笔记:探索Iris纸鸢花数据 探索Iris纸鸢花数据 阅读详情

欢迎来到本篇博客!今天我们将一起来探索一个经典的机器学习问题,即Iris鸢尾花数据集。无论你是机器学习初学者还是有一些经验的数据科学家,这篇文章都将为你提供有关这个数据集的深入理解以及如何使用机器学习算法进行分类的实践经验。

引言

Iris鸢尾花数据集是一个经典的数据集,由统计学家和生物学家Ronald A. Fisher于1936年首次介绍。该数据集包含了三个不同种类的鸢尾花:山鸢尾(setosa)、变色鸢尾(versicolor)和维吉尼亚鸢尾(virginica)。每个类别包含50个样本,总共150个样本。每个样本都有四个特征:花萼长度(sepal length)、花萼宽度(sepal width)、花瓣长度(petal length)和花瓣宽度(petal width)。

Iris鸢尾花数据集通常用于分类问题,即根据这四个特征来预测鸢尾花的种类。这是一个非常适合入门机器学习的数据集,因为它小巧且易于理解。

步骤1:导入必要的库

首先,我们需要导入一些Python库,以便进行数据分析和机器学习建模。以下是我们将使用的库:

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler
from sklearn.ensemble import RandomForestClassifier
from sklearn.metrics import accuracy_score, classification_report

步骤2:加载和探索数据

接下来,让我们加载Iris数据集并进行一些初步的数据探索。我们将使用

Pandas数据分析练习10 练习10-删除数据 探索Iris纸鸢花数据 目录 步骤1 导入必要的库 步骤2 数据集地址 步骤3 将数据集存成变量iris 步骤4 创建数据框的列名称 步骤5 数据框中有缺失值吗? 步骤6 将列petal_length的第10到19行设置为缺失值 步骤7 将缺失值全部替换为1.0 步骤8 删除列class 步骤9 将数据框前三行设置为缺失值 步骤10 删除有缺失值的行 步骤11 重新设置索引 代码截图 步骤1 导入必要的库 运行以下代码 #导入必要的库 import p 阅读详情

相关推荐

重拾Iris鸢尾花数据集分析

重拾Iris鸢尾花数据集分析

A Lucky Boy的博客 4531

基于朴素贝叶斯网络的iris鸢尾花数据集分类到新闻分类

本篇文章是对最简单的朴素贝叶斯网络的运用进行python实践,先对iris鸢尾花数据集做一个分类预实验,再对实际新闻进行分类预测 有关贝叶斯网络原理可以查看这篇文章 :贝叶斯网络基础 一、iris鸢尾花数据集分类 1、开头先导入相关模块: import matplotlib.pyplot as plt # 绘图 from sklearn.datasets import load_iris #导...

m0_46557838的博客 6956

sklearn数据集——iris鸢尾花数据集_iris数据集

通过上面的描述信息,我们可以知道该数据集包含150条数据,每50条数据属于一个类别,即有三个类别,每一条数据有四个特征。target_names 键对应的值是一个字符串数组,里面包含我们要预测的花的品种: 输出: 由此,我们可以知道鸢尾花数据集iris包含3类鸢尾花,分别为山鸢尾(Iris-setosa)、杂色鸢尾(Iris-versicolor)和维吉尼亚鸢尾(Iris-virginica)feature_names 键对应的值是一个字符串列表,对每一个特征进行了说明: 输出: 由此,我们可以知道每条数据

2401_84010362的博客 1303

Iris(鸢尾花) 数据集-机器学习入门

共同学习之作,欢迎讨论,因为个人能力问题,存在诸多不足。共同进步。 目录 一 环境 二 基础知识 三 任务 1.导入需要的库 2.数据载入 3.训练模型 4.预测 5.结果 GIT地址: 一 环境 第一步,去https://www.python.org/官网下载最新的Python。 开发环境用pycharm或者anaconda都行,个人建议两个都下,我是两个都用,但是p...

盼你开心 5454

sklearn数据集——iris鸢尾花数据集_iris数据集(1)

鸢尾花(Iris)数据集,是机器学习和统计学中一个经典的数据集。它包含在 scikit-learn 的 datasets 模块中。我们可以调用 load_iris 函数来加载数据: load_iris 返回的 iris 对象是一个 Bunch 对象,与字典非常相似,里面包含键和值: 输出: 可以看到,数据集有很多的keys。DESCR 键对应的值是数据集的简要说明。我们查看前面的部分内容: 输出: 通过上面的描述信息,我们可以知道该数据集包含150条数据,每50条数据属于一个类别,即有三个类别,每一条数据有

2401_84010326的博客 1756

鸢尾花(Iris)数据集

鸢尾花数据集的sql文件,内含150个数据样本。

整合WGCNA、机器学习和孟德尔随机化

(G)通过蛋白质免疫印迹法(Western blot)测定的 UT-B(由 SLC14A1 编码)、ARHGEF38、NEFH、MSMB、KRT23 和 KRT15 在前列腺癌肿瘤组织和癌旁非癌组织中的蛋白质表达水平。本研究利用来自基因表达综合数据库(GEO)的数据集筛选差异表达基因(DEGs),并采用加权基因共表达网络分析(WGCNA),以识别在模块中与前列腺癌高度相关的驱动基因。(F)蓝绿色模块中的模块成员关系(MM)与前列腺癌(PCa)的基因显著性(GS)的散点图。(D)6 个基因之间的相关性分析。

多组・学・多组学 1135

国家医保移动支付国密算法SM2签名验签、SM4加解密DLL

DLL,非.net开发,所以无需安装配置,直接程序引用开发即可,支持各类开发语言。已知省份有广西、贵州、安徽、河北、黑龙江、湖南、吉林、江苏、四川、新疆等各地方。国家医保移动支付国密算法SM2签名验签、SM4加解密DLL。//SM4加密与解密。支持医保移动支付(国家统一版),//SM2签名与验签。

4258

部署资源管理系统chemx

资源管理系统的部署教程

weixin_40784215的博客 822

瑞昱RTL8735B开发板深度评测:如何用200元板子搞定1080P视频流+AI推理?

本文深度评测瑞昱RTL8735B开发板(AMB82 MINI),解析其如何在200元预算内实现1080P视频流处理与边缘AI推理。该板搭载0.4TOPS NPU算力,支持H.264/H.265编码,适合物联网开发者构建高性价比边缘计算方案,并详细介绍了硬件架构、AI模型优化及实战项目搭建。

weixin_33712987的博客 520

MarkDown简介(深度解析MarkDown用法)

欢迎使用Markdown编辑器写博客 本Markdown编辑器使用StackEdit修改而来,用它写博客,将会带来全新的体验哦: Markdown和扩展Markdown简洁的语法 代码块高亮 图片链接和图片上传 LaTex数学公式 UML序列图和流程图 离线写博客 导入导出Markdown文件 丰富的快捷键 快捷键 加粗 Ctrl + B 斜体 Ctrl + I...

酷酷的旭 7340

智能车竞赛模糊PID代码与使用方法

本文给出了模糊PID的代码,以及模糊PID的程序使用方法、参数调整方法

piginthesouth的博客 9122

Camera Sensor接口协议全解析(六)聚焦onsemi HiSPi接口的技术突破与应用实践

摘要: Onsemi HiSPi是一种高速并行接口协议,专为高分辨率图像传感器设计,具备1600 Mbps传输速率、低功耗和高兼容性特点。通过对比DVP、MIPI CSI-2等主流协议,HiSPi在工业/医疗领域表现突出,支持动态功耗控制、多ROI和CRC校验。其创新架构包含多PHY设计,提供分组SP、流SP等多种工作模式,满足灵活传输需求。实际应用中,HiSPi在PCB缺陷检测(5μm精度)和液晶面板检测(0.3% Mura检出率)等场景展现卓越性能,成为高速成像领域的关键技术。

GateWorld的博客 1434

物理AI:连接数字智能与物理世界的下一代人工智能范式

物理AI正在推动人工智能从纯数字领域向物理世界扩展,实现比特到原子的智能跃迁。与传统AI相比,物理AI具有三大核心差异:1)在物理环境中运行;2)处理多模态传感器输入;3)产生可改变物理状态的输出。其技术栈包含感知层(多模态融合)、决策层(边缘计算)、执行层(运动控制)和连接层(5G/6G通信)。关键技术挑战包括:实时多传感器融合、物理约束下的决策规划、以及高精度执行控制。物理AI的发展面临实时性保障、安全验证等核心挑战,但其在机器人、自动驾驶等领域的应用潜力巨大,正成为智能技术落地的关键突破口。

fudaihb的博客 1707

VB摄像头监控

该VB模块可对摄像头捕获的画面进行录像等,可在创建的窗口进行控制

汉书HE8,好用的汇编代码编写工具

汉书HE8,好用的汇编代码编写工具早期编写汇编代码所用功能强大

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

上一篇: 机器学习算法详解:Seq2Seq模型
下一篇: 泰坦尼克号数据集分析:从入门到进阶
洞深视界
博客等级 码龄3年 575粉丝 142原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值