The Crop Prediction AI System is a machine learning application designed to predict optimal crop yields based on various environmental and soil parameters. By leveraging multiple predictive models, including Decision Tree, Logistic Regression, Naive Bayes Classifier, and Random Forest, this system provides accurate recommendations for farmers and agricultural stakeholders.
- Multi-Model Prediction: Utilizes various machine learning algorithms to enhance prediction accuracy.
- User-Friendly API: Built using FastAPI, allowing easy integration and interaction with the prediction system.
- CORS Support: Configured to allow requests from any origin, facilitating cross-origin resource sharing.
- Python: The primary programming language used for development.
- FastAPI: A modern web framework for building APIs with Python.
- Pandas: A data manipulation library used for handling input data.
- Machine Learning Libraries: Includes popular libraries for model training and prediction.
-
Clone the repository:
git clone https://github.com/mosh3eb/Crop_predictor.git cd Crop_predictor -
Install the required dependencies:
pip install -r requirements.txt
-
Start the FastAPI server:
uvicorn main:app --reload
-
Send a POST request to the /predict endpoint with the following JSON body:
{ "nitrogen": <value>, "phosphorus": <value>, "potassium": <value>, "temperature": <value>, "humidity": <value>, "ph": <value>, "rainfall": <value> } -
The response will include the predicted crop:
{ "predicted_crop": "crop_name" }
Contributions are welcome! If you have suggestions for improvements or new features, please fork the repository and submit a pull request.
This project is licensed under the MIT License. See the LICENSE file for details.

