Locally weighted logistic regression
ML System Design practice on Codemia
Design recommenders, ranking systems and training pipelines the way ML interviews actually ask for them, with worked solutions.
Introduction
Logistic regression is a widely used statistical technique for binary classification problems. Unlike ordinary least squares regression, logistic regression predicts the probability that a given input point belongs to a particular class. This is achieved through a logistic function, which maps predicted output probabilities between 0 and 1.
Locally weighted logistic regression (LWLR), also known as locally weighted scatterplot smoothing (LOWESS) for classification, is a type of non-parametric approach that enhances the prediction capability of standard logistic regression by applying weights to the data points based on their distance from the target point. This ensures that points closer to the prediction point have more influence than those further away, allowing better handling of non-linear decision boundaries.
Technical Explanation
Logistic Regression Formulation
In logistic regression, the relationship between the dependent binary variable and the independent variables is modeled using the logistic function:
Where: • is the probability that the output variable is one (given the vector of inputs ). • are the parameters.
The goal is to determine the optimal values that maximize the likelihood of the observed data.
Locally Weighted Logistic Regression (LWLR)
LWLR adapts the logistic regression by incorporating a weight function. Unlike global logistic regression that assumes uniform influence of all data points, LWLR assigns weights to each data point, which diminish with distance from the target data point:
- Weight Function: The weight for a training sample is given by: Where is the bandwidth parameter determining how quickly the influence of data points decreases with distance.
- Cost Function: The locally weighted cost function is:
- Optimization: LWLR optimizes the above objective by considering weights, typically using iterative techniques like gradient descent or sophisticated methods like Newton-Raphson.
Example
Consider a binary classification problem where the dataset contains non-linear relationships. Standard logistic regression might struggle here, as it imposes a linear decision boundary. LWLR can effectively model complex decision boundaries because it effectively "focuses" on a local neighborhood of data points while making the prediction.
• Medical Diagnosis: LWLR can enhance medical imaging through precise cancer cell classification, especially when dealing with non-linear features. • Finance: Predicting stock market trends where non-linear relationships are common between various financial indicators. • Anomaly Detection: Identifying rare events in manufacturing by adjusting the sensitivity to local conditions.
Related reading
- Log accuracy metric while training a tf.estimator
- Log likelihood to implement Naive Bayes for Text Classification
- log loss output is greater than 1
- Log transform dependent variable for regression tree
- Logging requests being served by tensorflow serving model
- Logging training and validation loss in tensorboard
- Logical AND/OR in Keras Backend
- Logistic Regression How to find top three feature that have highest weights?
.png&w=3840&q=75)
Tackling System Design Interview Problems
A short course that equips you with the skills to approach system design interviews methodically.
Start the free courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
ML System Design practice on Codemia
Design recommenders, ranking systems and training pipelines the way ML interviews actually ask for them, with worked solutions.