A web-based application that predicts whether a user has a healthy sleep routine, insomnia, or sleep apnea based on personal health metrics. Users fill in a simple form and receive an instant prediction powered by a machine learning model served through a REST API.
- Overview
- Features
- Tech Stack
- Input Features
- How It Works
- Project Structure
- Getting Started
- Usage
- API Reference
- Contributing
- License
- Contact
Sleep disorders affect millions of people worldwide. This tool helps users identify potential sleep issues early by analyzing key health indicators such as stress level, physical activity, heart rate, and BMI. The prediction is performed by an externally hosted machine learning model that classifies each submission into one of three categories:
| Label | Meaning |
|---|---|
| 0 | Healthy Sleep Routine |
| 1 | Insomnia |
| 2 | Sleep Apnea |
- Instant prediction – submit the form and get a result in seconds.
- Recommendation engine – after receiving a result, users can request nearby hospitals or clinics via the browser's Geolocation API (Google Maps integration).
- Responsive design – works on desktop, tablet, and mobile devices.
- Form validation – client-side checks ensure all fields are filled in correctly before submission.
- Custom alert UI – results are displayed in a styled popup rather than a plain browser dialog.
| Layer | Technology |
|---|---|
| Markup | HTML5 |
| Styling | CSS3, Bootstrap 5.3.3 |
| Scripting | JavaScript (ES6), jQuery 3.3.1 |
| ML Backend | Python REST API hosted on Render |
| Package Manager | npm (Bootstrap only) |
The prediction model uses the following 11 features:
| # | Feature | Type | Description |
|---|---|---|---|
| 1 | Age | Numeric | Age in years |
| 2 | Sleep Duration | Numeric | Average hours of sleep per night |
| 3 | Quality of Sleep | Scale (1–10) | Self-reported sleep quality |
| 4 | Physical Activity Level | Scale (1–10) | Daily physical activity level |
| 5 | Stress Level | Scale (1–10) | Self-reported stress level |
| 6 | Heart Rate | Numeric | Resting heart rate (bpm) |
| 7 | Daily Steps | Numeric | Average steps walked per day |
| 8 | Gender | Categorical | Male / Female |
| 9 | Occupation | Categorical | Student, Doctor, Engineer, Nurse, etc. |
| 10 | BMI Category | Categorical | Underweight / Normal weight / Overweight / Obese |
| 11 | Blood Pressure | Text | Systolic/Diastolic (e.g. 120/80) |
- The user opens the application in a browser and navigates to the Prediction page.
- They fill in all 11 health-metric fields and click Submit.
- The JavaScript client validates the inputs and sends a
POSTrequest to the prediction API. - The API returns a JSON response containing the predicted class (
0,1, or2). - The result is displayed in a custom popup with a human-readable label.
- Optionally, the user can click Find Nearby Hospitals, which opens Google Maps with a local hospital search using the browser's Geolocation API.
Sleep-Disorder-Prediction/
├── Index.html # Landing / home page
├── prediction.html # Health-metric input form and result display
├── script.js # Form handling, API calls, geolocation logic
├── style.css # Custom styles and Bootstrap overrides
├── package.json # npm metadata (Bootstrap dependency)
├── sleeping-disorder.jpg # Background image
├── facebook.png # Footer social icon
├── twitter.png # Footer social icon
├── image (1).png # Footer Instagram icon
└── LICENSE # Apache 2.0 License
- A modern web browser (Chrome, Firefox, Edge, Safari)
- Node.js & npm (optional – only needed to install Bootstrap locally)
-
Clone the repository
git clone https://github.com/tamim-shadman/Sleep-Disorder-Prediction.git cd Sleep-Disorder-Prediction -
Install dependencies (optional – Bootstrap is also loaded via CDN)
npm install
-
Open the app
Simply open
Index.htmlin your browser:# macOS open Index.html # Linux xdg-open Index.html # Windows start Index.html
No build step or local server is required.
- Open
Index.htmlin your browser. - Click Get Started or navigate to
prediction.html. - Fill in all the fields in the prediction form.
- Click Submit.
- View the prediction result in the popup.
- Optionally, click Find Nearby Hospitals to locate medical facilities near you.
The frontend communicates with the following endpoint:
| Property | Value |
|---|---|
| URL | https://sleep-disorder-prediction-api.onrender.com/predict_sleep_disorder |
| Method | POST |
| Content-Type | application/json |
{
"age": 30,
"sleep_duration": 7.5,
"quality_of_sleep": 8,
"physical_activity_level": 6,
"stress_level": 4,
"heart_rate": 72,
"daily_steps": 8000,
"gender": "Male",
"occupation": "Engineer",
"bmi_category": "Normal weight",
"blood_pressure": "120/80"
}{
"sleep_disorder": 0
}| Value | Meaning |
|---|---|
0 |
Healthy Sleep Routine |
1 |
Insomnia |
2 |
Sleep Apnea |
Contributions are welcome! To contribute:
- Fork the repository.
- Create a new branch:
git checkout -b feature/your-feature-name - Make your changes and commit them:
git commit -m 'Add your feature' - Push to your branch:
git push origin feature/your-feature-name - Open a Pull Request.
Please ensure your changes are well-tested and do not break existing functionality.
This project is licensed under the Apache License 2.0. See the LICENSE file for details.
Backbencher's Binary Solution
📧 backbenchersbinarysolution@gmail.com