Skip to content

dheetya/Linear-Regression-Plots

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ… Olympic Team Medals Predictor

This project explores a dataset of Olympic team statistics and builds a linear regression model to predict the number of medals a country will win based on features like number of athletes and prior medals.

It also evaluates the model using mean absolute error and analyzes prediction errors by country.


πŸ“‚ Dataset

The project uses a CSV file:

which contains the following columns:

  • team: Name of the team/country
  • country: Country code
  • year: Olympic year
  • athletes: Number of athletes entered
  • age: Average age of athletes
  • prev_medals: Number of medals won in previous Olympics
  • medals: Number of medals won in the current year

βš™οΈ What the Code Does

  1. Data Exploration

    • Computes correlations between features and medals
    • Visualizes relationships with regression plots (commented out β€” for Jupyter)
  2. Data Cleaning

    • Removes rows with missing values
    • Splits data into training and test sets (pre-2012 for training, 2012 and later for testing)
  3. Model Training

    • Trains a Linear Regression model on:
      • athletes
      • prev_medals
    • Predicts number of medals for test set countries
  4. Postprocessing

    • Ensures no negative predictions (clipped at 0)
    • Rounds predictions to nearest whole number
  5. Evaluation

    • Computes Mean Absolute Error (MAE) on test data
    • Analyzes errors by country
    • Plots a histogram of error ratio across countries

πŸ“Š Key Outputs

  • MAE of the model
  • Per-country prediction errors
  • Per-country error ratio (error divided by average medals won)
  • Histogram of error ratio across countries

πŸ› οΈ Requirements

  • Python 3.x
  • pandas
  • numpy
  • scikit-learn
  • seaborn
  • matplotlib

You can install them with: pip install pandas numpy scikit-learn seaborn matplotlib

Created by dheetya

About

No description or website provided.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages