葡萄酒数据可视化分析

news2024/9/21 14:32:30

葡萄酒数据可视化分析

在必应壁纸必应壁纸供图

数据集:https://download.csdn.net/download/weixin_53742691/87982219

import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
wine = pd.read_csv("wine_quality/wine_edited.csv")
wine.head()
fixed acidityvolatile aciditycitric acidresidual sugarchloridesfree sulfur dioxidetotal sulfur dioxidedensitypHsulphatesalcoholqualitycoloralcohol_levelacidity_level
07.40.700.001.90.07611.034.00.99783.510.569.45redlowlow
17.80.880.002.60.09825.067.00.99683.200.689.85redlowmod_high
27.80.760.042.30.09215.054.00.99703.260.659.85redlowmedium
311.20.280.561.90.07517.060.00.99803.160.589.86redlowmod_high
47.40.700.001.90.07611.034.00.99783.510.569.45redlowlow
wine.info()
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 6497 entries, 0 to 6496
Data columns (total 15 columns):
 #   Column                Non-Null Count  Dtype  
---  ------                --------------  -----  
 0   fixed acidity         6497 non-null   float64
 1   volatile acidity      6497 non-null   float64
 2   citric acid           6497 non-null   float64
 3   residual sugar        6497 non-null   float64
 4   chlorides             6497 non-null   float64
 5   free sulfur dioxide   6497 non-null   float64
 6   total sulfur dioxide  6497 non-null   float64
 7   density               6497 non-null   float64
 8   pH                    6497 non-null   float64
 9   sulphates             6497 non-null   float64
 10  alcohol               6497 non-null   float64
 11  quality               6497 non-null   int64  
 12  color                 6497 non-null   object 
 13  alcohol_level         6497 non-null   object 
 14  acidity_level         6496 non-null   object 
dtypes: float64(11), int64(1), object(3)
memory usage: 761.5+ KB

单一变量的可视化

sns.countplot(x='color',data=wine);


png

sns.countplot(x='acidity_level',data=wine);

png

sns.countplot(x='quality',data=wine);

png

sns.color_palette()

base_color = sns.color_palette()[0]
sns.countplot(x='color',data=wine,color=base_color);

png

sns.countplot(x='quality',data=wine,color=base_color);

png

sns.countplot(y='acidity_level',data=wine,color=base_color);

png

 wine.acidity_level.value_counts()
high        1717
mod_high    1643
low         1574
medium      1562
Name: acidity_level, dtype: int64
ph_order = wine.acidity_level.value_counts().index
sns.countplot(y='acidity_level',data=wine,color=base_color,order=ph_order);

png

sns.countplot(x='acidity_level',data=wine,color=base_color,order=ph_order);

png

sns.countplot(x='acidity_level',data=wine,color=base_color,order=ph_order);

acidity_class = wine['acidity_level'].value_counts()
locs,lables = plt.xticks()

for i in range(len(locs)):
    put_string = acidity_class[i]
    plt.text(locs[i],put_string-100,put_string,color='white',ha='center')

png

sns.countplot(y='acidity_level',data=wine,color=base_color,order=ph_order);

acidity_class = wine['acidity_level'].value_counts()
locs,lables = plt.yticks()

for i in range(len(locs)):
    put_string = acidity_class[i]
    plt.text(put_string+100,locs[i],put_string,ha='center')

png

alcohol_data = wine.alcohol_level.value_counts().reset_index()
alcohol_data = alcohol_data.rename(columns={'index':'alcohol_level','alcohol_level':'alcohol_counts'})
alcohol_data
alcohol_levelalcohol_counts
0high3320
1low3177
sns.barplot(x='alcohol_level',y='alcohol_counts',data=alcohol_data,color=base_color);

png

plt.pie(alcohol_data.alcohol_counts,labels=alcohol_data.alcohol_level,startangle=90)
plt.show()

png

acidity_class = wine['acidity_level'].value_counts().reset_index()
acidity_class = acidity_class.rename(columns={'index':'acidity_level','acidity_level':'level_counts'})
acidity_class
acidity_levellevel_counts
0high1717
1mod_high1643
2low1574
3medium1562
plt.pie(acidity_class.level_counts,labels=acidity_class.acidity_level,startangle=90)
plt.show()

png

plt.pie(acidity_class.level_counts,labels=acidity_class.acidity_level,startangle=90,wedgeprops={'width':0.4})
plt.show()

png

