Jagadesswar commited on
Commit
4581712
Β·
verified Β·
1 Parent(s): 832cc1e

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +10 -5
app.py CHANGED
@@ -25,30 +25,35 @@ crop = st.selectbox("🌱 Crop", ["Rice", "Wheat", "Cotton", "Maize", "Pulses"])
25
  season = st.selectbox("πŸ—“οΈ Season", ["Kharif", "Rabi", "Whole Year"])
26
  crop_year = st.number_input("πŸ“… Crop Year", min_value=1990, max_value=2025, value=2024)
27
 
28
- area = st.number_input("🌾 Area (hectares)", min_value=0.1, step=0.1)
29
- production = st.number_input("πŸ“¦ Production (tonnes)", min_value=0.1, step=0.1)
30
  bag_weight = st.number_input("βš–οΈ Bag Weight (kg)", min_value=50, max_value=100, value=75)
31
 
32
  rainfall = st.number_input("🌧️ Annual Rainfall (mm)", min_value=0.0, step=1.0)
33
  fertilizer = st.number_input("πŸ’Š Fertilizer Used (kg)", min_value=0.0, step=1.0)
34
  pesticide = st.number_input("🧴 Pesticide Used (kg)", min_value=0.0, step=1.0)
35
 
 
 
36
 
37
 
38
- # --- Input DataFrame (aligned with training data) ---
39
  input_data = pd.DataFrame({
40
  "Crop": [crop],
41
  "Crop_Year": [crop_year],
42
  "Season": [season],
43
  "State": [state],
44
- "Area": [area],
45
- "Production": [production],
46
  "Annual_Rainfall": [rainfall],
47
  "Fertilizer": [fertilizer],
48
  "Pesticide": [pesticide],
49
  })
50
 
 
51
  # --- Prediction ---
52
  if st.button("πŸš€ Predict Yield"):
53
  prediction = model.predict(input_data)[0] # model outputs yield in t/ha
54
  st.success(f"🌾 Estimated Yield: {prediction:.2f} t/ha")
 
 
 
 
25
  season = st.selectbox("πŸ—“οΈ Season", ["Kharif", "Rabi", "Whole Year"])
26
  crop_year = st.number_input("πŸ“… Crop Year", min_value=1990, max_value=2025, value=2024)
27
 
28
+ area_acres = st.number_input("🌾 Area (in acres)", min_value=0.1, step=0.1)
29
+ production_bags = st.number_input("πŸ“¦ Production (in bags)", min_value=1, step=1)
30
  bag_weight = st.number_input("βš–οΈ Bag Weight (kg)", min_value=50, max_value=100, value=75)
31
 
32
  rainfall = st.number_input("🌧️ Annual Rainfall (mm)", min_value=0.0, step=1.0)
33
  fertilizer = st.number_input("πŸ’Š Fertilizer Used (kg)", min_value=0.0, step=1.0)
34
  pesticide = st.number_input("🧴 Pesticide Used (kg)", min_value=0.0, step=1.0)
35
 
36
+ area_ha = area_acres / 2.47 # convert acres β†’ hectares
37
+ production_tonnes = (production_bags * bag_weight) / 1000 # convert bags β†’ tonnes
38
 
39
 
 
40
  input_data = pd.DataFrame({
41
  "Crop": [crop],
42
  "Crop_Year": [crop_year],
43
  "Season": [season],
44
  "State": [state],
45
+ "Area": [area_ha],
46
+ "Production": [production_tonnes],
47
  "Annual_Rainfall": [rainfall],
48
  "Fertilizer": [fertilizer],
49
  "Pesticide": [pesticide],
50
  })
51
 
52
+
53
  # --- Prediction ---
54
  if st.button("πŸš€ Predict Yield"):
55
  prediction = model.predict(input_data)[0] # model outputs yield in t/ha
56
  st.success(f"🌾 Estimated Yield: {prediction:.2f} t/ha")
57
+
58
+ prediction_bags_per_acre = (prediction * 2.47 * 1000) / bag_weight
59
+ st.info(f"Equivalent: {prediction_bags_per_acre:.2f} bags per acre")