《Python数据分析技术栈》第03章 03 可视化各级数据(Visualizing various levels of data)

03 可视化各级数据(Visualizing various levels of data)

《Python数据分析技术栈》第03章 03 可视化各级数据(Visualizing various levels of data)

Whenever you need to analyze data, first understand if the data is structured or unstructured. If the data is unstructured, convert it to a structured form with rows and columns, which makes it easier for further analysis using libraries like Pandas. Once you have data in this format, categorize each of the features or columns into the four levels of data and perform your analysis accordingly.

无论何时需要分析数据,首先要了解数据是结构化的还是非结构化的。如果是非结构化数据,则应将其转换为具有行和列的结构化形式,这样更便于使用 Pandas 等库进行进一步分析。有了这种格式的数据后,将每个特征或列归类到数据的四个层次,然后进行相应的分析。

Note that in this chapter, we only aim to understand how to categorize the variables in a dataset and identify the operations and plots that would apply for each category. The actual code that needs to be written to visualize the data is explained in Chapter 7.

请注意,在本章中,我们只想了解如何对数据集中的变量进行分类,并确定适用于每个类别的操作和绘图。为实现数据可视化而需要编写的实际代码将在第 7 章中讲解。

We look at how to classify the features and perform various operations using the famous Titanic dataset. The dataset can be imported from here: https://github.com/DataRepo2019/Data-files/blob/master/titanic.csv

我们将使用著名的泰坦尼克号数据集来研究如何对特征进行分类并执行各种操作。数据集可从此处导入: https://github.com/DataRepo2019/Data-files/blob/master/titanic.csv

Background information about the dataset: The RMS Titanic, a British passenger ship, sank on its maiden voyage from Southampton to New York on 15th April 1912, after it collided with an iceberg. Out of the 2,224 passengers, 1,500 died, making this event a tragedy of epic proportions. This dataset describes the survival status of the passengers and other details about them, including their class, name, age, and the number of relatives.

数据集背景信息: 1912 年 4 月 15 日,英国皇家泰坦尼克号客轮在从南安普顿到纽约的处女航中与冰山相撞沉没。在 2224 名乘客中,有 1500 人丧生,使这一事件成为史诗般的悲剧。该数据集描述了乘客的生还状况及其他详细信息,包括他们的等级、姓名、年龄和亲属人数。

在这里插入图片描述

The features in this dataset, classified according to the data level, are captured in Table 4-1.

表 4-1 根据数据级别对数据集中的特征进行了分类。

在这里插入图片描述

Let us now understand the rationale behind the classification of the features in this dataset.

现在,让我们来了解一下对该数据集中的特征进行分类的原理。

Nominal variables: Variables like “PassengerId”, “Survived”, “Name”, “Sex”, “Cabin”, and “Embarked” do not have any intrinsic ordering of their values. Note that some of these variables have numeric values, but these values are finite in number. We cannot perform an arithmetic operation on these values like addition, subtraction, multiplication, or division. One operation that is common with nominal variables is counting. A commonly used method in Pandas, value_counts (discussed in the next chapter), is used to determine the number of values per each unique category of the nominal variable. We can also find the mode (the most frequently occurring value). The bar graph is frequently used to visualize nominal data (pie charts can also be used), as shown in Figure 4-5.

名义变量: PassengerId"、“Survived”、“Name”、“Sex”、"Cabin "和 "Embarked "等变量的值没有内在顺序。需要注意的是,其中一些变量有数值,但这些数值的数量是有限的。我们无法对这些数值进行加、减、乘或除等算术运算。对名义变量常用的一种操作是计数。Pandas 中的一个常用方法 value_counts(将在下一章中讨论)用于确定标称变量中每个独特类别的值的数量。我们还可以找到模式(出现频率最高的值)。如图 4-5 所示,条形图常用于将名义数据可视化(也可以使用饼图)。

Ordinal variables: “Pclass” (or Passenger Class) is an ordinal variable since its values follow an order. A value of 1 is equivalent to first class, 2 is equivalent to the second class, and so on. These class values are indicative of socioeconomic status.

顺序变量: “Pclass”(或乘客等级)是一个顺序变量,因为它的值是有顺序的。数值 1 代表一等舱,2 代表二等舱,以此类推。这些等级值表明了社会经济地位。

We can find out the median value and percentiles. We can also count the number of values in each category, calculate the mode, and use plots like bar graphs and pie charts, just as we did for nominal variables.

我们可以找出中位值和百分位数。我们还可以计算每个类别中的数值个数、计算模式,并使用条形图和饼图等图表,就像我们对名义变量所做的那样。

In Figure 4-6, we have used a pie chart for the ordinal variable “Pclass”

在图 4-6 中,我们使用饼图来表示序数变量 “Pclass”。

Ratio Data: The “Age” and “Fare” variables are examples of ratio data, with the value zero as a reference point. With this type of data, we can perform a wide range of mathematical operations. For example, we can add all the fares and divide it by the total number of passengers to find the mean. We can also find out the standard deviation. A histogram, as shown in Figure 4-7, can be used to visualize this kind of continuous data to understand the distribution.

比率数据: 年龄 "和 "票价 "变量是比率数据的例子,以零值为参考点。利用这类数据,我们可以进行多种数学运算。例如,我们可以将所有票价相加,然后除以乘客总数,得出平均值。我们还可以求出标准差。直方图(如图 4-7 所示)可用于直观显示这类连续数据,以了解其分布情况。

In the preceding plots, we looked at the graphs for plotting individual categorical or continuous variables. In the following section, we understand which graphs to use when we have more than one variable or a combination of variables belong to different scales or levels.

在前面的绘图中,我们了解了用于绘制单个分类变量或连续变量的图形。在下一节中,我们将了解当有多个变量或变量组合属于不同尺度或级别时,应该使用哪种图形。

绘制混合数据(Plotting mixed data)

In this section, we’ll consider three scenarios, each of which has two variables that may or may not belong to the same level and discuss which plot to use for each scenario (using the same Titanic dataset).

在本节中,我们将考虑三种情况,每种情况都有两个变量,这两个变量可能属于也可能不 属于同一级别,并讨论每种情况下应使用哪种曲线图(使用相同的泰坦尼克数据集)。

One categorical and one continuous variable: A box plot shows the distribution, symmetry, and outliers for a continuous variable. A box plot can also show the continuous variable against a categorical variable. In Figure 4-8, the distribution of ‘Age’ (a ratio variable) for each value of the nominal variable – ‘Survived’ (0 is the value for passengers who did not survive and 1 is the value for those who did).

一个分类变量和一个连续变量: 方框图显示连续变量的分布、对称性和异常值。方框图还可以显示连续变量与分类变量的对比情况。在图 4-8 中,“年龄”(比率变量)在名义变量 “存活”(0 代表未存活乘客的值,1 代表存活乘客的值)的每个值上的分布情况。

Both continuous variables: Scatter plots are used to depict the relationship between two continuous variables. In Figure 4-9, we plot two ratio variables, ‘Age’ and ‘Fare’, on the x and y axes to produce a scatter plot.

都是连续变量: 散点图用于描述两个连续变量之间的关系。在图 4-9 中,我们将两个比率变量 "年龄 "和 "票价 "分别绘制在 x 轴和 y 轴上,从而得到散点图。

Both categorical variables: Using a clustered bar chart (Figure 4-10), you can combine two categorical variables with the bars depicted side by side to represent every combination of values for the two variables.

两个分类变量: 使用聚类条形图(图 4-10),可以将两个分类变量结合在一起,并列的条形图代表了这两个变量的所有数值组合。

We can also use a stacked bar chart to plot two categorical variables. Consider the following stacked bar chart, shown in Figure 4-11, plotting two categorical variables –“Pclass” and “Survived”

我们还可以使用堆叠条形图来绘制两个分类变量。下面是图 4-11 所示的堆叠条形图,其中绘制了两个分类变量–"Pclass "和 “Survived”。

