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.
Glossary
Locally Weighted Regression

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.
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.
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.
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.
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
hreceive 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.
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).
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.
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.
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.
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.
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Related Terms
Locally Weighted Regression (LWR) forms the statistical backbone of the LIME algorithm. These related concepts define how the local surrogate model is built, weighted, and evaluated.
Exponential Kernel
A distance-based weighting function that assigns higher importance to perturbed samples closer to the original instance. The kernel defines the effective neighborhood size by controlling how quickly sample weights decay with distance.
- Enforces the locality constraint of the explanation
- Typically uses a radial basis function (RBF) kernel
- Weight calculation:
exp(-distance^2 / kernel_width^2) - Samples far from the target instance receive near-zero weight
Kernel Width
A hyperparameter controlling the effective size of the local neighborhood. It determines how quickly sample weights decay with distance from the original instance, directly balancing local fidelity against explanation stability.
- Too narrow: overfits to noise, unstable explanations
- Too wide: loses locality, approximates global behavior
- Optimal selection is critical for meaningful explanations
- OptiLIME automates this selection process
Perturbation Sampling
The process of generating a synthetic neighborhood of data points by randomly altering or masking features of the original instance. This creates the training set for the local surrogate model.
- Text data: token masking or removal
- Image data: superpixel masking (turning segments on/off)
- Tabular data: value perturbation around the instance
- Each perturbed sample receives a proximity weight from the kernel
Sparse Linear Model
An interpretable surrogate model that uses Lasso (L1) regularization to select only a small number of the most important features. This ensures the final explanation remains concise for human consumption.
- L1 penalty forces irrelevant coefficients to exactly zero
- Produces a linear combination of weighted features
- Balances fidelity-interpretability trade-off
- The non-zero coefficients become the explanation
Local Fidelity
A measure of how accurately the interpretable surrogate model approximates the behavior of the underlying black-box model in the immediate neighborhood of the instance being explained.
- Measured via weighted squared error on perturbed samples
- High fidelity: surrogate closely matches black-box locally
- Low fidelity: explanation may be misleading or incomplete
- The fidelity-interpretability trade-off governs surrogate complexity
Neighborhood Generation
The specific strategy for creating perturbed data points, which varies by data modality. Each domain requires a tailored approach to produce meaningful, realistic variations around the target instance.
- Text: token masking or word removal from documents
- Images: superpixel masking (contiguous region occlusion)
- Tabular: sampling from feature distributions or quantiles
- Feature discretization often precedes neighborhood generation

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.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us