Spaces:
Sleeping
Sleeping
File size: 2,480 Bytes
badd6eb 89f7bb6 badd6eb ffe1a20 badd6eb 55c1d5f badd6eb 89f7bb6 cd7c664 ea16b12 89f7bb6 3fc9d84 89f7bb6 99dc882 89f7bb6 |
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 |
import pandas as pd
import streamlit as st
import pickle
# Load Model
try:
with open("classification pickle (1).pkl", "rb") as f:
model = pickle.load(f)
st.success("β
Model loaded successfully!")
except FileNotFoundError:
st.error("β Model file not found! Please upload `classification pickle.pkl`.")
model = None
# Title
st.markdown("<h1 style='text-align: center; color: green;'>Rice Class Predictor</h1>", unsafe_allow_html=True)
# User Inputs
with st.expander("πΉ **Enter Property Details**", expanded=True):
Area = st.number_input("Area", min_value=2522.0, max_value=10210.0, value=6660.0)
MajorAxisLength = st.number_input("Major Axis Length", min_value=74.13, max_value=183.21, value=153.88)
MinorAxisLength = st.number_input("Minor Axis Length", min_value=34.40, max_value=82.55, value=55.72)
Eccentricity = st.number_input("Eccentricity", min_value=0.67, max_value=0.97, value=0.92)
ConvexArea = st.number_input("Convex Area", min_value=2579.0, max_value=11008.0, value=6843.0)
EquivDiameter = st.number_input("Equivalent Diameter", min_value=56.66, max_value=114.01, value=92.08)
Extent = st.number_input("Extent", min_value=0.38, max_value=0.89, value=0.60)
Perimeter = st.number_input("Perimeter", min_value=197.01, max_value=508.51, value=353.08)
Roundness = st.number_input("Roundness", min_value=0.17, max_value=0.90, value=0.70)
AspectRation = st.number_input("Aspect Ration", min_value=1.35, max_value=3.91, value=2.60)
st.write("**Jasmine-1, Gonen-1**")
# Prediction Button
if st.button("π Predict Class"):
if model is not None:
input_data = pd.DataFrame([[Area, MajorAxisLength, MinorAxisLength, Eccentricity,
ConvexArea, EquivDiameter, Extent, Perimeter,
Roundness, AspectRation]],
columns=["Area", "MajorAxisLength", "MinorAxisLength",
"Eccentricity", "ConvexArea", "EquivDiameter",
"Extent", "Perimeter", "Roundness", "AspectRation"])
try:
predicted_class = model.predict(input_data)[0]
st.markdown(f"<div style='text-align: center; font-size: 20px; font-weight: bold; color: blue;'>Predicted Class: {predicted_class:.2f}</div>", unsafe_allow_html=True)
except ValueError as e:
st.error(f"β Error during prediction: {e}") |