Upload 2 files
Browse files- app.py +32 -0
- random_forest_model.joblib +3 -0
app.py
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import joblib
|
| 3 |
+
import numpy as np
|
| 4 |
+
|
| 5 |
+
# Load the trained model
|
| 6 |
+
model = joblib.load("random_forest_model.joblib")
|
| 7 |
+
|
| 8 |
+
# Title
|
| 9 |
+
st.title("π€ AI Model Predictor")
|
| 10 |
+
|
| 11 |
+
inputs = []
|
| 12 |
+
feature_names = ['Baseline Fetal Heart Rate','Number of accelerations per second', 'Number of fetal movements per second',
|
| 13 |
+
'Number of uterine contractions per second', 'Number of LDs per second', 'Number of SDs per second',
|
| 14 |
+
'Number of PDs per second']
|
| 15 |
+
for i in feature_names:
|
| 16 |
+
value = st.text_input(f"{i}", value=0.0)
|
| 17 |
+
inputs.append(value)
|
| 18 |
+
|
| 19 |
+
# Converting and reshaping inputs to a NumPy array
|
| 20 |
+
input_array = np.array([inputs]).reshape(1, -1)
|
| 21 |
+
|
| 22 |
+
# Prediction Button
|
| 23 |
+
if st.button("π Predict"):
|
| 24 |
+
prediction = model.predict(input_array)[0]
|
| 25 |
+
if prediction == 1 :
|
| 26 |
+
status = 'Normal'
|
| 27 |
+
elif prediction == 2:
|
| 28 |
+
status = 'Suspect'
|
| 29 |
+
else:
|
| 30 |
+
status = 'Pathological'
|
| 31 |
+
st.success(f"π€ Model Prediction: **{prediction:.2f}**")
|
| 32 |
+
st.success(f"πΌπΌ Prediction Class: **{status}**")
|
random_forest_model.joblib
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:659ff6618b8604bafb159401806901f91d9ca0fc62311fa8b5785982a15ed76a
|
| 3 |
+
size 6781057
|