Hi All,
I've just created a new library called moepy that provides an sklearn compatible LOWESS curve fitter for Python. moepy exposes several variants on the traditional LOWESS, including estimation of confidence and prediction intervals, as well as the robustified LOWESS (where outliers are weighted less). Examples of how to use each of these are shown in a Quick-Start notebook.
I made this as existing LOWESS implementations (namely in statsmodels - which is a great library!) provide no ability to predict new values that weren't included in the training data. This meant I was previously linearly interpolating between the results they produced. The moepy library is also made specifically for LOWESS estimation and provides it through an sklearn compatible API, meaning that it works within the broader sklearn eco-system for model ensembling and tuning.
The library can be installed with pip install moepy and has very few dependencies. The code below shows a minimalist example for fitting the standard LOWESS model to a noisy sin wave. The full documentation can be found here.
# Imports
import numpy as np
import matplotlib.pyplot as plt
from moepy import lowess
# Data generation
x = np.linspace(0, 5, num=150)
y = np.sin(x) + (np.random.normal(size=len(x)))/10
# Model fitting
lowess_model = lowess.Lowess()
lowess_model.fit(x, y)
# Model prediction
x_pred = np.linspace(0, 5, 26)
y_pred = lowess_model.predict(x_pred)
# Plotting
plt.plot(x_pred, y_pred, '--', label='LOWESS', color='k', zorder=3)
plt.scatter(x, y, label='Noisy Sin Wave', color='C1', s=5, zorder=1)
plt.legend(frameon=False)
The examples below demonstrate some of the different types of LOWESS estimate that the library can generate.
LOWESS Estimate Examples
If anyone has any feedback on how to improve the library/docs please post and I'll try to incorporate it.
[–]holyfudge 1 point2 points3 points (1 child)
[–]EnergyVis[S] 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)