https://github.com/djdurga/crop-prediction-analysis
https://github.com/djdurga/crop-prediction-analysis
Last synced: 13 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/djdurga/crop-prediction-analysis
- Owner: Djdurga
- Created: 2024-07-27T07:26:23.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-07-27T07:29:50.000Z (almost 2 years ago)
- Last Synced: 2025-10-16T02:22:09.231Z (9 months ago)
- Language: Jupyter Notebook
- Size: 2.73 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Crop Production Analysis in India
## Project Overview
This project aims to analyze crop production data in India, predict future crop production, and identify key indicators and metrics influencing crop yields. By utilizing data science techniques, this project provides actionable insights for stakeholders in the agriculture sector.
## Dataset Description
The dataset contains information on crop production across various states in India over several years. Key features include:
- **State_Name**: The name of the state.
- **District_Name**: The name of the district.
- **Crop_Year**: The year of crop production.
- **Season**: The season in which the crop was grown.
- **Crop**: The type of crop.
- **Area**: The area of land used for crop production (in hectares).
- **Production**: The amount of crop produced (in tons).
## Analysis Steps
### 1. Data Exploration
- **Initial Inspection**: Loaded the dataset and displayed the first few rows to understand its structure.
- **Basic Statistics**: Generated summary statistics to get insights into the distribution of data.
- **Missing Values**: Checked for and handled missing values by removing rows with missing data.
- **Data Information**: Examined the data types and the presence of null values.
### 2. Exploratory Data Analysis (EDA)
- **Distribution of Crop Production**: Visualized the distribution of crop production using a histogram.
- **Area vs. Production**: Examined the relationship between the area of land used and the crop production using a scatter plot.
- **Crop Production by State**: Analyzed crop production across different states using a box plot to identify variations and outliers.
### 3. Data Preprocessing
- **Encoding Categorical Variables**: Converted categorical variables into numerical format using one-hot encoding.
- **Feature and Target Variable Split**: Separated the dataset into features (independent variables) and the target variable (dependent variable, i.e., crop production).
- **Training and Testing Sets**: Split the dataset into training (80%) and testing sets (20%).
- **Standardization**: Standardized the features to have a mean of 0 and a standard deviation of 1 for better model performance.
### 4. Model Building
- **Model Selection**: Chose a Random Forest Regressor for predicting crop production.
- **Training**: Trained the model using the training set.
- **Prediction**: Made predictions on the test set.
- **Evaluation**: Evaluated the model's performance using Mean Squared Error (MSE) and R-squared (R²) score.
### 5. Model Performance
- **Mean Squared Error (MSE)**: Quantifies the difference between the predicted and actual values.
- **R-squared (R²) Score**: Indicates how well the model explains the variance in the target variable. An R² score of 0.90, for example, means that 90% of the variance in crop production is explained by the model.
- **Accuracy in Percentage**: Converted the R² score into a percentage for easier interpretation.
### 6. Feature Importance
- Identified the top 10 features influencing crop production using the feature importance scores from the Random Forest model.
## Key Insights
- **Model Performance**: The model achieved an R² score of [insert R² score], translating to an accuracy of [insert accuracy percentage]%. This indicates a strong predictive capability.
- **Top Features**: The most significant features influencing crop production were [list top features].
## Conclusion
This analysis provides valuable insights into crop production patterns in India. By understanding the key factors affecting crop yields, stakeholders can make informed decisions to enhance agricultural productivity. The trained model can be used for future predictions, helping in better planning and resource allocation.
## Future Work
- **Further Data Enrichment**: Incorporate additional datasets, such as weather data, soil quality, and irrigation practices, to improve model accuracy.
- **Advanced Modeling Techniques**: Explore other machine learning algorithms and ensemble methods to enhance predictive performance.
- **Real-Time Predictions**: Develop a real-time prediction system for dynamic crop production forecasting.
## Files
- **summary.json**: Contains a summary of key insights and findings.
- **crop_production_model.pkl**: Saved trained model for future use.
## How to Run the Project
1. **Clone the repository**:
```sh
git clone https://github.com/your-username/crop-production-analysis.git
cd crop-production-analysis
```
2. **Install the required packages**:
```sh
pip install -r requirements.txt
```
3. **Run the analysis script**:
```sh
python crop_production_analysis.py
```
4. **View the results**:
- The summary of key insights will be saved to `summary.json`.
- The trained model will be saved to `crop_production_model.pkl`.