/rain-prediction

A web application has been developed using Flask and Machine Learning models, specifically a logistic regression model, to predict the likelihood of rain with high accuracy.

Primary LanguageHTML

ML-Model-Flask-Deployment

This is a demo project to elaborate how Machine Learn Models are deployed on production using Flask API

Prerequisites

You must have Scikit Learn, Pandas (for Machine Leraning Model) and Flask (for API) installed.

Project Structure

This project has four major parts :

  1. model.py - This contains code fot our Machine Learning model to predict rain probabilty based on training data in 'rain.csv' file.
  2. app.py - This contains Flask APIs that receives tempreture details, computes the precited value based on our model and returns it.
  3. request.py - This uses requests module to call APIs already defined in app.py and dispalys the returned value.
  4. templates - This folder contains the HTML template to allow user to enter values and displays the predicted chance of rain.

Running the project

  1. Ensure that you are in the project home directory. Create the machine learning model by running below command -
python model.py

This would create a serialized version of our model into a file model.pkl

  1. Run app.py using below command to start Flask API
python app.py

By default, flask will run on port 5000.

  1. Navigate to URL http://localhost:5000

You should be able to view the homepage as below : Screen Shot 2023-06-13 at 7 20 08 PM

Enter valid numerical values in all 3 input boxes and hit 'Is it going to rain?'.

If everything goes well, you should be able to see the predicted probability of rain on the HTML page! Screen Shot 2023-06-13 at 7 21 50 PM

  1. You can also send direct POST requests to FLask API using Python's inbuilt request module Run the below command to send the request with some pre-popuated values -
python request.py