This project builds a predictive linear regression model to forecast the number of Olympic medals a country's team will win based on team characteristics and historical performance. The model analyzes historical Olympic data spanning from 1964 to 2016 and uses features like team size, athlete experience, and past medal performance to make predictions on future Olympic Games.
Olympic Games are one of the world's most prestigious sporting events. Predicting medal performance is valuable for:
- Sports organizations planning resource allocation
- Athletes and coaches setting realistic goals
- Analysts understanding factors that influence Olympic success
This project addresses the question: "What features best predict Olympic medal count?"
The project uses a comprehensive dataset (teams.csv) containing 2,144 records of Olympic team participation across multiple Olympic Games. Each record represents a country's team in a specific Olympic year.
| Feature | Description |
|---|---|
| team | Country/Team code (3-letter ISO code) |
| country | Full country name |
| year | Olympic Games year |
| events | Number of events the team participated in |
| athletes | Number of athletes on the team |
| age | Average age of athletes |
| height | Average height of athletes |
| weight | Average weight of athletes |
| medals | Number of medals won (TARGET VARIABLE) |
| prev_medals | Medals won in previous Olympics |
| prev_3_medals | Average medals from previous 3 Olympics |
- Time Range: 1964-2016 Olympic Games
- Total Records: 2,144 team entries
- Training Set: 1,609 records (before 2012)
- Test Set: 405 records (2012 and 2016)
- Missing Data: 130 rows with null values in
prev_medalsfield (teams competing in their first Olympics)
The analysis begins with examining correlations between features and medal performance:
- prev_medals: 0.92 correlation with medals (Strong predictor - past performance predicts future success)
- athletes: 0.84 correlation with medals (More athletes → more medal opportunities)
- age: 0.03 correlation with medals (Weak relationship)
- year: -0.02 correlation with medals (Olympic year has minimal impact)
Key Finding: Historical medal performance (prev_medals) is the strongest predictor, followed by team size (athletes).
- Train/Test Split: 80/20 split using year threshold (pre-2012 for training, 2012+ for testing)
- Feature Selection: Selected
athletesandprev_medalsas predictors based on correlation analysis - Missing Data Handling: Rows with missing
prev_medalswere identified but analyzed
Implemented a Linear Regression model using scikit-learn:
from sklearn.linear_model import LinearRegression
predictors = ["athletes", "prev_medals"]
target = "medals"
reg = LinearRegression()
reg.fit(train[predictors], train[target])The model was evaluated using R² score (coefficient of determination) on both training and test datasets to measure predictive accuracy.
The linear regression model successfully predicts Olympic medal counts with strong correlations between input features and outputs. The model demonstrates:
- High predictive power from historical medal data (
prev_medals) - Significant impact of team size (
athletes) on medal performance - Data-driven validation through 80/20 train/test split
- Past Performance is Key: Countries that won medals in previous Olympics are most likely to win medals again
- Team Size Matters: Larger teams have more opportunities to win medals
- Demographics are Secondary: Athlete age, height, and weight have minimal impact on medal performance
- Year-Independent: The Olympic year itself doesn't significantly affect medal outcomes
- Language: Python 3
- Libraries:
- pandas: Data loading, manipulation, and analysis
- NumPy: Numerical computing
- scikit-learn: Machine learning (Linear Regression)
- Seaborn: Statistical data visualization
- Matplotlib: Visualization (via Seaborn)
- Notebook: Jupyter Notebook (
main.ipynb)
Olympic-medals-Linear-regression/
├── README.md # Project documentation (this file)
├── main.ipynb # Main Jupyter notebook with full analysis
├── teams.csv # Olympic teams dataset (2,144 records)
└── .venv/ # Python virtual environment
-
Clone the repository
git clone <repository-url> cd Olympic-medals-Linear-regression
-
Create and activate virtual environment
python -m venv .venv .venv\Scripts\activate # On Windows source .venv/bin/activate # On Unix/Mac
-
Install dependencies
pip install pandas numpy scikit-learn seaborn matplotlib
-
Run the Jupyter notebook
jupyter notebook main.ipynb
-
Execute cells sequentially to load data, perform EDA, train the model, and view results
This project was developed following best practices from:
The tutorial provided foundational knowledge on:
- Building linear regression models
- Feature correlation analysis
- Train/test data splitting
- Model evaluation techniques
- Feature Engineering: Create polynomial features or interaction terms
- Advanced Models: Experiment with Ridge/Lasso regression or Gradient Boosting
- Hyperparameter Tuning: Optimize model parameters
- Cross-Validation: Implement k-fold cross-validation for robust evaluation
- Additional Features: Incorporate socioeconomic indicators (GDP, population) or performance trends
This project was created as part of machine learning portfolio development.