File size: 3,556 Bytes
161ba65
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4439b77
161ba65
 
 
 
 
 
 
 
a99bdb9
161ba65
a99bdb9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
161ba65
 
 
 
 
 
 
 
 
 
 
 
 
db96cc2
 
 
 
 
 
 
 
 
161ba65
db96cc2
 
 
 
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import streamlit as st 
import joblib

html_temp = """
    <div style="background-color:green;padding:10px">
    <h2 style="color:white;text-align:center;">crop Yeid Prediction  </h2>
    </div>
    """
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"""
    <style>
        /* Set the background image for the entire app */
        .stApp {{
            background-color: #FAC668;
            background-size: 100px;
            background-repeat:no;
            background-attachment: auto;
            background-position:full;
        }}
    </style>
    """, 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("")