Logo

Vectorized Linear Regression Demo

AIO2025: Module 05.

๐Ÿ“Š
About this Vectorized Linear Regression Demo
This interactive demo showcases Linear Regression implemented from scratch using numpy and gradient descent. Learn how linear regression works with pure matrix operations (vectorization) and visualize the training process step by step.

๐Ÿ“Š How to Use: Select data โ†’ Configure target โ†’ Set training parameters โ†’ Enter new point โ†’ Run prediction!

Start with sample datasets or upload your own CSV/Excel files.

๐Ÿ—‚๏ธ Sample Datasets
๐ŸŽฏ Target Column

๐Ÿ”„ Loading sample data...

๐Ÿ“‹ Data Preview (First 5 Rows)

๐Ÿ“Š Linear Regression Parameters

0 6

Current Learning Rate: 0.01

0 10

Current Batch Size: Full Batch

๐Ÿ“Š Data Split Configuration

0.6 0.9

๐Ÿ“Š Linear Regression Results & Visualization

**๐Ÿ“Š Linear Regression Results**

Training details will appear here showing the learned parameters and prediction.

๐Ÿ“Š Linear Regression Tips:

  • ๐Ÿ“‰ Training Loss: Monitor how the Mean Squared Error (MSE) on training data decreases over epochs.
  • ๐Ÿ“Š Validation Loss: Track validation loss to detect overfitting - if it increases while training loss decreases, the model is overfitting.
  • โšก Performance Comparison: The demo runs both simple (Python loops) and vectorized (NumPy) implementations to show the speedup from vectorization!
  • ๐Ÿ”ข Normalization: Both implementations use automatic normalization (standardization) for better convergence and numerical stability.
  • ๐Ÿ“ฆ Batch Size: Use the slider to select batch size (powers of 2). The slider adjusts dynamically based on your training data size!
    • 0 = 1 sample, 1 = 2 samples, 2 = 4 samples, 3 = 8 samples, etc.
    • Max value = Full Batch (all training samples)
    • Smaller batches = more frequent updates but noisier. Larger batches = more stable but slower convergence.
  • ๐ŸŽฏ Epochs: More epochs allow the model to learn better, but watch for overfitting on the validation chart.
  • โš™๏ธ Learning Rate: Use the slider to select learning rate (powers of 10).
    • 0 = 1e-6, 1 = 1e-5, 2 = 1e-4, 3 = 1e-3, 4 = 1e-2, 5 = 1e-1, 6 = 1
    • Too high (>0.1) may cause instability/overflow, too low (<0.0001) may be slow.
  • โš ๏ธ Overflow Warning: If Simple Linear Regression shows "Overflow", the learning rate is too high. The vectorized version has better numerical stability!
  • ๐Ÿ”ง Vectorization: The vectorized version uses pure numpy matrix operations for efficient computation - typically 10-100ร— faster!
  • โœจ Try it: Slide the batch size to see different gradient descent variants, adjust learning rates (0.001 - 0.01) and epochs (50 - 500)!