File size: 2,026 Bytes
f02a8e0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import streamlit as st
import pandas as pd
import joblib

# Page config
st.set_page_config(page_title="Blueberry Yield Predictor", layout="wide")

# Load model and scaler
@st.cache_resource
def load_model():
    model = joblib.load('model.joblib')
    scaler = joblib.load('scaler.joblib')
    return model, scaler

model, scaler = load_model()

# App title
st.title('🫐 Blueberry Yield Predictor')
st.markdown('Enter field parameters to predict blueberry yield')

# Create two columns for inputs
col1, col2 = st.columns(2)

with col1:
    st.subheader('Field Parameters')
    clonesize = st.slider('Clone Size', 10.0, 40.0, 25.0)
    honeybee = st.slider('Honeybee', 0.0, 1.0, 0.5)
    bumbles = st.slider('Bumbles', 0.0, 1.0, 0.25)
    andrena = st.slider('Andrena', 0.0, 1.0, 0.5)

with col2:
    st.subheader('Environmental Parameters')
    osmia = st.slider('Osmia', 0.0, 1.0, 0.5)
    MaxOfUpperTRange = st.slider('Max Temperature (°F)', 60.0, 100.0, 80.0)
    MinOfUpperTRange = st.slider('Min Temperature (°F)', 35.0, 60.0, 50.0)
    RainingDays = st.slider('Raining Days', 1.0, 34.0, 20.0)

# Predict button
if st.button('Predict Yield'):
    # Create input data
    input_data = pd.DataFrame({
        'clonesize': [clonesize],
        'honeybee': [honeybee],
        'bumbles': [bumbles],
        'andrena': [andrena],
        'osmia': [osmia],
        'MaxOfUpperTRange': [MaxOfUpperTRange],
        'MinOfUpperTRange': [MinOfUpperTRange],
        'AverageOfUpperTRange': [(MaxOfUpperTRange + MinOfUpperTRange) / 2],
        'MaxOfLowerTRange': [60.0],
        'MinOfLowerTRange': [30.0],
        'AverageOfLowerTRange': [45.0],
        'RainingDays': [RainingDays],
        'AverageRainingDays': [RainingDays/100],
        'fruitset': [0.5],
        'fruitmass': [0.45],
        'seeds': [35.0]
    })
    
    # Scale and predict
    input_scaled = scaler.transform(input_data)
    prediction = model.predict(input_scaled)[0]
    
    # Display prediction
    st.success(f'Predicted Yield: {prediction:.2f}')