Lowess
Lowess
¶
Bases: Loess
Smooth the data using Locally Weighted Scatterplot Smoothing (LOWESS).
LOWESS is a non-parametric regression method that combines multiple regression models in a k-nearest-neighbor-based meta-model. It is particularly useful for fitting a smooth curve to data that may exhibit non-linear relationships. The robustness weights are used to reduce the influence of outliers in the data. They are calculated based on the residuals from the previous iteration of the smoothing process.
| PARAMETER | DESCRIPTION |
|---|---|
source
|
Pandas long format DataFrame containing the data source for the plot.
TYPE:
|
target
|
Column name of the target variable for the plot.
TYPE:
|
feature
|
Column name of the feature variable for the plot, by default ''
TYPE:
|
Examples:
import numpy as np
import daspi as dsp
import pandas as pd
import matplotlib.pyplot as plt
x = 5*np.random.random(100)
data = pd.DataFrame(dict(
x = x,
y = np.sin(x) * 3*np.exp(-x) + np.random.normal(0, 0.2, 100)))
model = dsp.Lowess(data, 'y', 'x')
sequence, prediction, lower, upper = model.fitted_line(0.95)
fig, ax = plt.subplots()
ax.scatter(data.x, data.y)
ax.plot(sequence, prediction)
ax.fill_between(sequence, lower, upper, alpha=0.2)
robustness_kernel
instance-attribute
¶
The kernel function used to assign weights for adjusting the LOESS fitted values, providing robustness against outliers.