当前位置:网站首页>Machine learning Seaborn visualization

Machine learning Seaborn visualization

2022-07-05 07:14:00 RS&Hydrology

Main records seaborn Visual learning notes ( Understand which functions to draw images are available ).


One 、seaborn principle

 Example :pandas Is based on NumPy A tool of , The tool is created to solve data analysis tasks .
picture source :https://www.bilibili.com/video/BV1VX4y1F76x/

  • boxenplot: Suitable for big data
  • Distribution diagram of numerical variables in different categories :stripplot;swarmplot;violinplot
  • FaceGrid,PairGrid You can customize the drawing function

see seaborn edition :sns.__version__
Version update :pip install —upgrade seaborn

Two 、 Variable distribution

1.sns.boxplot(): View the value range of numeric variables

sns.boxplot(): View the value range of numeric variables , Whether there are outliers .

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns

print(sns.__version__)  
# print(sns.get_dataset_names())

df = pd.read_excel('D:/1.xlsx')

sns.boxplot(data=df,x="Height")
plt.show()

 Insert picture description here

2.sns.displot(): View the distribution of variables

  • sns.displot(kind = hist) # Draw histogram
    Histogram :sns.histplot(bins,hue,shrink)
    bins: change bin numbers
    hue: Category variable
    shrink: Zoom factor
  • sns.displot(kind = kde) # Plotting kernel density estimates (kernel density estimate (KDE)), It is a method to visualize the distribution of observations in data sets , Similar to histogram .KDE Use a continuous probability density curve of one or more dimensions to represent data .
  • sns.displot(kind = ecdf) # Represents the proportion or count of observations below each unique value in the dataset . Compare with histogram or density diagram , Its advantage is that each observation is directly visualized , This means that there is no need to adjust the box dividing or smoothing parameters .
penguins = sns.load_dataset("penguins")
sns.ecdfplot(data=penguins, x="flipper_length_mm")

 Insert picture description here

  • sns.countplot(data=df,x=“class”) Number of Statistics

3.sns.jointplot(): Plot the joint distribution and respective distribution of two variables

sns.jointplot(dataset,x,y,kind)

sns.jointplot() Function upgrade :
JoinGrid, Can pass g.plot() Custom function .g = sns.JoinGrid(); g.plot(sns.histplot,sns.boxplot)

4.sns.pairplot(): Plot the joint distribution of all numerical variables in pairs

sns.pairplot() Function upgrade :
PairGrid, Can pass g.map() Custom drawing function

Reference material

https://www.bilibili.com/video/BV1VX4y1F76x/

https://blog.csdn.net/qq_45176548/article/details/117305614?utm_medium=distribute.pc_relevant.none-task-blog-2defaultbaidujs_title~default-1.queryctrv2&spm=1001.2101.3001.4242.2&utm_relevant_index=4

原网站

版权声明
本文为[RS&Hydrology]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202140559171816.html