Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🌱 Crop Recommendation System

A Machine Learning-based Crop Recommendation System that predicts the most suitable crop based on soil nutrients and environmental conditions.

The system uses a K-Nearest Neighbors (KNN) classification algorithm and considers factors such as nitrogen, phosphorus, potassium, soil pH, temperature, humidity, and rainfall for crop prediction.


📌 Overview

Agricultural crop selection depends on various soil and weather conditions. This project uses machine learning to recommend suitable crops based on input parameters.

The system also integrates real-time weather data using the Open-Meteo API to obtain temperature, humidity, and rainfall information.


✨ Features

  • 🌱 Crop recommendation using Machine Learning
  • 🤖 K-Nearest Neighbors (KNN) classification model
  • 🌦️ Real-time weather data integration
  • 🧪 Uses soil nutrient parameters:
    • Nitrogen (N)
    • Phosphorus (P)
    • Potassium (K)
    • Soil pH
  • 📊 Uses environmental factors:
    • Temperature
    • Humidity
    • Rainfall

🛠️ Technologies Used

  • Python 🐍
  • Pandas
  • Scikit-learn
  • NumPy
  • Requests
  • Open-Meteo API

📂 Project Structure

Crop-Recommendation-System
│
├── crop_rec_system.py          # Crop recommendation ML program
├── Crop_recommendation.csv     # Dataset
├── requirements.txt            # Required Python libraries
├── README.md                   # Project documentation
└── .gitignore                  # Git ignored files

📊 Dataset

The dataset contains soil and environmental parameters used for crop prediction.

Input Features:

Feature Description
N Nitrogen content
P Phosphorus content
K Potassium content
temperature Temperature value
humidity Humidity percentage
ph Soil pH value
rainfall Rainfall amount

Output:

label → Recommended crop

⚙️ Installation

Clone the repository:

git clone https://github.com/Sathyabyte/Crop-Recommendation-System.git

Navigate into the project folder:

cd Crop-Recommendation-System

Install dependencies:

pip install -r requirements.txt

▶️ How to Run

Run the Python program:

python crop_rec_system.py

The program will:

  1. Load the crop dataset
  2. Train a KNN classification model
  3. Fetch weather information
  4. Take soil nutrient values as input
  5. Predict the recommended crop

💡 Example Input

Enter Nitrogen value: 90
Enter Phosphorus value: 42
Enter Potassium value: 43
Enter pH value: 6.5

🌾 Output

Recommended Crop: rice

🚀 Future Improvements

  • Save trained model for faster predictions
  • Add a user-friendly GUI/web interface
  • Improve model comparison using multiple ML algorithms
  • Add location-based crop recommendations

👩‍💻 Author

Sathyabyte

BCA (Hons) Student | Data Science + AI/ML

About

Machine Learning based crop recommendation system using KNN and weather data integration.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages