This repository contains the AnyLogic model for the project "Crop Prediction using Agent based modeling and Machine Learning". This model simulates the influence of weather factors on soil dynamics, utilizing the Crop_Prediction.csv dataset from Kaggle Dataset Repository to enhance our understanding of Crop Prediction based on the different environmental factors and soil quality.
This repository contains two main components:
- A Machine Learning Model for crop prediction.
- An AnyLogic Model to simulate the prediction process.
- Prerequisites
- Cloning the Repository
- Importing the Model in AnyLogic
- Running the Model
- Adjusting Parameters
- Outputs
- Acknowledgments
To open and run this model, you need:
- AnyLogic Software: Please install AnyLogic (version X.X or later) from AnyLogic's official website.
- Git (optional): If you prefer cloning via command line.
- Python 3.7 or higher
- Flask (
pip install flask
) - Other dependencies listed in
requirements.txt
To obtain a copy of this project, follow one of these methods:
If Git is installed, open a terminal and enter the following command:
git clone https://github.com/DEVANG-2021/CropPredictionModel.git
-
Download as ZIP:
- Go to the repository’s GitHub page.
- Click on Code > Download ZIP.
-
Extract the ZIP:
- Unzip the downloaded file to a folder of your choice on your local machine.
- Navigate to the ML_model folder:
cd ML_model
- Navigate to the ML_model folder:
cd ML_model
- Start the Flask server:
python api.py
- The ML model will now run on the Flask-based API. You can interact with it through its endpoint.
-
Open AnyLogic:
- Start AnyLogic on your computer.
-
Import the Project:
- In AnyLogic, go to File > Open Project.
- Navigate to the folder where you extracted the ZIP file.
- Select the
.alp
file (e.g.,CropPredictionNew.alp
) and click Open.
-
Select the Experiment:
- Locate the Projects pane (usually on the left side of the AnyLogic interface).
- Select the main experiment, typically named
Main
orSimulation
.
-
Run the Experiment:
- Click the Run button (green triangle) in the AnyLogic toolbar, or right-click the experiment name and select Run.
-
View the Simulation:
- The simulation window will open, displaying the Crop Prediction Main Agent with the button, sliders, and crop images.
Here’s an example screenshot of the simulation:
You can modify certain weather and fire parameters to see how different conditions affect the simulation:
-
Locate Parameters:
- In the Projects pane, click on the main experiment (
Simulation
orMain
).
- In the Projects pane, click on the main experiment (
-
Modify Values:
- Modify input parameters within the AnyLogic model to test different scenarios.
- For the ML model, update the input data in the API payload to adjust predictions.
-
Save and Run:
- After modifying parameters, save changes and Run the experiment again to see the effects.
The model provides several outputs, including:
- ML Model: Provides crop prediction results via the Flask API.
- AnyLogic Model: Simulates crop prediction dynamics and outputs visualization of scenarios.
Special thanks to Dr. Ziad Kobti for his support and guidance.
Technologies used:
- AnyLogic: For simulation modeling.
- Java: For programming and model customization.
- Python: For programming and making machine learning model and also perform visualisation.