CSV Regression
Fit a simple linear regression and get slope, intercept, R², and residuals.
About this tool
Pick an X column and a Y column from your CSV and fit a straight line by ordinary least squares. You get the slope, intercept, R-squared, the number of pairs used, and the predicted value and residual for every row.
How to use
How it works
Least squares chooses the line that minimises the sum of squared vertical distances to the points. Slope = covariance(x, y) / variance(x), and the intercept makes the line pass through the means. R-squared is the share of the variance in y that the line explains. Rows with a missing x or y are left out.
y = slope · x + intercept R² = 1 − SS_res / SS_tot
Worked example
A trend with one outlier
- Input
- x: 1..7 y: 2.1, 3.9, 6.2, 7.8, 10.1, 12.2, 30
- Output
- slope 3.7214, intercept -4.5571, R² 0.7414, n 7
- Walkthrough
- The last point (7, 30) has a residual of 8.51, the largest of all, and pulls the slope up. Without it the slope would be close to 2.
Limitations
- Simple linear regression with one predictor only.
- No confidence intervals, p-values or significance tests.
- Both columns must be numeric; otherwise there is an error.
Questions
How do I run a linear regression on a CSV?
What does R-squared mean?
Does it support multiple regression?
What are residuals?
Features
- Slope, intercept, R²
- Per-row residuals
- Runs in your browser
Related resources
Guides and videos from around the web—opens on YouTube or the publisher’s site.
What Is A RESTful API?
Traversy Media
APIs are how most data tools receive payloads.
Watch on YouTubeFinding mean, median, and mode
Khan Academy
Descriptive stats for quick data summaries.
Watch on YouTube
- Fetch API
MDN
How browsers pull remote data into local tools.
- Model for Tabular Data and Metadata on the Web
W3C
Tabular data model behind CSV-oriented workflows.