{ "cells": [ { "cell_type": "markdown", "id": "f33e5de7", "metadata": {}, "source": [ "# Bias-Variance Tradeoff Interactive Demo\n", "\n", "This notebook demonstrates the fundamental **bias-variance tradeoff** in machine learning through interactive visualizations.\n", "\n", "## Key Concepts:\n", "\n", "### π― Bias\n", "- Error from overly simplistic assumptions\n", "- High bias β **Underfitting**\n", "- Model misses relevant patterns in the data\n", "\n", "### π Variance\n", "- Error from sensitivity to training data fluctuations\n", "- High variance β **Overfitting**\n", "- Model learns noise instead of signal\n", "\n", "### βοΈ The Tradeoff\n", "- **Total Error = BiasΒ² + Variance + Irreducible Error**\n", "- As model complexity increases:\n", " - Bias decreases β\n", " - Variance increases β\n", "- Goal: Find the sweet spot!\n", "\n", "## Visualizations:\n", "\n", "1. **Fitting Comparison**: See underfitting vs optimal vs overfitting\n", "2. **Prediction Spread**: Visualize how predictions vary across different training sets\n", "3. **Bullseye Diagrams**: Intuitive representation of bias (offset) and variance (spread)" ] }, { "cell_type": "code", "execution_count": 1, "id": "b9c6cdbe", "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "c:\\Users\\rinab\\miniforge3\\envs\\WORK\\lib\\site-packages\\tqdm\\auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n", " from .autonotebook import tqdm as notebook_tqdm\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "* Running on local URL: http://127.0.0.1:7860\n", "* Running on public URL: https://3bab683affa1571f93.gradio.live\n", "\n", "This share link expires in 1 week. For free permanent hosting and GPU upgrades, run `gradio deploy` from the terminal in the working directory to deploy to Hugging Face Spaces (https://huggingface.co/spaces)\n" ] }, { "data": { "text/html": [ "
" ], "text/plain": [ "