Hospital Crowd Prediction
Recommendation System
Official documentation for the **AI-powered system** that forecasts hospital traffic, optimizes patient visits, and enhances operational efficiency using machine learning.
Project By: Group 2
Devadath N.P
Project Leader
Abhirath S Madhav
Hanna Fathima TK
Fathimath Faheema
Krishnapriya
Ananya Sujay
1. Project Overview
The **Hospital Queue Optimizer** is an intelligent web application designed to forecast crowd levels in a hospital at any given day and time. By leveraging a machine learning model, it provides patients with data-driven recommendations for the optimal time to visit, minimizing wait times and improving patient experience.
Primary Goal
To predict hospital crowdedness and suggest the least busy time slot for a visit on a selected day, enhancing resource management and patient flow.
Core Technology
Built with Streamlit for the interactive UI and a Random Forest Classifier for the prediction engine, trained on synthetic hospital traffic data.
2. Prerequisites & Requirements
A **Python 3.x environment** is required. The project relies on several key data science and web development libraries, which are listed below.
-
streamlit— For building the interactive web application GUI. -
numpy&pandas— For efficient data manipulation and handling. -
scikit-learn— For the machine learning model (RandomForestClassifier,StandardScaler). -
matplotlib&seaborn— For generating performance visualizations like the Confusion Matrix. -
datetime— For handling date and time logic.
3. Setup Instructions
3.1. Clone the Repository
First, get the project source code by cloning the official GitHub repository.
# Clone the repository
git clone https://github.com/HospitalCrowd/Crowdprediction-AI.git
# Navigate into the project directory
cd Crowdprediction-AI
3.2. Install Dependencies
Install all required libraries using pip. It's recommended to do this within a virtual environment.
# Install the necessary libraries
pip install streamlit numpy pandas scikit-learn matplotlib seaborn
4. Running the Application
With the dependencies installed, you can start the application using the Streamlit CLI. The app will automatically generate the dataset and train the model on its first run.
(Assuming the main script is named app.py)
# Execute the Streamlit application
streamlit run app.py
This command launches a local web server and opens the application in your default browser at http://localhost:8501.
5. Using the Streamlit Interface
User Inputs & Controls
The interface is designed for simplicity. All user controls are located in the sidebar:
- Select a Date: Choose your desired day using the calendar widget.
- Select a Time: Pick a specific time slot for the prediction (e.g., 10:00 AM).
- Predict & Suggest: Click this primary button to trigger the analysis.
Prediction & Recommendation
After clicking the button, the app instantly provides two key pieces of information:
- Crowd Status: A clear indication of whether the hospital is predicted to be Crowded or Not Crowded at your selected time.
- Best Time to Visit: A recommendation for the optimal 30-minute slot on the chosen day, identified by simulating all time slots to find the one with the lowest predicted crowd level.
6. Technical & Performance Details
The application provides transparency into the machine learning model's performance and architecture.
Model Type
Random Forest Classifier
Chosen for high accuracy, speed, and robustness against overfitting on structured data.
Model Accuracy
~90-92%
A high performance metric displayed directly in the user interface for full transparency.
Data Size
~15,000 Samples
Each data point represents aggregated crowd data for a 30-minute time slot.
Input Features
3 Core Features
Features used for prediction: hour, day_of_week, is_weekend.
Training Split
70% / 30%
The dataset is split 70% for model training and 30% for validation/testing.
Data Caching
@st.cache_data
Streamlit's caching decorator is used to optimize performance by loading the dataset and trained model only once.
Confusion Matrix
The application dynamically displays a confusion matrix, visually representing the model's performance by showing the counts of correct (True Positives/Negatives) versus incorrect (False Positives/Negatives) predictions, offering clear model diagnostics.
Classification Report
A detailed report is also generated, providing key classification metrics like **precision**, **recall**, and the **F1-score** for each class (Crowded vs. Not Crowded), ensuring a complete understanding of the model's predictive capabilities.