Update app.py
Browse files
app.py
CHANGED
|
@@ -1,40 +1,36 @@
|
|
| 1 |
-
import
|
| 2 |
-
import
|
| 3 |
-
import
|
| 4 |
-
import
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
#
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
st.
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
st.dataframe(data)
|
| 35 |
-
|
| 36 |
-
# Download Predictions
|
| 37 |
-
st.download_button(label="Download Predictions", data=data.to_csv(index=False), file_name="predictions.csv", mime="text/csv")
|
| 38 |
|
| 39 |
|
| 40 |
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import numpy as np
|
| 3 |
+
import joblib
|
| 4 |
+
import pandas as pd
|
| 5 |
+
|
| 6 |
+
# Load the trained model
|
| 7 |
+
model = joblib.load("rice_model.pkl")
|
| 8 |
+
|
| 9 |
+
# Streamlit UI
|
| 10 |
+
st.title("Rice Classification Model")
|
| 11 |
+
st.write("Enter the grain properties to predict the type of rice.")
|
| 12 |
+
|
| 13 |
+
# User input fields
|
| 14 |
+
area = st.number_input("Area", min_value=1000, max_value=10000, value=5000)
|
| 15 |
+
major_axis_length = st.number_input("Major Axis Length", min_value=50.0, max_value=200.0, value=100.0)
|
| 16 |
+
minor_axis_length = st.number_input("Minor Axis Length", min_value=30.0, max_value=100.0, value=50.0)
|
| 17 |
+
eccentricity = st.number_input("Eccentricity", min_value=0.5, max_value=1.0, value=0.75)
|
| 18 |
+
convex_area = st.number_input("Convex Area", min_value=1000, max_value=10000, value=5000)
|
| 19 |
+
equiv_diameter = st.number_input("Equivalent Diameter", min_value=30.0, max_value=120.0, value=75.0)
|
| 20 |
+
extent = st.number_input("Extent", min_value=0.4, max_value=1.0, value=0.7)
|
| 21 |
+
perimeter = st.number_input("Perimeter", min_value=100.0, max_value=500.0, value=250.0)
|
| 22 |
+
roundness = st.number_input("Roundness", min_value=0.5, max_value=1.0, value=0.75)
|
| 23 |
+
aspect_ratio = st.number_input("Aspect Ratio", min_value=1.0, max_value=3.0, value=1.5)
|
| 24 |
+
|
| 25 |
+
# Predict button
|
| 26 |
+
if st.button("Predict Rice Type"):
|
| 27 |
+
input_features = np.array([[area, major_axis_length, minor_axis_length, eccentricity, convex_area,
|
| 28 |
+
equiv_diameter, extent, perimeter, roundness, aspect_ratio]])
|
| 29 |
+
prediction = model.predict(input_features)[0]
|
| 30 |
+
rice_type = "Type 1" if prediction == 1 else "Type 0"
|
| 31 |
+
st.success(f"Predicted Rice Type: {rice_type}")
|
| 32 |
+
|
| 33 |
+
# Run using: streamlit run app.py
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
|
| 35 |
|
| 36 |
|