This repository contains code for a Machine Learning web app that predicts the number of medals a country is expected to achieve in the Olympics based on the number of athletes and previous medals won.
The Olympic Medal Prediction Web Application is built using Python and Flask framework. It uses a linear regression model trained on historical data to predict the number of medals a country is expected to win in the Olympics.
The application loads data from a CSV file called teams.csv
, which should contain information about different teams participating in the Olympics, including the team name, country, year, number of athletes, average age, previous medals won, and total medals won. The application pre-processes the data by selecting relevant columns and removing any rows with missing values.
A linear regression model is then trained using the selected predictors: the number of athletes and previous medals won. The trained model is saved to a file called olympic.pkl
using pickle, a Python serialization library.
The web application utilizes the Flask framework to serve the predictive model. It provides a simple user interface where users can enter the number of athletes and previous medals of a country to obtain the predicted number of medals that country is expected to achieve. The prediction is performed by loading the trained model from the olympic.pkl
file and making predictions using the provided features.
To run the Olympic Medal Prediction Web Application locally, follow these steps:
- Clone this repository to your local machine or download the code as a ZIP file.
- Ensure you have Python 3 installed on your system.
- Install the required dependencies by running the following command in your terminal:
pip install -r req.txt
- Make sure you have completed the installation steps.
- Place your data file named
teams.csv
in the same directory as the code files. - Run the following command in your terminal to start the web application:
python app.py
- Open a web browser and navigate to
http://localhost:5000
to access the web application. - Enter the number of athletes and previous medals for a country in the provided input fields.
- Click the "Predict" button to see the predicted number of medals for that country.
- The prediction will be displayed on the same page.