泰坦尼克号 数据分析

My goal was to get a better understanding of how to work with tabular data so I challenged myself and started with the Titanic -project. I think this was an excellent way to learn the basics of data analysis with python.

我的目标是更好地了解如何使用表格数据,因此我挑战自我并开始了Titanic项目。 我认为这是学习python数据分析基础知识的绝佳方法。

You can find the competition here: https://www.kaggle.com/c/titanicI really recommend you to try it yourself if you want to learn how to analyze the data and build machine learning models.

您可以在这里找到比赛: https : //www.kaggle.com/c/titanic如果您想学习如何分析数据和建立机器学习模型,我真的建议您自己尝试一下。

I started by uploading the packages:

我首先上传了软件包:

import pandas as pd import numpy as npimport matplotlib.pyplot as pltimport seaborn as sns

Pandas is a great package for tabular data analysis. Numpy provides a high-performance multidimensional array object and tools for working with these arrays. Matplotlib packages help you to generate plots, histograms, power spectra, bar charts, etc., with just a few lines of code. Seaborn is developed based on the Matplotlib library and it can be used to create attractive and informative statistical graphics.

Pandas是用于表格数据分析的出色软件包。 Numpy提供了高性能的多维数组对象和用于处理这些数组的工具。 Matplotlib软件包可帮助您仅用几行代码即可生成图,直方图,功率谱,条形图等。 Seaborn是基于Matplotlib库开发的,可用于创建引人入胜且内容丰富的统计图形。

After loading these packages I loaded the data:

加载这些软件包后,我加载了数据:

df=pd.read_csv("train.csv")

Then I had a quick look at the data:

然后,我快速浏览了一下数据:

df.head()#This prints you the first 5 rows of the table#If you want to print 10 rows of the table instead of 5, then usedf.head(10)
Screenshot of the first rows
第一行的屏幕截图
df.tail()# This prints you out the last five rows of the table

I recommend starting with a look at the data so that you can be sure everything is as it should be. This is how you can avoid stupid mistakes in further analysis.

我建议先查看数据,以确保所有内容都应该是正确的。 这样可以避免进一步分析中的愚蠢错误。

df.shape#This prints you the number of rows and columns

It is a good habit to print out the shape of the data in the beginning so you can check the number of columns and rows and be sure you haven’t missed any data during the analysis.

在开始时打印出数据的形状是个好习惯,因此您可以检查列数和行数,并确保在分析过程中没有遗漏任何数据。

分析数据 (Analyze the data)

Then I continued to look at the data by counting the values. This gave me a lot of information about the content of the data.

然后,我继续通过计算值来查看数据。 这给了我很多有关数据内容的信息。

df['Pclass'].value_counts()# Prints out count of classes values
The number of persons in each class. 3rd class was the most popular.
每个班级的人数。 第三类是最受欢迎的。

I prefer using percentages to showcase values. It is easier to understand the values in percentages.

我更喜欢使用百分比来展示价值。 更容易理解百分比值。

df['Pclass'].value_counts(normalize=True)# same as above just that using "normalize=True" value is printed in percentages
55% of people were in 3rd class
55%的人在三等舱

I counted values for each column separately. In the future, I challenge myself to do the function which prints out values but it was not my scope in this project.

我分别计算每列的值。 将来,我会挑战自己执行输出值的功能,但这不是我在本项目中的工作范围。

I wanted to understand also the values of different columns so I used the describe() method for that.

我还想了解不同列的值,因此我使用了describe()方法。

df['Fare'].describe()# describe() is used to view basic statistical details like count, mean, minimum and maximum values.
“Fare” column values
“票价”列值

Here you can see for example that the minimum price for the ticket was 0,00 $ and the maximum price was 512,33 $.

例如,在这里您可以看到门票的最低价格为0,00 $,最高价格为512,33 $。

I did several crosstables to understand which were the determinant values for the surviving.

我做了几个交叉表,以了解哪些是生存的决定性价值。

pd.crosstab(df['Survived'], df['Sex'])# crosstable number of sex based on surviving.
Here I also recommend using percentages instead of numerical values
在这里,我还建议使用百分比而不是数值
pd.crosstab(df['Survived'], df['Sex'], normalize=True)# Using "normalize=True", you get values in percentage.
Same as above just in percentages
与上面相同,只是百分比

Doing crosstables with different values gives you information about the possible correlations between the variables, for example, sex and surviving. As you can see, 26% of women survived and most of the men, 52%, didn’t survive.

使用不同的值进行交叉表可为您提供有关变量之间可能的相关性的信息,例如性别和存活率。 如您所见,有26%的女性幸存下来,而大多数男性(52%)没有幸存。

可视化数据 (Visualize the data)

