import streamlit as st import joblib html_temp = """

crop Yeid Prediction

""" st.markdown(html_temp, unsafe_allow_html=True) image_url="https://miro.medium.com/v2/resize:fit:1358/0*k-lYNf3gZ1M2u6AN" st.image(image_url, use_container_width=True) st.markdown(f""" """, unsafe_allow_html=True) col1,col2=st.columns(2) with col1: # Area options_Area = ['Albania', 'Algeria', 'Angola', 'Argentina', 'Armenia','Australia', 'Austria', 'Azerbaijan', 'Bahamas', 'Bahrain', 'Bangladesh', 'Belarus', 'Belgium', 'Botswana', 'Brazil','Bulgaria', 'Burkina Faso', 'Burundi', 'Cameroon', 'Canada', 'Central African Republic', 'Chile', 'Colombia', 'Croatia', 'Denmark', 'Dominican Republic', 'Ecuador', 'Egypt', 'El Salvador','Eritrea', 'Estonia', 'Finland', 'France', 'Germany', 'Ghana', 'Greece', 'Guatemala', 'Guinea', 'Guyana', 'Haiti', 'Honduras', 'Hungary', 'India', 'Indonesia', 'Iraq', 'Ireland', 'Italy', 'Jamaica', 'Japan', 'Kazakhstan', 'Kenya', 'Latvia', 'Lebanon', 'Lesotho', 'Libya', 'Lithuania', 'Madagascar', 'Malawi', 'Malaysia', 'Mali', 'Mauritania', 'Mauritius', 'Mexico', 'Montenegro', 'Morocco', 'Mozambique', 'Namibia', 'Nepal', 'Netherlands', 'New Zealand', 'Nicaragua', 'Niger', 'Norway', 'Pakistan', 'Papua New Guinea', 'Peru', 'Poland', 'Portugal', 'Qatar', 'Romania', 'Rwanda', 'Saudi Arabia', 'Senegal', 'Slovenia', 'South Africa', 'Spain', 'Sri Lanka', 'Sudan', 'Suriname', 'Sweden', 'Switzerland', 'Tajikistan', 'Thailand', 'Tunisia', 'Turkey', 'Uganda', 'Ukraine', 'United Kingdom', 'Uruguay', 'Zambia', 'Zimbabwe'] Area= st.selectbox('Choose an Area:', options_Area) Area_value=options_Area.index(Area) with col2: # Item options_Item =['Maize','Potatoes', 'Rice, paddy', 'Sorghum', 'Soybeans', 'Wheat','Cassava', 'Sweet potatoes', 'Plantains and others', 'Yams'] Item= st.selectbox('Choose a Item:', options_Item) Item_value=options_Item.index(Item) # average_rain_fall_mm_per_year avg_rainfall=st.slider('Slide The value to get Avg Rainfall',min_value=51,max_value=3240,value=1) # Pesticides_tonnes pes_tonnes=st.slider('Slide The value to get Pesticides Tonnes',min_value=1,max_value=367778,value=1) # Avg Temp avg_temp=st.slider('Slide The value to get Avg Temperature',min_value=1,max_value=30,value=1) model=joblib.load("model_rf.joblib") if st.button("Enter"): try: # Prepare input for the model input_features = [[Area_value, Item_value, avg_rainfall, pes_tonnes, avg_temp]] # Get prediction from the model output = model.predict(input_features)[0] # Display the result with styling st.success(f"🌱 The predicted **hg/ha_yield** is: **{output:.2f}**") except Exception as e: st.error(f"⚠️ Error in prediction: {e}") st.write("")