- breadcrumb.home
- breadcrumb.lab
- Linear Regression
Linear Regression Demo
Train a linear regression model on housing data and make predictions. This demo shows how machine learning models can predict house prices based on features like area, bedrooms, age, location, and crime rate.
Step 1: Training Data
View and edit the training data. Each row represents a house with features (area, bedrooms, age, location, crime rate) and its actual price. You can add, edit, or delete rows. If no data is provided, the system will generate synthetic data.
No training data yet. Click "Train with Default Data" to generate synthetic data, or "Add Row" to create custom data.
⚠️ Train the model first
Please complete Step 1 to train the model before making predictions.
Step 2: Make Predictions
Enter house features below to predict the price using the trained model.
About Linear Regression
Linear regression is a fundamental machine learning algorithm that models the relationship between a dependent variable (house price) and one or more independent variables (features).
Model Equation
y = β₀ + β₁x₁ + β₂x₂ + ⋯ + βᵣxᵣ + ε
Cost Function (Mean Squared Error)
J(θ) = ½∑i(hθ(x(i)) - y(i))²
= ½∑i(θᵀx(i) - y(i))²
How It Works
- Training Phase: The algorithm finds the optimal parameters θthat minimize the cost function J(θ) using gradient descent or the normal equation.
- Prediction Phase: Once trained, predictions are made using the model equation: ŷ = θᵀx (where ŷ is the predicted value).
- This Demo: Uses scikit-learn's LinearRegression, which employs the normal equation (closed-form solution) to find the optimal coefficients that minimize the mean squared error.
Academic Papers and Resources
- "The Method of Least Squares" by Carl Friedrich Gauss (1809) - The original formulation of least squares regression
- "The Theory of Least Squares When the Parameters are Subject to Linear Restrictions" by A. C. Aitken (1935) - Extension of least squares theory
- "The Use of Multiple Measurements in Taxonomic Problems" by R. A. Fisher (1936) - Early application of linear discriminant analysis
- "The Elements of Statistical Learning" by Hastie, Tibshirani, and Friedman (2009) - Comprehensive textbook covering linear regression and extensions
- "An Introduction to Statistical Learning" by James, Witten, Hastie, and Tibshirani (2021) - Accessible introduction to statistical learning methods
- "Pattern Recognition and Machine Learning" by Christopher Bishop (2006) - Chapter 3 covers linear regression in detail
- scikit-learn Linear Models Documentation - Official documentation for sklearn's linear regression implementation
- Linear Regression (Wikipedia) - Comprehensive overview of linear regression theory and applications
- Machine Learning Course by Andrew Ng (Coursera) - Week 1-2 cover linear regression with gradient descent