自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

EDA中常用的九個可視化圖表介紹和代碼示例

大數(shù)據(jù) 數(shù)據(jù)分析
探索性數(shù)據(jù)分析(EDA)是數(shù)據(jù)科學(xué)家用來分析和調(diào)查數(shù)據(jù)集并總結(jié)其主要特征的一種方法,通常采用數(shù)據(jù)可視化技術(shù)。我們可以說EDA是通過創(chuàng)建可視化和摘要來調(diào)查和理解數(shù)據(jù)集的過程。

探索性數(shù)據(jù)分析(EDA)是數(shù)據(jù)科學(xué)家用來分析和調(diào)查數(shù)據(jù)集并總結(jié)其主要特征的一種方法,通常采用數(shù)據(jù)可視化技術(shù)。我們可以說EDA是通過創(chuàng)建可視化和摘要來調(diào)查和理解數(shù)據(jù)集的過程。EDA是我們詢問數(shù)據(jù)問題的一種方式,可以找出關(guān)于數(shù)據(jù)的所有信息,并理解它為什么是這樣的(即識別趨勢、模式、異常等)。

在這篇文章中我們介紹EDA中常用的9個圖表,并且針對每個圖表給出代碼示例。

1、條形圖/計數(shù)圖

顯示分類變量的分布??梢暬瘮?shù)據(jù)集中每個類別的頻率或計數(shù)。

import seaborn as sns
 import matplotlib.pyplot as plt
 
 
 data = sns.load_dataset('tips')
 sns.countplot(x='day', data=data)
 plt.title('Count of Tips by Day')
 plt.show()

2、箱線圖

顯示數(shù)據(jù)中的平均值、中位數(shù)、分位數(shù)和離群值。比較多個變量的分布。可以識別擴(kuò)散的數(shù)值變量,檢測數(shù)據(jù)集中潛在的異常值。

import seaborn as sns
 import matplotlib.pyplot as plt
 
 data = sns.load_dataset('tips')
 sns.boxplot(x='day', y='total_bill', data=data)
 plt.title('Box Plot of Total Bill by Day')
 plt.show()

3、密度圖

作為數(shù)據(jù)科學(xué)家,建議使用密度圖而不是直方圖,因?yàn)槲覀儾聹y最佳的裝箱數(shù)量是有問題的。

密度圖可以可視化連續(xù)變量的分布。識別數(shù)據(jù)中的峰值、低谷和總體模式。了解分布的形狀并比較多個變量的分布。

import seaborn as sns
 import matplotlib.pyplot as plt
 
 data = sns.load_dataset('tips')
 sns.kdeplot(data['total_bill'], shade=True)
 plt.title('Density Plot of Total Bill')
 plt.show()

4、散點(diǎn)圖

探索兩個連續(xù)變量之間的關(guān)系。識別數(shù)據(jù)中的模式、相關(guān)性或集群。

import seaborn as sns
 import matplotlib.pyplot as plt
 
 data = sns.load_dataset('tips')
 sns.scatterplot(x='total_bill', y='tip', data=data)
 plt.title('Scatter Plot of Total Bill vs. Tip')
 plt.show()

5、線型圖

在時間序列中顯示趨勢或模式。表示連續(xù)區(qū)間內(nèi)兩個連續(xù)變量之間的關(guān)系,還可以比較連續(xù)范圍內(nèi)變量的變化。

import seaborn as sns
 import matplotlib.pyplot as plt
 
 data = sns.load_dataset('tips')
 sns.lineplot(x='total_bill', y='tip', data=data)
 plt.title('Line Plot of Tip Over Total Bill')
 plt.show()

6、熱圖

顯示數(shù)值變量的相關(guān)矩陣。識別大型數(shù)據(jù)集中的模式和關(guān)系。

import seaborn as sns
 import matplotlib.pyplot as plt
 
 data = sns.load_dataset('tips')
 correlation_matrix = data.corr()
 sns.heatmap(correlation_matrix, annot=True, cmap='coolwarm')
 plt.title('Correlation Heatmap')
 plt.show()

