Question about usage
Closed this issue · 1 comments
Thanks for this package -- I am trying it out as a replacement for LOWESS, and it seems promising.
I've written this function as a wrapper to work with a pandas Series:
from whittaker_eilers import WhittakerSmoother
def make_whittaker_eilers(series):
"""Compute a smooth line.
series: pd.Series
returns: pd.Series
"""
y = series.values
x = series.index.values
whittaker_smoother = WhittakerSmoother(
lmbda=1e4, order=3, data_length=len(y), x_input=x
)
smooth = whittaker_smoother.smooth(y)
return pd.Series(smooth, index=x)
One of the datasets I'm working with has unevenly spaced points, so I'm providing the x
values as x_input
.
But now I would like to evaluate the smooth function at equally spaced points -- I was expecting a parameter like x_output
to indicate where the function should be evaluated, but it looks like it doesn't exist.
Is there another way to do this?
Hi there, thanks for giving the package a go!
Yes, you can absolutely do this you'll just need to use weights. Start by inserting the x
values you want to evaluate at into your x_input
, then insert dummy values of 0 into your y
series for them, and finally set the weight of each of the dummy measurements to 0 (leaving actual measurements with a weight of 1). When you run the smoothing on y
, it will evaluate it at the filled in x_input
.
I understand that it can be quite a pain to do this for some datasets! I may in the future introduce some sort of wrapper function to add functionality like you've suggested to match how these packages usually work in SciPy etc.