File size: 1,631 Bytes
53415e3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4409f18
53415e3
 
 
4409f18
53415e3
a16a586
 
 
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
import streamlit as st
import numpy as np
import joblib
import pandas as pd

# Load the trained model
model = joblib.load("rice_model.pkl")

# Streamlit UI
st.title("Rice Classification Model")
st.write("Enter the grain properties to predict the type of rice.")

# User input fields
area = st.number_input("Area", min_value=1000, max_value=10000, value=5000)
major_axis_length = st.number_input("Major Axis Length", min_value=50.0, max_value=200.0, value=100.0)
minor_axis_length = st.number_input("Minor Axis Length", min_value=30.0, max_value=100.0, value=50.0)
eccentricity = st.number_input("Eccentricity", min_value=0.5, max_value=1.0, value=0.75)
convex_area = st.number_input("Convex Area", min_value=1000, max_value=10000, value=5000)
equiv_diameter = st.number_input("Equivalent Diameter", min_value=30.0, max_value=120.0, value=75.0)
extent = st.number_input("Extent", min_value=0.4, max_value=1.0, value=0.7)
perimeter = st.number_input("Perimeter", min_value=100.0, max_value=500.0, value=250.0)
roundness = st.number_input("Roundness", min_value=0.5, max_value=1.0, value=0.75)
aspect_ratio = st.number_input("Aspect Ratio", min_value=1.0, max_value=3.0, value=1.5)

# Predict button
if st.button("Predict Rice Type"):
    input_features = np.array([[area, major_axis_length, minor_axis_length, eccentricity, convex_area, 
                                   equiv_diameter, extent, perimeter, roundness, aspect_ratio]])
    prediction = model.predict(input_features)[0]
    rice_type = "Type 1" if prediction == 1 else "Type 0"
    st.success(f"Predicted Rice Type: {rice_type}")

# Run using: streamlit run app.py