The Crop Recommendation with Machine Learning project aims to provide tailored crop recommendations based on various environmental factors such as soil type, temperature, humidity, and more. The goal of this project is to assist farmers and agricultural researchers in selecting the most suitable crops for specific environmental conditions, thereby optimizing yield and minimizing risk.
The system utilizes a machine learning model to predict the optimal crop based on user input. The user interface is built using React.js, offering an intuitive and user-friendly experience.
- Machine Learning Model: A predictive model trained on agricultural datasets to suggest the best crop for given environmental conditions.
- Web Application: A responsive and interactive web interface built with React.js for users to input data and receive crop recommendations.
- Data Visualization: Visual representations of input data and recommendations to help users understand and analyze the suggestions.
- User Management: Option to save and manage user data and previous recommendations if integrated with a database.
- Backend:
- Python
- Flask (for creating the API)
- Scikit-learn (for machine learning model training and prediction)
- Frontend:
- React.js (for building the user interface)
- Axios (for making API calls)
- Tailwind CSS (for styling and responsive design)
- Database:
- MongoDB (optional, for storing user data and recommendation history)
- Deployment:
- Heroku
- Python 3.x
- Node.js and npm
-
Clone the repository:
git clone [https://github.com/yourusername/crop-recommendation.git](https://github.com/kientech/Crop-Recommendation-with-Machine-Learning)
-
Navigate to the backend directory:
cd crop-recommendation/backend
-
Install the required Python packages:
pip install -r requirements.txt
-
Start the Flask server:
python app.py
The backend server should now be running on
http://localhost:5000
(or another port if configured differently).
-
Navigate to the frontend directory:
cd crop-recommendation/frontend
-
Install the required npm packages:
npm install
-
Start the React.js development server:
npm start
The frontend application should now be running on
http://localhost:3000
(or another port if configured differently).
- Web Interface: Access the web application in your browser. Enter environmental data such as soil type, temperature, and humidity into the form provided. The system will then use the machine learning model to recommend the most suitable crop.
- API Endpoints: The backend API provides endpoints for receiving data from the frontend and returning predictions. You can interact with these endpoints directly using tools like Postman for testing.
- GET /api/recommendation - Retrieve crop recommendations based on input parameters.
- POST /api/recommendation - Submit environmental data and receive crop recommendations.
The machine learning model is trained using a dataset that includes various environmental factors and the corresponding crop yields. The model training script is located in the model_training
directory.
-
Navigate to the
model_training
directory:cd crop-recommendation/model_training
-
Run the training script:
python train_model.py
This script will preprocess the data, train the model, and save it for use by the backend API.
The web application allows users to:
- Input Data: Enter environmental conditions including soil type, temperature, and humidity.
- Get Recommendations: Receive crop recommendations based on the input data.
- View Recommendations: (If database is implemented) Access and review previous recommendations.
We welcome contributions from the community! To contribute to this project:
- Fork the repository.
- Create a new branch for your changes.
- Make your changes and test them thoroughly.
- Submit a pull request with a description of your changes.