KDE con kdeplot() —#
0:00 min | Última modificación: Octubre 13, 2021 | [YouTube]
[1]:
import matplotlib.pyplot as plt
import numpy as np
import seaborn as sns
[2]:
penguins = sns.load_dataset("penguins")
display(
penguins.head(),
penguins.tail(),
penguins.size,
)
species | island | bill_length_mm | bill_depth_mm | flipper_length_mm | body_mass_g | sex | |
---|---|---|---|---|---|---|---|
0 | Adelie | Torgersen | 39.1 | 18.7 | 181.0 | 3750.0 | Male |
1 | Adelie | Torgersen | 39.5 | 17.4 | 186.0 | 3800.0 | Female |
2 | Adelie | Torgersen | 40.3 | 18.0 | 195.0 | 3250.0 | Female |
3 | Adelie | Torgersen | NaN | NaN | NaN | NaN | NaN |
4 | Adelie | Torgersen | 36.7 | 19.3 | 193.0 | 3450.0 | Female |
species | island | bill_length_mm | bill_depth_mm | flipper_length_mm | body_mass_g | sex | |
---|---|---|---|---|---|---|---|
339 | Gentoo | Biscoe | NaN | NaN | NaN | NaN | NaN |
340 | Gentoo | Biscoe | 46.8 | 14.3 | 215.0 | 4850.0 | Female |
341 | Gentoo | Biscoe | 50.4 | 15.7 | 222.0 | 5750.0 | Male |
342 | Gentoo | Biscoe | 45.2 | 14.8 | 212.0 | 5200.0 | Female |
343 | Gentoo | Biscoe | 49.9 | 16.1 | 213.0 | 5400.0 | Male |
2408
[3]:
#
# Estimación no paramétrica básica usando
# kdeplot(). Note que aca se pasa directamente
# la columna con los datos.
#
sns.kdeplot(
penguins.flipper_length_mm,
color="blue",
shade=True,
)
plt.show()
[4]:
#
# kde acumulada usando kdeplot()
#
sns.kdeplot(
penguins.flipper_length_mm,
color="blue",
shade=True,
cumulative=True,
)
plt.show()