- Preproces the raw data:
python ./src/preprocess.py --data_path data/agriculture.xlsx --encode label --scale N --scale P --scale K --scale temperature --scale humidity --scale ph --scale rainfall-
The dataset Agriculture Data contains 2200 rows and 8 columns.
-
It provides favourable conditions that favour growth of some plants, the conditions include: Nitrogen - N, Phosphorus - P, Potassium - K, temperature, humidity, ph and rainfall.
-
The plants predicted are:
['rice', 'maize', 'chickpea', 'kidneybeans', 'pigeonpeas', 'mothbeans', 'mungbean', 'blackgram', 'lentil', 'pomegranate', 'banana', mango', 'grapes', 'watermelon', 'muskmelon', 'apple', 'orange', 'papaya', 'coconut', 'cotton', 'jute', 'coffee'] -
Key Factors to Consider:
Climate:
- Temperature: temperature suitable for a wide range of crops.
- Humidity: humidity favoring crops that thrive in humid conditions or otherwise.
- Rainfall: rainfall that can support various crops, but specific needs vary.
Soil pH:
- check pH which is suitable for any crop.
Nutrient Requirements:
- N, P, and K levels: These nutrients are essential for plant growth and development. The specific requirements vary among crops.
- The model takes input of the following items:
Nitrogen(**N**), Phosphorus(**P**), Potassium(**K**), **temperature, humidity, ph and rainfall**. - From that input, it returns the prediction object and the crop which has been predicted.
- All inputs are saved in the database for retraining the model and the result to is saved to track the performance of the model over time.
- The model takes floating point values to predict the crop which is favourable for the given conditions.
- The model is based on
LogisticRegressionand predicts 22 different classes. - Model accuracy after Cross Validation and model selection is
96.6%. - The model MinMaxScales all the inputs using
sklearn.preprocessing.MinMaxScalerto have the values withing a given range for ease in training the model and creating predictions.
Further about the features
- Rice:
- Climate: Warm, humid climate with temperatures between 25-35°C and high humidity (70-90%). Annual rainfall of 1000-2000 mm.
- Nutrient Requirements: High N (100-150 kg/ha), P (50-80 kg/ha), and K (80-120 kg/ha).
- Soil pH: Tolerates a wide range of pH (5-8).
- Maize:
- Climate: Warm, humid climate with temperatures between 20-30°C and moderate humidity (60-80%). Annual rainfall of 600-1000 mm.
- Nutrient Requirements: High N (100-150 kg/ha), P (50-80 kg/ha), and K (80-120 kg/ha).
- Soil pH: Tolerates a wide range of pH (5-8).
- Chickpea:
- Climate: Warm, dry climate with temperatures between 20-30°C and low humidity (30-50%). Annual rainfall of 300-500 mm.
- Nutrient Requirements: Moderate N (40-60 kg/ha), P (30-50 kg/ha), and K (40-60 kg/ha).
- Soil pH: Prefers neutral to slightly acidic soil (6-7).
- Kidney Beans:
- Climate: Warm, humid climate with temperatures between 20-30°C and moderate humidity (60-80%). Annual rainfall of 600-1000 mm.
- Nutrient Requirements: Moderate N (40-60 kg/ha), P (30-50 kg/ha), and K (40-60 kg/ha).
- Soil pH: Prefers well-drained soil with a pH of 6-7.
- Pigeon Peas:
- Climate: Warm, dry climate with temperatures between 25-35°C and low humidity (30-50%). Annual rainfall of 300-600 mm.
- Nutrient Requirements: Moderate N (40-60 kg/ha), P (30-50 kg/ha), and K (40-60 kg/ha).
- Soil pH: Tolerates a wide range of pH (5-8).
- Moth Beans:
- Climate: Warm, dry climate with temperatures between 25-35°C and low humidity (30-50%). Annual rainfall of 300-600 mm.
- Nutrient Requirements: Moderate N (40-60 kg/ha), P (30-50 kg/ha), and K (40-60 kg/ha).
- Soil pH: Tolerates a wide range of pH (5-8).
- Mung Bean:
- Climate: Warm, humid climate with temperatures between 25-35°C and high humidity (70-90%). Annual rainfall of 600-1000 mm.
- Nutrient Requirements: Moderate N (40-60 kg/ha), P (30-50 kg/ha), and K (40-60 kg/ha).
- Soil pH: Tolerates a wide range of pH (5-8).
- Black Gram:
- Climate: Warm, humid climate with temperatures between 25-35°C and high humidity (70-90%). Annual rainfall of 600-1000 mm.
- Nutrient Requirements: Moderate N (40-60 kg/ha), P (30-50 kg/ha), and K (40-60 kg/ha).
- Soil pH: Tolerates a wide range of pH (5-8).
- Lentil:
- Climate: Cool, dry climate with temperatures between 15-25°C and low humidity (30-50%). Annual rainfall of 300-500 mm.
- Nutrient Requirements: Moderate N (40-60 kg/ha), P (30-50 kg/ha), and K (40-60 kg/ha).
- Soil pH: Prefers neutral to slightly alkaline soil (7-8).
- Pomegranate:
- Climate: Warm, dry climate with temperatures between 25-35°C and low humidity (30-50%). Annual rainfall of 300-600 mm.
- Nutrient Requirements: Moderate N (40-60 kg/ha), P (30-50 kg/ha), and K (40-60 kg/ha).
- Soil pH: Prefers slightly alkaline soil (7-8).
- Banana:
- Climate: Warm, humid climate with temperatures between 25-35°C and high humidity (70-90%). Annual rainfall of 1000-2000 mm.
- Nutrient Requirements: High N (100-150 kg/ha), P (50-80 kg/ha), and K (80-120 kg/ha).
- Soil pH: Prefers well-drained soil with a pH of 5-7.
- Mango:
- Climate: Warm, humid climate with temperatures between 25-35°C and high humidity (70-90%). Annual rainfall of 1000-2000 mm.
- Nutrient Requirements: High N (100-150 kg/ha), P (50-80 kg/ha), and K (80-120 kg/ha).
- Soil pH: Prefers well-drained soil with a pH of 6-7.
- Grapes:
- Climate: Warm, dry climate with temperatures between 20-30°C and low humidity (30-50%). Annual rainfall of 300-600 mm.
- Nutrient Requirements: Moderate N (40-60 kg/ha), P (30-50 kg/ha), and K (40-60 kg/ha).
- Soil pH: Prefers well-drained soil with a pH of 6-7.
- Watermelon:
- Climate: Warm, humid climate with temperatures between 25-35°C and high humidity (70-90%). Annual rainfall of 600-1000 mm.
- Nutrient Requirements: Moderate N (40-60 kg/ha), P (30-50 kg/ha), and K (40-60 kg/ha).
- Soil pH: Prefers well-drained soil with a pH of 6-7.
- Muskmelon:
- Climate: Warm, dry climate with temperatures between 25-35°C and low humidity (30-50%). Annual rainfall of 300-600 mm.
- Nutrient Requirements: Moderate N (40-60 kg/ha), P (30-50 kg/ha), and K (40-60 kg/ha).
- Soil pH: Prefers well-drained soil with a pH of 6-7.
- Apple:
- Climate: Cool, temperate climate with temperatures between 10-20°C and moderate humidity (60-80%). Annual rainfall of 600-1000 mm.
- Nutrient Requirements: Moderate N (40-60 kg/ha), P (30-50 kg/ha), and K (40-60 kg/ha).
- Soil pH: Prefers well-drained soil with a pH of 6-7.
- Orange:
- Climate: Warm, humid climate with temperatures between 25-35°C and high humidity (70-90%). Annual rainfall of 1000-2000 mm.
- Nutrient Requirements: High N (100-150 kg/ha), P (50-80 kg/ha), and K (80-120 kg/ha).
- Soil pH: Prefers well-drained soil with a pH of 6-7.
- Papaya:
- Climate: Warm, humid climate with temperatures between 25-35°C and high humidity (70-90%). Annual rainfall of 1000-2000 mm.
- Nutrient Requirements: High N (100-150 kg/ha), P (50-80 kg/ha), and K (80-120 kg/ha).