You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I assume the OP meant precisely what statsmodels' lowess does. But if I understand correctly, statsmodels combines fit and predict methods into one, and so doesn't allow to predict on new data. Is @agramfort package considered for an eventual addition to scikit-learn? If not, it seems like a rather unfortunate omission.
would you restrict the method to data with only one feature?
I could see such a non-parametric regression method in a generalized
additive model (GAM) module based on backfitting.
Thoughts?
I thought about the case with one feature, but only because it's so much more common and because in the multi-variate case I'm afraid performance would be a much bigger problem.
The statsmodel version of lowess doesn't have any higher functions, like estimating the error variance of the model. As far as I can tell, such functionality doesn't exist anywhere in the python universe yet. I'm currently using rpy2 to access the R version of loess.
@luisvalesilva what's the problem with using the gist or statsmodels? This seems to be used mostly for 1d and so doesn't really fit into scikit-learn? I'm not really familiar though.
I mean in principal you could do that with nd data, too.. @agramfort what is this usually used for?
@amueller in my particular case, I need x values in the output different from the observed x values. I am not an expert, though, so there might be other ways. And I do see the point that this doesn't fit scikit-learn too well.
@amueller I didn't provide enough information, I'm sorry. What I want to do is this: given a data set with some observed x and y values, generate a close reproduction of the data for new x values in the same range as the original x values. Here's some R code generating a simplified example of the problem.
Let's say I have the following data.
# Observed x values
x <- round(seq(1, 78, 1) * (100/78), 1)
x
@amueller They can be used for multivariate data. As is discussed here, the difference appears to be in the particular implementation, where "lowess" have been implementations for 1D predictor case and "loess" for the multivariate case.
PS: My apologies for joining the party late, but I figured I'd post since the issue had not been closed
EDIT: Here is another useful discussion of the lowess vs loess implementation in R.
I'm currently using R's loess through rpy2, just like @naught101. Would love to see it get added to scikit-learn.
Same here, though skmisc's loess might fit better in statsmodels.
The current skmisc loess implementation is 1d. It's used for similar applications as scikit-learn's kernel estiamators in 1d.
@amueller If sklearn would be interested, I can look into helping get skmisc.loess fixed up for submission to sklearn. If you aren't interested, let us know and we can ask statsmodels
would you restrict the method to data with only one feature? I could see such a non-parametric regression method in a generalized additive model (GAM) module based on backfitting. Thoughts?
It is my understanding that local regression is not supported directly in scikit-learn at the moment. However, one can combine some existing modules from scikit-learn, numpy and scipy to build a custom regressor in scikit-learn, which can then be used with the same interface as the LinearRegression model. That is a bit of work, but not completely out of reach. I did that a while back and put a prototype with some unit tests and a notebook that explains the mathematical background a bit in my repository here:
Is this what you guys are looking for? It does work with multivariate input data and supports local polynomial regression of any degree.
@amueller If so, would there still be any interest in this? I'd be more than happy to give back to the community and submit this as a proper scikit-learn model via a pull request.
The missing features are penalties on B-Spline differences as requested in #20760, or full GAMs #3482.
I also have concerns about runtime and memory requirements of kernel regression.
Activity
agramfort commentedon Apr 20, 2014
you have my gist https://gist.github.com/agramfort/850437
and
http://statsmodels.sourceforge.net/devel/generated/statsmodels.nonparametric.smoothers_lowess.lowess.html
is that what you had in mind?
pkch commentedon Mar 27, 2016
I assume the OP meant precisely what statsmodels' lowess does. But if I understand correctly, statsmodels combines
fitandpredictmethods into one, and so doesn't allow to predict on new data. Is @agramfort package considered for an eventual addition to scikit-learn? If not, it seems like a rather unfortunate omission.agramfort commentedon Mar 27, 2016
pkch commentedon Mar 27, 2016
I thought about the case with one feature, but only because it's so much more common and because in the multi-variate case I'm afraid performance would be a much bigger problem.
naught101 commentedon Aug 31, 2016
The statsmodel version of lowess doesn't have any higher functions, like estimating the error variance of the model. As far as I can tell, such functionality doesn't exist anywhere in the python universe yet. I'm currently using rpy2 to access the R version of loess.
naught101 commentedon Aug 31, 2016
and there is a question related to my comment on stackoverflow: https://stackoverflow.com/questions/31104565/confidence-interval-for-lowess-in-python
luisvalesilva commentedon Oct 13, 2016
I'm currently using R's loess through rpy2, just like @naught101. Would love to see it get added to scikit-learn.
amueller commentedon Oct 13, 2016
@luisvalesilva what's the problem with using the gist or statsmodels? This seems to be used mostly for 1d and so doesn't really fit into scikit-learn? I'm not really familiar though.
I mean in principal you could do that with nd data, too.. @agramfort what is this usually used for?
luisvalesilva commentedon Oct 14, 2016
@amueller in my particular case, I need x values in the output different from the observed x values. I am not an expert, though, so there might be other ways. And I do see the point that this doesn't fit scikit-learn too well.
amueller commentedon Oct 14, 2016
@luisvalesilva sorry I didn't understand your comment.
luisvalesilva commentedon Oct 16, 2016
@amueller I didn't provide enough information, I'm sorry. What I want to do is this: given a data set with some observed x and y values, generate a close reproduction of the data for new x values in the same range as the original x values. Here's some R code generating a simplified example of the problem.
Let's say I have the following data.
[1] 1.3 2.6 3.8 5.1 6.4 7.7 9.0 10.3 11.5 12.8 14.1
[12] 15.4 16.7 17.9 19.2 20.5 21.8 23.1 24.4 25.6 26.9 28.2
[23] 29.5 30.8 32.1 33.3 34.6 35.9 37.2 38.5 39.7 41.0 42.3
[34] 43.6 44.9 46.2 47.4 48.7 50.0 51.3 52.6 53.8 55.1 56.4
[45] 57.7 59.0 60.3 61.5 62.8 64.1 65.4 66.7 67.9 69.2 70.5
[56] 71.8 73.1 74.4 75.6 76.9 78.2 79.5 80.8 82.1 83.3 84.6
[67] 85.9 87.2 88.5 89.7 91.0 92.3 93.6 94.9 96.2 97.4 98.7
[78] 100.0
I need to get y values for the sequence of integers between 1 and 100. These will be my new x values.
[1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
[18] 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
[35] 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
[52] 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
[69] 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
[86] 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
In my real application, I do something like this for 1000s of similar cases and then calculate the mean value of y for each x value.
This may be a little out of place here, sorry about that! But I would be very interested in alternative ways to do this.
ashimb9 commentedon Oct 27, 2017
@amueller They can be used for multivariate data. As is discussed here, the difference appears to be in the particular implementation, where "lowess" have been implementations for 1D predictor case and "loess" for the multivariate case.
PS: My apologies for joining the party late, but I figured I'd post since the issue had not been closed
EDIT: Here is another useful discussion of the lowess vs loess implementation in R.
histed commentedon Jan 14, 2020
Same here, though skmisc's loess might fit better in statsmodels.
The current skmisc loess implementation is 1d. It's used for similar applications as scikit-learn's kernel estiamators in 1d.
@amueller If sklearn would be interested, I can look into helping get skmisc.loess fixed up for submission to sklearn. If you aren't interested, let us know and we can ask statsmodels
naught101 commentedon Jan 15, 2020
Cross-referencing: #3482
niknow commentedon Feb 7, 2021
It is my understanding that local regression is not supported directly in scikit-learn at the moment. However, one can combine some existing modules from scikit-learn, numpy and scipy to build a custom regressor in scikit-learn, which can then be used with the same interface as the LinearRegression model. That is a bit of work, but not completely out of reach. I did that a while back and put a prototype with some unit tests and a notebook that explains the mathematical background a bit in my repository here:
https://github.com/niknow/machine-learning-examples/tree/master/local_regression
Is this what you guys are looking for? It does work with multivariate input data and supports local polynomial regression of any degree.
@amueller If so, would there still be any interest in this? I'd be more than happy to give back to the community and submit this as a proper scikit-learn model via a pull request.
amueller commentedon Apr 6, 2021
I think it would be great to have, but one issue is always finding reviewers. Not sure if @naught101 is still interested and/or @agramfort ?
naught101 commentedon Apr 6, 2021
@amueller I don't think I am very qualified to give a review of the stats implementation, unfortunately. I'm happy to do some testing though.
amueller commentedon Apr 6, 2021
Also maybe @thomasjpfan who looked into GAMs? Though this sounds closer to MARS?
agramfort commentedon Apr 7, 2021
I am not an expert on this matter but I have a look to an implementation.
lorentzenchr commentedon Feb 28, 2026
I would say we have
The missing features are penalties on B-Spline differences as requested in #20760, or full GAMs #3482.
I also have concerns about runtime and memory requirements of kernel regression.
Therefore, I close.
On top, there are
KernelRidge