Skip to content

Project for Predicting Algerian Forest Fires and Fire Weather Index Using Machine Learning with Python.

Notifications You must be signed in to change notification settings

aravind-selvam/forest-fire-prediction

Repository files navigation

forthebadge made-with-python


Logo

Forest Fire Predictor

Machine Learning Project
Explore the Repo »

View Flask app code · Model Building · EDA on Forest Fires dataset

About The Project

  • Using Data Science and Machine learning, we can build a model that takes in the detected fires dataset learns and detects future fires based on certain Weather report.
  • Storing the Sourced dataset to MongoDB.
  • Building a Flask App hosted on Heroku.
  • Sklearn for pre-processing and Model Building
  • Pandas, Numpy, Matplotlib for csv reading, Data Processing, Data Cleaning, Visualization etc.

Deployed app

Screenshot (10)

LINK TO HEROKU APP

Introduction

  • I used a dataset on Algerian Forest Fires from UCI. The dataset contains a culmination of forest fire observations and data in two regions of Algeria: the Bejaia region and the Sidi Bel-Abbes region.
  • The timeline of this dataset is from June 2012 to September 2012. In this project, we focused on whether certain weather features could predict forest fires in these regions using few Machine Learning algorithms.

Steps

  • Installing Python, PyCharm, Monogodb, Git to Computer.
  • Creating Flask app by importing Flask module.
  • Download the source dataset from UCI Repository.
  • For Classification algorithm decided to predict the features Classes from the dataset which is Binary classification (fire, not fire).
  • For Regression Problem algorithm decided to predict the feature FWI (Fire weather Index) which is 90%+ correlated to Classes Feature.

Loading CSV and Inserting to DB

  • The Downloaded CSV file is loaded as pandas Dataframe using Pandas Library.
  • Pandas Dataframe is converted to Dict .
  • Mongodb Altas is used as DB here, with pymongo library mongodb is connected to python.
  • Database and collections created via python and the list of dictionaries is uploaded using collection.insert_many method.

(back to top)

EDA

  • In this step, we will apply Exploratory Data Analysis (EDA) to extract insights from the data set to know which features have contributed more in predicting Forest fire by performing Data Analysis using Pandas and Data visualization using Matplotlib & Seaborn.
  • It is always a good practice to understand the data first and try to gather as many insights from it.

Model Building

  • For Regression Problem algorithm decided to predict the feature FWI (Fire weather Index) which is 90%+ correlated to Classes Feature.
  • Models used : Linear regression, Lasso Regression, Ridge Regression, Random forest, Decision tree, K-Nearest Neighbour regressor, Support Vector Regressor.
  • For Classification algorithm decided to predict the features Classes from the dataset which is Binary classification (fire, not fire).
  • Models used : Logistic Regression, Decision Tree, Random Forest, XGboost, K-Nearest Neighbour.

Model Selection

  • HyperParameter Tuning Randomized Gridsearch CV is done for top 2 models for both Regression and Classification.
  • For Classification Stratified Kfold Cross-Validation metrics is used based best Mean CV Accuracy Model is used for Model Deployment.
  • For Regression R2 score metrics is used to select best model The R2 score is one of the performance evaluation measures for regression-based machine learning models.

Flask

  • Importing the Flask module and creating a Flask web server from the Flask module.
  • Create an object app in flask class with __name__ which represents current app.py file.
  • Create / route to render default page html.
  • /predict_api route for api testing using Postman
  • Create a route /predict /predictR to get user input for Classification and Regression respectively.
  • Run the flask app with app.run() code.

Heroku Deployment

  • Create new repo in Github and push all the data using Git.
  • Install Heroku CLI and login using heroku login and setup the app in Heroku Web.
  • Connect with app heroku git:remote -a appname
  • Push to Heroku using git push heroku main

(back to top)

Technologies used

Python scikit-learn Flask MongoDB NumPy Pandas

Tools used

PyCharm Git GitHub Tools used | Postman Heroku

Contact

Aravind Selvam | LinkedIn Aravind Selvam | G Mail GodWin1100 | GitHub

(back to top)