lmplot fails with lowess=True
See original GitHub issueDear Seaborn developpers,
I’m trying a simple lmplot that fails as follows:
In [22]: sns.lmplot(data=go, x="states", y="rate", lowess=True)
/home/franck/.local/lib/python3.5/site-packages/numpy/lib/function_base.py:4016: RuntimeWarning: Invalid value encountered in median
r = func(a, **kwargs)
/home/franck/.local/lib/python3.5/site-packages/statsmodels/nonparametric/smoothers_lowess.py:165: RuntimeWarning: invalid value encountered in greater_equal
res = _lowess(y, x, frac=frac, it=it, delta=delta)
Out[22]: <seaborn.axisgrid.FacetGrid at 0x7ff15d5b97f0>
The data is not something complicated or strange, here is the CSV:
go.csv.gz
As a result, I got the scatter plot but not the smoothed curve:
I have many other similar data sets that cause no problem, I’ve just isolated this particular one that fails. I’m working with Python 3.5.2, Seaborn 0.8.1, Numpy 1.13.3, and Statsmodel 0.8.0.
Any help will be very wellcome, thanks in advance! Franck
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Markers in seaborn lmplot - python - Stack Overflow
The markers argument in lmplot() requires a single entry for each level ... fit_reg=False, hue='z', lowess=True, scatter_kws={'alpha': 0.5}, ...
Read more >seaborn.lmplot — seaborn 0.12.1 documentation - PyData |
seaborn.lmplot# ... Plot data and regression model fits across a FacetGrid. This function combines regplot() and FacetGrid . It is intended as a...
Read more >Lab 9 — Stat 159/259 - Reproducible and Collaborative Data ...
The lmplot function will plot a scatter plot of the data and fit and visualize a linear model on top of it. Let's...
Read more >Linear regression diagnostics in Python - Jan Kirenz
Non-linearity of the response-predictor relationship; Non-constant variance of error terms (heteroscedasticity); Non-normally distributed errors ...
Read more >Linear models with quantitative data - | notebook.community
For instance, it is common to plot the *standard error* of an estimate, which corresponds to the 68% confidence interval. In [ ]:....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Yep, I think issue is what’s happening here. I can’t explain exactly what statsmodels is doing, but it makes sense. “lowess” stands for “locally weighted smoothing”. There is at least one segment in your dataset where for a reasonable definition of “local”, there is nothing to smooth.
I don’t think seaborn should do anything here. Raising would be annoying if you’re trying to draw a big facet grid where one or two subsets has a failing lowess. A warning would be good, but statsmodels is in the better position to give an informative warning about exactly what’s happening. All seaborn can do really is say that “something” has gone wrong, but that’s already obvious from the lack of a line on the plot.
But I don’t know how you call it… 😃 I’ve patched around the call
res = _lowess(y, x, frac=frac, it=it, delta=delta)
to observe parameters and return value. It yields:Can you confirm this is a bug in statsmodels?