In summary, you can use a scatter plot for two continuous variables, a stacked or clustered bar chart for two categorical variables, and a box plot when you want to display a continuous variable across different values of a categorical variable.

总之,您可以对两个连续变量使用散点图,对两个分类变量使用堆叠条形图或聚类条形图,当您想在分类变量的不同值之间显示连续变量时使用盒状图。

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

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

【图解数据结构】顺序表实战指南:手把手教你详细实现(超详细解析)

🌈个人主页:聆风吟 🔥系列专栏:图解数据结构、算法模板 🔖少年有梦不应止于心动,更要付诸行动。 文章目录 一. ⛳️线性表1.1 🔔线性表的定义1.2 🔔线性表的存储结构 二. ⛳️顺序表…

解决Windows下Goland的Terminal设置为Git Bash失败

路径不要选错了: 如果还是不行: 把bash路径加进去试试 goland设置Terminal

在Qt中通过控制按钮实现登录界面密码与明码的转换

创建控件: 首先,在Qt设计师界面界面上创建QLineEdit类文本框,用于输入密码,并且实现密码与明码相互转化。 设置初始状态: 默认情况下,输入密码的文本框应该是可见的并允许用户输入。 添加切换按钮&…

MCM备赛笔记——PCA主成分分析法

Key Concept 主成分分析(PCA,Principal Component Analysis)是一种统计方法,它通过线性变换将多维数据变换到新的坐标系统中,使得这一数据的任何投影的第一大方差出现在第一个坐标(即第一个主成分&#xf…

H5嵌入小程序适配方案

时间过去了两个多月,2024已经到来,又老了一岁。头发也掉了好多。在这两个月时间里都忙着写页面,感觉时间过去得很快。没有以前那么轻松了。也不是遇到了什么难点技术,而是接手了一个很烂得项目。能有多烂,一个页面发起…

Linux之进程间通信(管道)

目录 一、进程间通信 1、进程间通信的概念 2、进程间通信的目的 3、进程间通信的分类 二、管道 1、管道基本介绍 2、匿名管道 3、命名管道 一、进程间通信 1、进程间通信的概念 什么是进程间通信? 我们在学习了进程的相关知识后,知道&#xff…

Vue记录

vue2、vue3记录 vue2记录 经典vue2结构 index.vue&#xff1a; <template><div>...</div> </template><script>import method from "xxx.js"import component from "xxx.vue"export default {name: "ComponentName&…

Vue3.0性能提升主要是通过哪几方面体现的?

文章目录 一、编译阶段diff算法优化静态提升事件监听缓存SSR优化 二、源码体积三、响应式系统参考文献 一、编译阶段 回顾Vue2&#xff0c;我们知道每个组件实例都对应一个 watcher 实例&#xff0c;它会在组件渲染的过程中把用到的数据property记录为依赖&#xff0c;当依赖发…

Cloudreve存储策略-通过从机存储来拓展容量

Sham的云服务器是搬瓦工最低低低配的&#xff0c;1H 0.5G不说&#xff0c;硬盘容量也只有10g&#xff0c;说实话&#xff0c;装了宝塔面板和服务器套件后&#xff0c;基本满了&#xff0c;这时又想在云服务器上打个网盘用于下载、存储&#xff0c;这时就需要拓展硬盘&#xff0…

Redis 面试题 | 01.精选Redis高频面试题

&#x1f90d; 前端开发工程师、技术日更博主、已过CET6 &#x1f368; 阿珊和她的猫_CSDN博客专家、23年度博客之星前端领域TOP1 &#x1f560; 牛客高级专题作者、打造专栏《前端面试必备》 、《2024面试高频手撕题》 &#x1f35a; 蓝桥云课签约作者、上架课程《Vue.js 和 E…

HCIA——22DNS:DNS层次域名空间、域名服务器、域名解析的原理

学习目标&#xff1a; 计算机网络 1.掌握计算机网络的基本概念、基本原理和基本方法。 2.掌握计算机网络的体系结构和典型网络协议&#xff0c;了解典型网络设备的组成和特点&#xff0c;理解典型网络设备的工作原理。 3.能够运用计算机网络的基本概念、基本原理和基本方法进行…

基于springboot+vue的母婴商城系统(前后端分离)

博主主页&#xff1a;猫头鹰源码 博主简介&#xff1a;Java领域优质创作者、CSDN博客专家、公司架构师、全网粉丝5万、专注Java技术领域和毕业设计项目实战 主要内容&#xff1a;毕业设计(Javaweb项目|小程序等)、简历模板、学习资料、面试题库、技术咨询 文末联系获取 项目背景…

第二课:BERT

文章目录 第二课&#xff1a;BERT1、学习总结&#xff1a;为什么要学习BERT&#xff1f;预训练模型的发展历程BERT结构BERT 输入BERT EmbeddingBERT 模型构建BERT self-attention 层BERT self-attention 输出层BERT feed-forward 层BERT 最后的Add&NormBERT EncoderBERT 输…

c++ mysql数据库编程(linux系统)

ubuntu下mysql数据库的安装 ubuntu安装mysql&#xff08;图文详解&#xff09;-CSDN博客https://blog.csdn.net/qq_58158950/article/details/135667062?spm1001.2014.3001.5501 项目目录结构 数据库及表结构 public.h //打印错误信息 #ifndef PUBLIC_h #define PUBLIC_H…

Centos使用Docker搭建自己的Gitlab(社区版和设置汉化、修改密码、设置SSH秘钥)

根据我的经验 部署Gitlab&#xff08;社区版&#xff09; 至少需要2核4g的服务器 带宽3~4M 1. 在自己电脑上安装终端&#xff1a;宝塔ssl终端 或者 FinalShell&#xff0c;根据喜好安装即可 http://www.hostbuf.com/t/988.html http://www.hostbuf.com/downloads/finalshell_w…

macOS磁盘管理工具Paragon Hard Disk Manager,轻松且安全的改变磁盘分区

Paragon Hard Disk Manager mac版是Macos上一款磁盘管理工具&#xff0c;可以帮助你轻松而且安全的随意改变磁盘分区的大小和各种分区参数&#xff0c;作为mac磁盘分区工具也是游刃有余&#xff0c;同时在找回数据的时候也非常容易&#xff0c;并且不会损坏原来的数据&#xff…

项目解决方案:多地医馆的高清视频监控接入汇聚联网

目 录 一、背景 二、建设目标及需求 1.建设目标 2.现状分析 3.需求分析 三、方案设计 1.设计依据 2.设计原则 3.方案设计 3.1 方案描述 3.2 组网说明 四、产品介绍 1.视频监控综合资源管理平台介绍 2.视频录像服务器和存储 2.1概述 2.2存储设计 …

【工具】使用ssh进行socket5代理

文章目录 shellssh命令详解正向代理&#xff1a;反向代理&#xff1a;本地 socks5 代理 shell ssh -D 3333 root192.168.0.11 #输入密码 #3333端口已经使用远程机进行转发设置Windows全局代理转发 socks127.0.0.1 3333如果远程机为公网ip&#xff0c;可通过搜索引擎查询出网…

软件资源管理下载系统全新带勋章功能 + Uniapp前端

测试环境&#xff1a;php7.1。ng1.2&#xff0c;MySQL 5.6 常见问题&#xff1a; 配置好登录后转圈圈&#xff0c;检查环境及伪静态以及后台创建好应用 上传图片不了&#xff0c;检查php拓展fileinfo 以及public文件权限 App个人主页随机背景图&#xff0c;在前端uitl文件…

【数学笔记】集合及简要逻辑

集合 基础简要逻辑集合间的关系与运算 基础 集合定义&#xff1a;把一些能够确定的不同对象组成的整体叫做一个集合&#xff0c;每个对象叫做元素。集合记法&#xff1a;一般用大写字母 A , B , C . . . . . . A,B,C...... A,B,C......表示集合&#xff0c;小写字母 a , b ,…
最新文章