This project aims to build a machine learning model that can recommend the most suitable crop to grow based on various environmental and soil parameters. The model is trained on a dataset containing information about different crops and their respective growing conditions.
The Crop Recommendation System leverages machine learning algorithms to suggest the most appropriate crop to cultivate under given conditions. It includes data preprocessing, exploratory data analysis (EDA), model training, and evaluation steps to ensure high accuracy and reliability.
The dataset used for this project is Crop_recommendation.csv
, which contains the following columns:
- N: Ratio of Nitrogen content in soil
- P: Ratio of Phosphorous content in soil
- K: Ratio of Potassium content in soil
- temperature: Temperature in degree Celsius
- humidity: Relative humidity in %
- ph: pH value of the soil
- rainfall: Rainfall in mm
- label: Type of crop
To run this project, you need to have Python installed along with several libraries. You can install the required libraries using the following command:
pip install -r requirements.txt
- Clone the repository:
git clone https://github.com/KumarranMahesh/Crop-Recommendation-System.git
- Navigate to the project directory:
cd Crop-Recommendation-System
-
Ensure you have the dataset
Crop_recommendation.csv
in the data directory. -
Run the Jupyter notebook or Python script to execute the project.
The project includes the following steps for model training:
- Data Preprocessing: Handling missing values, scaling numerical features, and encoding categorical features.
- Exploratory Data Analysis (EDA): Visualizing distributions and correlations of features using Matplotlib and Seaborn.
- Model Implementation: Training multiple machine learning models including Logistic Regression, Random Forest, Gradient Boosting, and more.
The models are evaluated based on accuracy, with a split of the dataset into training and testing sets using an 80-20 ratio. The Random Forest model achieved the highest accuracy of 100%.
- Random Forest Model: Achieved an accuracy of 100% on the test set.
- The trained model is saved as model.pkl for future use.