Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use python's seaborn to plot CDF?

When I use the sns.kdeplot and let culmulative=True, the error is

Cumulative distributions are currentlyonly implemented in statsmodels.Please install statsmodels.

Even though I have already installed statsmodels.

like image 641
S.J. Zhang Avatar asked Jun 10 '16 11:06

S.J. Zhang


People also ask

How do you explain a CDF plot?

The Cumulative Distribution Function (CDF) plot is a lin-lin plot with data overlay and confidence limits. It shows the cumulative density of any data set over time (i.e., Probability vs. size).

How would you make a distribution plot using Seaborn?

How to Plot a Distribution Plot with Seaborn? Seaborn has different types of distribution plots that you might want to use. These plot types are: KDE Plots ( kdeplot() ), and Histogram Plots ( histplot() ). Both of these can be achieved through the generic displot() function, or through their respective functions.

What is Ecdf in Seaborn?

An ECDF represents the proportion or count of observations falling below each unique value in a dataset. Compared to a histogram or density plot, it has the advantage that each observation is visualized directly, meaning that there are no binning or smoothing parameters that need to be adjusted.


1 Answers

From the source code, we can see that all Seaborn does is attempt to import

try:
    import statsmodels.nonparametric.api as smnp
    _has_statsmodels = True
except ImportError:
    _has_statsmodels = False

at a module level, and should _has_statsmodels be False, the _univariate_kdeplot function attempts to fall back on SciPy, which does not support cumulative distributions for this purpose.

So there is nothing murky happening in Seaborn here, you simply have an ImportError from an installation or setup issue regarding statsmodels.

like image 111
miradulo Avatar answered Sep 30 '22 19:09

miradulo