It is nice to have numerical values in tables but it is easier to understand the visualized data, at least for me. This is why I plotted histograms and bar charts. By creating histograms and bar charts I learned how to visualize the data. Here are a few examples:

在表格中有数值很高兴,但至少对于我来说,更容易理解可视化数据。 这就是为什么我绘制直方图和条形图的原因。 通过创建直方图和条形图,我学习了如何可视化数据。 这里有一些例子:

df.hist(column='Age')
In this histogram, you can see that passengers were mostly 20–40 years old.
在此直方图中,您可以看到乘客的年龄大多为20-40岁。

I used seaborn library for the bar charts.

我使用seaborn库制作条形图。

sns.countplot(x='Sex', hue='Survived', data=df);
More females survived than males.
存活下来的女性多于男性。

Also, I used a heatmap to see the correlation between different columns.

另外,我使用热图来查看不同列之间的相关性。

corrmat = df.corr()f, ax = plt.subplots(figsize=(12, 9))sns.heatmap(corrmat, vmax=.8, annot=True, square=True, annot_kws={'size': 15});

Heatmap shows that there is a strong negative correlation between Fares and Classes, so that when one increases other decreases. It is logical because ticket prices in the 1st class are higher than in the 3rd class.

热图显示,票价和舱位之间有很强的负相关性,因此当票价增加时,其他票价会下降。 这是合乎逻辑的,因为第一类的机票价格高于第三类的机票价格。

If we focus on analyzing the correlations between surviving and other values, we see that there is a strong positive correlation between surviving and fare. The probability to survive is higher when the ticket price has been higher.

如果我们专注于分析幸存值与其他值之间的相关性,我们会发现幸存率和票价之间存在很强的正相关性。 当门票价格较高时,生存的可能性较高。

You can find the project in Github. please feel free to try it yourself and comment if there is something that needs clarifying!

您可以在Github中找到该项目。 请随时尝试一下,如果有需要澄清的地方,请发表评论!

Thank you for the highly trained monkey (Risto Hinno) for motivating and inspiring me!

感谢您训练有素的猴子( Risto Hinno )激励和启发我!

翻译自: https://medium.com/swlh/part-1-titanic-basic-of-data-analysis-ab3025d29f6e

泰坦尼克号 数据分析


http://www.taodudu.cc/news/show-994853.html

相关文章:

  • vba数组dim_NDArray — —一个基于Java的N-Dim数组工具包
  • python算法和数据结构_Python中的数据结构和算法
  • python dash_Dash是Databricks Spark后端的理想基于Python的前端
  • 在Python中查找子字符串索引的5种方法
  • 趣味数据故事_坏数据的好故事
  • python分句_Python循环中的分句,继续和其他子句
  • python数据建模数据集_Python中的数据集
  • usgs地震记录如何下载_用大叶草绘制USGS地震数据
  • 数据可视化 信息可视化_更好的数据可视化的8个技巧
  • sql 左联接 全联接_通过了解自我联接将您SQL技能提升到一个新的水平
  • 科学价值 社交关系 大数据_服务的价值:数据科学和用户体验研究美好生活
  • vs azure web_在Azure中迁移和自动化Chrome Web爬网程序的指南。
  • selenium 解析网页_用Selenium进行网页搜刮
  • hive 导入hdfs数据_将数据加载或导入运行在基于HDFS的数据湖之上的Hive表中的另一种方法。
  • 大数据业务学习笔记_学习业务成为一名出色的数据科学家
  • python 开发api_使用FastAPI和Python快速开发高性能API
  • Power BI:M与DAX以及度量与计算列
  • 梯度下降法优化目标函数_如何通过3个简单的步骤区分梯度下降目标函数
  • seaborn 子图_Seaborn FacetGrid:进一步完善子图
  • 异常检测时间序列_时间序列的无监督异常检测
  • 存款惊人_如何使您的图快速美丽惊人
  • 网络传播动力学_通过简单的规则传播动力
  • 开源软件 安全风险_3开源安全风险及其解决方法
  • 自助分析_为什么自助服务分析真的不是一回事
  • 错误录入 算法_如何使用验证错误率确定算法输出之间的关系
  • pytorch回归_PyTorch:用岭回归检查泰坦尼克号下沉
  • iris数据集 测试集_IRIS数据集的探索性数据分析
  • flink 检查点_Flink检查点和恢复
  • python初学者_初学者使用Python的完整介绍
  • snowflake 数据库_Snowflake数据分析教程

