Spaces:
Sleeping
Sleeping
File size: 1,400 Bytes
3d00fa3 0c02f7c 3d00fa3 dfe16c6 3d00fa3 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | import streamlit as st
import pandas as pd
import joblib
# Load model
model = joblib.load("model.pkl")
st.title("🌾 Crop Yield Prediction")
st.write("Enter the details below to predict crop yield.")
# Load dataset (only for dropdown values)
df = pd.read_csv("Indian_crop.csv")
# Inputs
year = st.number_input(
"Year",
min_value=int(df["Year"].min()),
max_value=int(df["Year"].max()),
value=int(df["Year"].max()),
step=1
)
state = st.selectbox("State", sorted(df["State"].unique()))
crop = st.selectbox("Crop", sorted(df["Crop"].unique()))
season = st.selectbox("Season", sorted(df["Season"].unique()))
area = st.number_input("Area (Hectares)", min_value=0.0, value=1.0)
annual_rainfall = st.number_input("Annual Rainfall (mm)", min_value=0.0, value=1000.0)
fertilizer = st.number_input("Fertilizer (kg)", min_value=0.0, value=100.0)
pesticide = st.number_input("Pesticide (kg)", min_value=0.0, value=10.0)
if st.button("Predict Yield"):
input_df = pd.DataFrame({
"Year": [year],
"State": [state],
"Crop": [crop],
"Season": [season],
"Area": [area],
"Annual_Rainfall": [annual_rainfall],
"Fertilizer": [fertilizer],
"Pesticide": [pesticide]
})
prediction = model.predict(input_df)
st.success(f"🌾 Predicted Yield: {prediction[0]}") |