How eldrago12/restorease works
Project Type and Purpose
• This is a machine learning deployment project that integrates a Neural Network, a Random Forest model (for feature selection and probabilities), and a LightGBM meta-model. Its aim is to predict sleep disorders (e.g., Insomnia, Sleep Apnea, or Healthy status) with high accuracy.
• The project supports both model training/testing and deployment via two options: a Flask web application and an AWS Lambda-based solution using a converted tflite model.
File Structure
• Top-level files like LICENSE, README.md, app.py, and HTML pages (assessment.html, homepage.html) indicate that the repository holds both documentation and user interfaces.
• The existence of multiple Python scripts (final.py, h5_test.py, tflite_test.py, and model_conversion.py) shows that the project includes testing and conversion utilities.
• The “model” directory contains all artifact models (TensorFlow neural network in .h5 and .tflite formats, Random Forest, scaler, and meta-model artifacts in .pkl files) used in the prediction pipeline.
Key Architectural Components
a. User / Client Interface:
• Static web pages (assessment.html, homepage.html) and API clients that send prediction requests.
b. Web Server / API Layer:
• Flask application (app.py) that receives HTTP POST requests on the “/predict” endpoint.
c. Model Loading & Preprocessing:
• Code that loads all the model artifacts (neural.h5, rf_model.pkl, scaler.pkl, sleep_disorder_encoder.pkl, top_feature_names.pkl).
• Data preprocessing (using StandardScaler and label encoding) and feature selection steps.
d. Prediction Pipeline:
• Neural Network component running predictions (with probability output for each class).
• Random Forest component generating feature selection probabilities.
• A meta-model (LightGBM) that integrates outputs from the Neural Network, Random Forest, and selected top features.
• A decision logic that compares the NN prediction confidence to determine whether to use the neural or meta-model output.
e. Deployment Options:
• Option 1: Flask-based REST API for real-time predictions.
• Option 2: AWS Lambda deployment with model conversion to tflite for a lightweight execution environment.
f. Model Conversion & Testing Utilities:
• Scripts like model_conversion.py for converting to tflite and separate testing scripts (h5_test.py, tflite_test.py) to validate model performance.
• Clear labels for every component or module.