wine.describe()
fixed acidityvolatile aciditycitric acidresidual sugarchloridesfree sulfur dioxidetotal sulfur dioxidedensitypHsulphatesalcoholquality
count6497.0000006497.0000006497.0000006497.0000006497.0000006497.0000006497.0000006497.0000006497.0000006497.0000006497.0000006497.000000
mean7.2153070.3396660.3186335.4432350.05603430.525319115.7445740.9946973.2185010.53126810.4918015.818378
std1.2964340.1646360.1453184.7578040.03503417.74940056.5218550.0029990.1607870.1488061.1927120.873255
min3.8000000.0800000.0000000.6000000.0090001.0000006.0000000.9871102.7200000.2200008.0000003.000000
25%6.4000000.2300000.2500001.8000000.03800017.00000077.0000000.9923403.1100000.4300009.5000005.000000
50%7.0000000.2900000.3100003.0000000.04700029.000000118.0000000.9948903.2100000.51000010.3000006.000000
75%7.7000000.4000000.3900008.1000000.06500041.000000156.0000000.9969903.3200000.60000011.3000006.000000
max15.9000001.5800001.66000065.8000000.611000289.000000440.0000001.0389804.0100002.00000014.9000009.000000
plt.hist(data=wine,x='pH')
plt.show()

png

import numpy as np
bin_edges = np.arange(wine.pH.min(),wine.pH.max()+0.05,0.05)
len(bin_edges )
27
plt.hist(data=wine,x='pH',bins=bin_edges)
plt.show()

png

bin_edges = np.arange(0.0,0.125+0.005,0.005)
plt.hist(data=wine,x='chlorides',bins=bin_edges)
plt.xlim((0.0,0.125))
plt.show()

png

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/708755.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

chatgpt赋能python:用Python来制作动画

用Python来制作动画 Python是一种高级编程语言&#xff0c;可以用于许多任务&#xff0c;包括数据分析、网络编程&#xff0c;甚至是制作动画。在这篇文章中&#xff0c;我们将讨论如何使用Python来制作动画。 Python中的动画库 Python中有许多用于制作动画的库。其中最流行…

论文笔记--Goat: Fine-tuned LLaMA Outperforms GPT-4 on Arithmetic Tasks

论文笔记--Goat: Fine-tuned LLaMA Outperforms GPT-4 on Arithmetic Tasks 1. 文章简介2. 文章概括3 文章重点技术3.1 LLM的选择3.2 算数任务的可学习性(learnability)3.3 大模型的加减乘除 4. 数值实验结果5. 文章亮点6. 原文传送门7. References 1. 文章简介 标题&#xff…

选读SQL经典实例笔记01_检索和排序

1. 在WHERE子句中引用别名列 1.1. 当表里的某些列没有被恰当命名的时候&#xff0c;这个技巧尤其有用 1.2. sql select sal as salary, comm as commissionfrom empwhere salary &#xff1c; 5000 1.3. 内嵌视图 1.3.1. sql select *from (select sal as salary, comm …

按 DDD 设计这个新项目

一、专业术语 各种服务 IAAS&#xff1a;基础设施服务&#xff0c;Infrastructure-as-a-service PAAS&#xff1a;平台服务&#xff0c;Platform-as-a-service SAAS&#xff1a;软件服务&#xff0c;Software-as-a-service 二、架构演变 图片 从图中已经可以很容易看出架…

R 语言 ggplot2 PCA 主成分分析(虚拟数据集)

