- Python 62.5%
- Nix 37.5%
| .gitignore | ||
| app.py | ||
| flake.lock | ||
| flake.nix | ||
| prog.py | ||
| README.md | ||
Linear Regression Visualization (Streamlit)
Running the app
This project uses a Nix flake to provide a reproducible Python environment.
From the project directory, run:
nix develop
streamlit run app.py
Streamlit will print a local URL (usually http://localhost:8501).
Open it in a browser to interact with the app.
Purpose of this app (data science context)
This app is a minimal illustration of linear regression, one of the foundational tools in data science and machine learning.
Mitchell’s framing of learning
Using Mitchell’s definition of learning:
A program learns from experience E with respect to tasks T and performance measure P, if its performance at T, as measured by P, improves with E.
This app fits that framing as follows:
- Task (T): Predict a numerical value (Calorie Burnage) from measured features (Average Pulse).
- Experience (E): A dataset of observed
(Average_Pulse, Calorie_Burnage)pairs. - Performance (P): Squared prediction error minimized by least-squares regression.
The program “learns” by estimating the parameters of a model from data so that prediction error is minimized.
What linear regression is doing
Linear regression fits a model of the form:
[ y = m x + b ]
where:
xis the input feature (Average Pulse),yis the output variable (Calorie Burnage),mandbare parameters learned from data.
The regression line is chosen to minimize the total squared vertical distance between the observed data points and the model’s predictions. This is the simplest example of a regression task in machine learning.
Why the visualization matters
The scatter plot shows the raw data (experience). The line shows the learned model.
The sliders control the visible x-range and are meant to build intuition about:
- Model domain: The regression model is only supported by data where observations exist.
- Extrapolation: Predictions outside the observed range are assumptions, not learned behavior.
- Geometric interpretation: Regression is fitting a geometric object (a line) to data points in a coordinate space.
Why this is foundational
Although simple, this example contains the core structure shared by more advanced data-science methods:
- defining a task,
- representing data numerically,
- choosing a model,
- fitting parameters from data,
- and evaluating performance.
More complex techniques (polynomial regression, PCA, image decomposition, neural networks) build directly on these same ideas, extended to higher dimensions and richer models.