Implement comprehensive overfitting simulation for high-dimensional linear models#12
Draft
Implement comprehensive overfitting simulation for high-dimensional linear models#12
Conversation
…thon, Julia, and R Co-authored-by: gsaco <[email protected]>
Co-authored-by: gsaco <[email protected]>
Copilot
AI
changed the title
[WIP] Simulate a data generating process like in Lab2 with only 2 variables X and Y, for
n
=
1000
. For practical purposes, make the intercept parameter of your data generating process be equal to zero. You are asked to do the following in a loop:
Estimate...
Implement comprehensive overfitting simulation for high-dimensional linear models
Sep 5, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR implements a complete educational simulation demonstrating the overfitting phenomenon in high-dimensional linear models across three programming languages: Python, Julia, and R.
Overview
The simulation addresses the classic bias-variance tradeoff by fitting polynomial regression models with increasing complexity to a nonlinear data generating process. It clearly demonstrates how model performance on training data can be misleading when evaluating generalization capability.
Data Generating Process
The simulation uses the specified nonlinear relationship:
Key Features
Multi-Language Implementation
simulation_python.ipynb: Complete Python implementation using scikit-learnsimulation_julia.ipynb: Native Julia implementation with efficient linear algebrasimulation_r.ipynb: R implementation using base R and ggplot2simulation.ipynb: Main simulation file (Python version)Comprehensive Analysis
Each notebook tests polynomial regression with 1, 2, 5, 10, 20, 50, 100, 200, 500, 1000 features and calculates:
Educational Visualizations
Three separate plots in each language show:
Example Results
The simulation consistently shows the expected overfitting pattern:
Supporting Infrastructure
requirements.txt: Python dependencies for easy setuptest_simulation.py: Basic validation of the implementationcomprehensive_test.py: Detailed analysis with overfitting metricscreate_plots.py: Standalone visualization generator.gitignore: Proper version control excluding generated filesEducational Value
This implementation provides a hands-on demonstration of fundamental concepts:
The simulation serves as an excellent teaching tool for courses in machine learning, econometrics, and high-dimensional statistics, providing concrete evidence of theoretical concepts through reproducible code examples.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.