Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sleep disorder analysis added #673

Merged
merged 1 commit into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
375 changes: 375 additions & 0 deletions Prediction Models/sleep_disorder_predictor/data/dataset.csv

Large diffs are not rendered by default.

43 changes: 43 additions & 0 deletions Prediction Models/sleep_disorder_predictor/model.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import streamlit as st
import pickle
import pandas as pd # Import pandas to handle DataFrames
import numpy as np
import warnings
warnings.filterwarnings("ignore")

# Load the model and the scaler
model_path = 'Prediction Models/sleep_disorder_predictor/saved_models/Model_Prediction.sav'
preprocessor_path = 'Prediction Models/sleep_disorder_predictor/saved_models/preprocessor.sav'

# Load the pre-trained model and scaler using pickle
loaded_model = pickle.load(open(model_path, 'rb'))
preprocessor = pickle.load(open(preprocessor_path, 'rb'))

# Define the prediction function
def disease_get_prediction(Age, Sleep_Duration,
Heart_Rate, Daily_Steps,
Systolic, Diastolic, Occupation, Quality_of_Sleep, Gender,
Physical_Activity_Level, Stress_Level, BMI_Category):
# Create a DataFrame with the features using correct column names
features = pd.DataFrame({
'Age': [int(Age)],
'Sleep Duration': [float(Sleep_Duration)], # Changed to match expected name
'Heart Rate': [int(Heart_Rate)], # Changed to match expected name
'Daily Steps': [int(Daily_Steps)], # Changed to match expected name
'Systolic': [float(Systolic)],
'Diastolic': [float(Diastolic)],
'Occupation': [Occupation],
'Quality of Sleep': [int(Quality_of_Sleep)], # Changed to match expected name
'Gender': [Gender],
'Physical Activity Level': [int(Physical_Activity_Level)], # Changed to match expected name
'Stress Level': [int(Stress_Level)], # Changed to match expected name
'BMI Category': [BMI_Category] # Changed to match expected name
})

# Apply the preprocessor (make sure it expects a DataFrame)
preprocessed_data = preprocessor.transform(features)

# Make prediction
prediction = loaded_model.predict(preprocessed_data)

return prediction
Loading
Loading