生成虚拟数据集 library(ggplot2)data.matrix <- matrix(nrow 100, ncol 10)colnames(data.matrix) <- c(paste("wt",1:5,sep ""),paste("ko",1:5,sep "") )rownames(data.matrix) <- paste("gene",1:100,sep…

vue安装|win11系统

1.安装node.js https://nodejs.org/en/download 下载对应系统对应位数的.msi文件&#xff0c; 下载完成后&#xff0c;一直点击next进行安装 自定义安装路径&#xff0c;我的安装路径为**“D:\nodejs”** # 检查node.js版本 node -V# 检查npm版本 npm -V在D:\nodejs下新建两…

DataGrip连接clickhouse

首先保证ClickHouse启动了&#xff1a; 先建一个工程&#xff1a; 建立数据库源连接&#xff1a; 用户名和密码可以不写&#xff1a; 添加ClickHouse驱动&#xff1a;最好不用自己下载的驱动&#xff0c;会出现一些错误以及连接失败&#xff0c;用在线下载的。 选择一个版…

《深入浅出SSD:固态存储核心技术、原理与实战》----学习记录(三)

第3章 SSD存储介质&#xff1a;闪存 3.1 闪存物理结构 3.1.1 闪存器件原理 1978年诞生的世界上第一块固态硬盘就是基于DRAM的。但由于保存在DRAM中的数据有掉电易失性&#xff0c;当然还有成本因素&#xff0c;所以现在的固态硬盘一般都不采用DRAM&#xff0c;而是使用闪存…

JS对象的浅拷贝与深拷贝

一. 浅拷贝 定义&#xff1a;浅拷贝是按位拷贝对象&#xff0c;它会创建一个新对象&#xff0c;这个对象有着原始对象属性值的一份精确拷贝。如果属性是基本类型&#xff0c;拷贝的就是基本类型的值&#xff1b;如果属性是内存地址&#xff08;引用类型&#xff09;&#xff0c…

DETRs Beat YOLOs on Real-time Object Detection论文详解

论文题目&#xff1a;DETRs Beat YOLOs on Real-time Object Detection 论文地址&#xff1a;https://arxiv.org/abs/2304.08069 论文代码&#xff1a;mirrors / facebookresearch / ConvNeXt GitCode 等我毕业再打败吧&#xff0c;别打败YOLO&#xff0c;广大研究生们不同…

ROS:通信机制实操

目录 ROS&#xff1a;通信机制一、话题发布实操1.1需求1.2分析1.3实现流程1.4实现代码1.4.1C版1.4.2Python版 1.5执行 二、话题订阅实操2.1需求2.2分析2.3流程2.4实现代码2.4.1启动无辜GUI与键盘控制节点2.4.2C版 ROS&#xff1a;通信机制 一、话题发布实操 1.1需求 编码实现…

Airtest:Windows桌面应用自动化测试一

Airtest&#xff1a;Windows桌面应用自动化测试一 一、为什么选择Airtest?二、官方文档三、环境搭建四、简易操作1、模拟双击桌面应用2、连接应用窗口&#xff08;1&#xff09;嵌入方式连接&#xff08;2种方式连接应用窗口&#xff09;&#xff08;2&#xff09;非嵌入方式连…

设计模式学习之代理模式

设计模式系列往期文章 设计模式学习之策略模式设计模式学习之策略模式在前端的应用设计模式学习之简单工厂模式设计模式学习之工厂方法模式设计模式学习之抽象工厂模式设计模式学习之策略模式和简单工厂模式的对比设计模式学习之观察者模式设计模式学习之模板方法模式 代理模…

怎么把录音转文字?录音转文字怎么操作

以前在采访过程中&#xff0c;总是需要及时记录采访者的回答&#xff0c;并把这些回答准确地记录到笔记本上。然而手写记录不仅效率低下&#xff0c;还可能因为笔迹潦草而导致记录错误。 后来在前辈的指导下&#xff0c;我才知道可以使用录音转文字工具来解决这些问题&#xf…

[安洵杯 2019]game

前言 llvm混淆&#xff0c;第一次接触到&#xff0c;没找到可以直接反混淆的工具&#xff0c;但看了相关知识后&#xff0c;发现有效代码依旧是原有的那一小部分&#xff0c;所以可以直接看有意义的部分代码&#xff0c;有时间好好了解下吧 代码分析 v8是我们输入的&#xff…

设计模式篇(Java):适配器模式

设计模式篇(Java)&#xff1a;建造者模式 八、适配器模式 8.1 适配器模式基本介绍 生活中的适配器例子 比如生活中的插座&#xff0c;在不同国家插座有着不同的规格&#xff0c;如果我们从一个国家去另外一个国家需要使用插座时就需要一个中间转换器把两种不同规则的插座适配一…

【数据结构导论】第 3 章:栈、队列和数组

目录 一、栈 &#xff08;1&#xff09;栈的基本概念 ① 定义 ② 示意图 ③ 栈的特点 ④ 栈的基本运算 &#xff08;2&#xff09;栈的顺序实现 ① 顺序栈及常用名词 ② 顺序栈的类型定义 ③ 顺序栈的基本运算 Ⅰ. 初始化 Ⅱ. 判栈空 Ⅲ. 进栈 Ⅳ. 出栈 Ⅴ. …

【JavaSE】程序逻辑控制

目录 【1】概念 【2】顺序结构 【3】分支结构 【3.1】if 语句 【3.2】switch 语句 【4】循环结构 【4.1】while 循环 【4.2】for 循环 【4.3】do while 循环 【4.4】break 关键字 【4.5】continue 关键字 【5】输入输出 【5.1】输出到控制台 【5.2】从键盘输入 …

第38节:cesium 风场效果(含源码+视频)

结果示例: 完整源码: <template><div class="viewer"><vc-viewer @ready="ready" :logo="false"><!

抖音seo矩阵系统源码开发部署|抖音小程序接入(一)

一、 开发部署步骤&#xff1a; &#xff08;1&#xff09;申请开放平台服务商 &#xff08;2&#xff09;申请开放平台网站应用 &#xff08;3&#xff09;申请开放平台应用权限 &#xff08;4&#xff09;提交各个API接口申请文档 &#xff08;5&#xff09;审核通过技…