Inferensys

Glossary

Locally Weighted Regression

A non-parametric regression method that fits a simple model to a localized subset of data, weighting points by their proximity to the target instance, forming the statistical backbone of the LIME algorithm.
Data scientist building training data pipeline on laptop, data preprocessing visible, technical workspace.
NON-PARAMETRIC LOCAL FITTING

What is Locally Weighted Regression?

Locally weighted regression is a non-parametric statistical method that fits a simple model to a localized subset of data, weighting points by their proximity to a target instance, forming the statistical backbone of the LIME algorithm.

Locally weighted regression is a memory-based, non-parametric algorithm that makes predictions by fitting a low-degree polynomial to a subset of training data localized around the query point. Unlike global regression, which estimates a single function for the entire dataset, this method performs a separate weighted fit for each prediction, assigning higher importance to data points closer to the target instance via a kernel function. This approach allows the model to adapt flexibly to complex, non-linear structures without assuming a rigid global parametric form.

The weighting is governed by a bandwidth hyperparameter that controls the size of the local neighborhood, directly managing the bias-variance trade-off. A narrow bandwidth captures fine local detail but risks high variance, while a wide bandwidth produces a smoother, more biased fit. In the LIME framework, locally weighted regression serves as the interpretable surrogate model, approximating the black-box decision boundary in the immediate vicinity of the instance being explained to generate human-understandable feature importance scores.

NON-PARAMETRIC ESTIMATION

Key Characteristics of Locally Weighted Regression

Locally Weighted Regression (LWR) is a memory-based, non-parametric algorithm that fits a simple model to a localized subset of data, weighting points by their proximity to the query instance. It forms the statistical backbone of the LIME explanation framework.

01

Memory-Based Learning

LWR is a lazy learner that performs no explicit training phase. Instead, it stores the entire training dataset and defers all computation until a query is made. When a prediction is required for a specific point, the algorithm dynamically retrieves the relevant local neighborhood from memory, fits a simple model, and discards it. This contrasts with eager learners like neural networks that compress data into fixed parameters during training. The memory-based approach allows LWR to adapt its hypothesis complexity to the query point without retraining.

02

Distance-Based Weighting Kernel

The core mechanism of LWR is a weighting function that assigns importance to each training point based on its distance from the query instance. The standard choice is the tricube kernel:

  • Points exactly at the query location receive full weight (1.0)
  • Points beyond a bandwidth parameter h receive zero weight
  • The weight decays smoothly in between, creating a soft boundary This ensures that the local model is dominated by the most proximate data, enforcing the locality constraint critical to LIME's fidelity.
03

Bandwidth Parameter Control

The bandwidth or smoothing parameter h controls the size of the local neighborhood and fundamentally governs the bias-variance trade-off:

  • Small bandwidth: High variance, low bias. The model fits very local patterns but is sensitive to noise. Captures fine detail at the risk of overfitting.
  • Large bandwidth: Low variance, high bias. The model smooths over more data, approaching a global linear regression. More stable but may miss local structure. Optimal bandwidth selection is typically performed via cross-validation or analytical methods like the Akaike Information Criterion (AIC).
04

Local Polynomial Fitting

Within the weighted neighborhood, LWR fits a low-degree polynomial—typically linear or quadratic—using weighted least squares. The objective function minimizes: Σ w(x_i, x_query) * (y_i - β₀ - β₁x_i - ...)² A degree-0 fit produces a locally constant estimate (kernel smoothing). A degree-1 fit (local linear regression) corrects boundary bias and is the most common choice. The prediction for the query point is simply the fitted polynomial evaluated at the query location. Higher-degree polynomials capture more curvature but increase variance.

05

Non-Parametric Flexibility

LWR makes no assumptions about the global functional form of the underlying data-generating process. Unlike parametric models that impose a fixed structure (e.g., linear, exponential), LWR adapts to arbitrary nonlinear relationships by stitching together local approximations. This flexibility is the reason LIME uses LWR as its surrogate: a sparse linear model fitted with local weights can approximate any complex decision boundary in a small region. The trade-off is that LWR requires the full dataset at inference time and scales linearly with data size.

06

Connection to LIME Surrogate Training

In the LIME algorithm, LWR is the engine that trains the interpretable surrogate model. The process maps directly to LWR mechanics:

  • Perturbation samples become the training data points
  • Cosine or Euclidean distance from the original instance determines weights via an exponential kernel
  • A sparse linear model (Lasso) is fitted using these weighted samples
  • The resulting coefficients become the feature importance scores in the explanation The kernel width in LIME directly corresponds to LWR's bandwidth, controlling how 'local' the explanation remains.
LOCALLY WEIGHTED REGRESSION

Frequently Asked Questions

Clear, technical answers to common questions about the non-parametric regression method that underpins local interpretable model explanations.

Locally Weighted Regression (LWR) is a non-parametric, memory-based regression algorithm that fits a simple model to a localized subset of the training data, weighting each point by its proximity to the query instance. Unlike global regression, which fits a single function to the entire dataset, LWR performs a new, local optimization for every prediction. The process involves three steps: first, a distance metric (typically Euclidean) identifies the nearest neighbors to the target point. Second, a kernel function assigns weights to these neighbors, giving higher influence to points closer to the query. Third, a simple model—often a linear or polynomial regression—is fitted to the weighted data. The prediction is then made by evaluating this local model at the query point. This approach allows LWR to flexibly model complex, non-linear relationships without requiring a pre-specified global functional form, making it the statistical backbone of the LIME algorithm for model interpretability.

Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.