7、小提琴圖

結(jié)合了箱形圖和核密度圖的特點(diǎn),可以可視化一個數(shù)值變量在不同類別中的分布。

import seaborn as sns
 import matplotlib.pyplot as plt
 
 data = sns.load_dataset('tips')
 sns.violinplot(x='day', y='total_bill', data=data)
 plt.title('Violin Plot of Total Bill by Day')
 plt.show()

8、子圖

為了進(jìn)行對比,可以在同一圖中并排比較多個子圖。

import seaborn as sns
 import matplotlib.pyplot as plt
 
 data = sns.load_dataset('tips')
 
 plt.figure(figsize=(12, 8))
 
 plt.subplot(2, 2, 1)
 sns.scatterplot(x='total_bill', y='tip', data=data)
 plt.title('Scatter Plot of Total Bill vs Tip')
 
 plt.subplot(2, 2, 2)
 sns.boxplot(x='day', y='total_bill', data=data)
 plt.title('Box Plot of Total Bill by Day')
 
 plt.subplot(2, 2, 3)
 sns.barplot(x='day', y='total_bill', data=data)
 plt.title('Bar Plot of Total Bill by Day')
 
 plt.subplot(2, 2, 4)
 sns.histplot(data['total_bill'], kde=True)
 plt.title('Histogram of Total Bill')
 
 plt.tight_layout()
 plt.show()

9、關(guān)系圖

Pairplot在中文中沒有特定的翻譯,我這里把它稱作關(guān)系圖,因?yàn)樗怯糜诶L制變量之間的關(guān)系,通過對多個變量進(jìn)行可視化來探索它們之間的相關(guān)性和趨勢。

import seaborn as sns
 import matplotlib.pyplot as plt
 
 data = sns.load_dataset('tips')
 
 sns.pairplot(data, hue='day')
 plt.suptitle('Pairplot of Numerical Variables by Day', y=1.02)
 plt.show()

總結(jié)

以上就是在EDA中常用的圖表,可以看到seaborn是可以非常好用的工具,它基于matplotlib但是更加美觀,并且需要編寫的代碼更少,所以在EDA需要簡單的出圖的時候可以優(yōu)先使用它。

責(zé)任編輯:彭凡 來源: DeepHub IMBA
相關(guān)推薦

2023-10-24 20:38:15

數(shù)據(jù)分析機(jī)器學(xué)習(xí)

2020-07-13 14:35:25

可視化數(shù)據(jù)編程

2022-05-30 08:37:34

可視化圖表項(xiàng)目開源

2015-08-20 10:04:40

可視化

2024-05-22 16:03:49

2020-03-01 14:01:22

Echarts數(shù)據(jù)可視化圖表

2022-11-28 15:04:42

數(shù)據(jù)可視化工具

2023-06-11 16:12:14

數(shù)據(jù)可視化圖表類型

2023-08-01 16:01:59

可視化Seaborn

2017-01-10 15:14:34

大數(shù)據(jù)數(shù)據(jù)可視化圖表類型

2021-04-09 10:42:03

數(shù)據(jù)可視化框架大數(shù)據(jù)

2019-06-23 15:44:24

Matplotlib可視化圖表

2022-08-23 12:32:37

Python可視化圖表

2017-05-23 09:07:48

可視化圖表視覺

2023-05-18 07:48:01

.NET網(wǎng)絡(luò)編程

2021-10-11 08:04:22

Python數(shù)據(jù)行程

2019-12-18 14:40:09

數(shù)據(jù)可視化后端技術(shù)Python

2022-07-13 15:54:14

Matplotlib圖表

2019-05-28 11:52:43

可視化圖表數(shù)據(jù)

2018-09-26 16:15:31

數(shù)據(jù)可視化大數(shù)據(jù)數(shù)據(jù)分析
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號