Run the Calculator
Paste a numeric dataset below. By default, the tool assumes the last column is the target variable. You can also name the target column or provide its numeric position.
Example Data Table
This sample dataset is already loaded into the textarea above.
| TV | Online | Sales | |
|---|---|---|---|
| 12 | 4 | 9 | 41 |
| 14 | 5 | 8 | 45 |
| 15 | 6 | 8 | 47 |
| 17 | 7 | 7 | 50 |
| 18 | 8 | 7 | 53 |
| 20 | 9 | 6 | 57 |
| 22 | 10 | 6 | 61 |
| 24 | 11 | 5 | 64 |
| 25 | 12 | 5 | 66 |
| 27 | 13 | 4 | 70 |
| 29 | 14 | 4 | 74 |
| 31 | 15 | 3 | 77 |
Formula Used
Lasso regression minimizes the penalized loss:
1 / (2n) × Σ(yᵢ − ŷᵢ)² + λ × Σ|βⱼ|
The prediction equation is:
ŷ = β₀ + β₁x₁ + β₂x₂ + ... + βₚxₚ
The absolute-value penalty λ × Σ|βⱼ| shrinks weak coefficients.
As lambda increases, some coefficients become exactly zero, which performs feature selection and reduces model complexity.
This page uses coordinate descent with soft-thresholding:
S(z, λ) = sign(z) × max(|z| − λ, 0)
Key diagnostic formulas:
MSE = Σ(actual − predicted)² / n,
RMSE = √MSE,
MAE = Σ|actual − predicted| / n,
and
R² = 1 − SSE / SST.
How to Use This Calculator
- Paste your dataset into the textarea. Keep each column numeric.
- Set the delimiter that matches your data source.
- Choose whether the first row contains headers.
- Leave the target blank to use the last column, or name it explicitly.
- Start with a small lambda such as
0.10to0.50. - Increase lambda to remove weaker variables and simplify the model.
- Review R², RMSE, sparsity, and the coefficient table after fitting.
- Use the CSV or PDF buttons to save the model summary and prediction report.
Frequently Asked Questions
1) What does lambda control in Lasso regression?
Lambda controls the strength of the penalty applied to coefficients. A larger lambda shrinks more coefficients toward zero, simplifying the model and reducing overfitting risk.
2) Why do some coefficients become exactly zero?
Lasso uses an absolute-value penalty. That penalty can force weak predictors to zero, which means the model keeps only stronger variables and performs built-in feature selection.
3) Should predictors be standardized?
Usually yes. Standardization makes variables comparable, especially when they use different units or ranges. Without it, larger-scale predictors can dominate the penalty unfairly.
4) How is Lasso different from ordinary least squares?
Ordinary least squares minimizes only prediction error. Lasso adds a penalty on coefficient size, which shrinks estimates and can remove less useful predictors entirely.
5) Can this tool handle multiple predictors?
Yes. Include as many numeric predictor columns as needed, plus one numeric target column. The tool will estimate all coefficients together and report which ones survive shrinkage.
6) What metrics should I review first?
Start with R², RMSE, MAE, selected features, and sparsity percentage. Then inspect coefficients and residuals to decide whether the chosen lambda gives a useful balance.
7) Why does a very large lambda reduce model accuracy?
When lambda is too large, important variables may be over-shrunk or removed. That can create an overly simple model, which often increases prediction error.
8) What kind of data should I paste here?
Use clean numeric data arranged in rows and columns. Avoid missing values, text labels inside numeric rows, merged cells, or extra symbols that break parsing.