泰坦尼克号 数据分析_第1部分:泰坦尼克号-数据分析基础相关推荐

  1. 学习excel数据分析_为什么Excel是学习数据分析的最佳方法

    学习excel数据分析 它是视觉的,它是透明的,并且使事情变得简单. (It's visual, it's transparent, and it keeps things simple.) The ...

  2. 利用python进行数据分析_资料 | 利用Python进行数据分析

    下载地址:https://www.yanxishe.com/resourceDetail/1443?from=leiphonecolumn_res0518 以下内容节选自豆瓣: 内容简介 · · · ...

  3. python怎么做数据分析_如何用python进行数据分析

    1.Python数据分析流程及学习路径 数据分析的流程概括起来主要是:读写.处理计算.分析建模和可视化四个部分.在不同的步骤中会用到不同的Python工具.每一步的主题也包含众多内容. 根据每个部分需 ...

  4. 用python进行股票数据分析_利用python进行股票数据分析

    个人觉得这问题问的不太对,说句不好的话,你是来搞编程的还是做股票的. 当然,如果题主只是用来搜集资料,看数据的话那还是可以操作一波的,至于python要怎么入门,个人下面会推荐一些入门级的书籍,通过这 ...

  5. Python_数据分析_关联规则和王者荣耀数据分析实战

    如果同学不喜欢看理论,可以直接看后面王者数据分析的部分. 关联规则 如果不知道尿布和啤酒问题,建议百度百科,先有个大致的了解 我们找百度百科上面的例子来讲一下 tid是交易单号,后面每一纵列中1代表购 ...

  6. python股票数据分析_用Python进行股票数据分析

    本篇运用Python进行自选股的数据分析,帮助进行投资决策,分析用到以下两个模块:pandas(数据分析包):pandas_datareader(可以查询雅虎的股票数据接口). 本篇参考了猴子老师的课 ...

  7. 四大会计师事务所python数据分析_用Python玩转数据分析4

    MOOC上的课程<用Python玩转数据分析>的学习笔记. 序列序列中的每一个元素都有它的一个索引,N长的序列中元素的索引从[0]到[N-1]或者从[-1]到[-N]. 字符串,用''表示 ...

  8. 四大会计师事务所python数据分析_如何用Python进行数据分析

    利用手中一份虚拟的朝阳医院销售数据,为大家浅析一下用Python进行数据分析的过程.数据分析过程 一.理解数据 首先导入excel文件 #导入excel文件 fileNameStr="朝阳医 ...

  9. python进行气象数据分析_使用机器学习进行气象数据分析

    1. 首先我们需要找到数据,很多地方提供了api,比如: https://www.wunderground.com/weather/api(但是这个网站不提供空气质量) 2. 从api获取数据,使用p ...

  10. 用python进行股票数据分析_用 Python 做股市数据分析(2)

    这篇博文是用Python分析股市数据系列两部中的第二部,内容基于我在阅读第一部分).在这两篇博文中,我会讨论一些基础知识,包括比如如何用pandas从雅虎财经获得数据, 可视化股市数据,平均数指标的定 ...

最新文章

  1. jsonView谷歌插件
  2. Mybatis之批量更新操作
  3. java 学习 --------接口概念
  4. autocad2014 第二次打开闪退_cad2014闪退的原因和解决方法
  5. springboot 日志数据
  6. arcgis 属性表 汇总_Arcgis中遥感影像地理配准、矢量化与地图制作
  7. Ural_1030. Titanic
  8. Oracle的AES加密与解密用法
  9. elasticsearch5.0.0中索引和文档接口的变化
  10. python 哈希表_数据结构-7 哈希表
  11. 随想录(单片机和步进电机学习笔记)
  12. 使用HttpSessionListener接口监听Session的创建和失效
  13. 文章目录:使用VisualStudio 2010从分析到实施系列【共5+3篇】
  14. nui UI 具有右键属性的菜单树
  15. 如何入行Android开发
  16. MybatisPlusExcepection: can not find lambda cache for this property [XX] for entity [xxx]
  17. 【软件推荐】电脑控制手机软件Scrcpy
  18. android 电脑 共享文件夹,安卓手机如何访问电脑局域网共享的文件
  19. “佩奇”刷爆朋友圈 “野猪”占领美术馆空间
  20. 计算机科技手抄报内容,科技手抄报内容-科技在我身边

热门文章

  1. 【ubuntu】vim语法高亮设置无效
  2. 证明AVL树的上界和下界
  3. 【Verilog HDL】第三章 reg和net及其一组类型的区别——充分运用实验思维
  4. Gdb 调试core文件详解
  5. 阿里大神最佳总结Flutter进阶学习笔记,技术详细介绍
  6. 音乐计算机融合课,融合信息技术的音乐课
  7. 2019.04.09 电商25 结算功能1
  8. myelcipse和maven搭建项目
  9. 看libevent所遇到的英语生词
  10. html中视频播放完后可以跳到另一个html