Bridging Clinical Expertise with Data Science
As a healthcare professional with 10 years of clinical nursing experience, I developed this project to address a critical gap in hospital operations: how staffing composition impacts patient safety.
This tool uses Logistic Regression to quantify how patient-to-nurse ratios and team experience levels impact the probability of adverse events (e.g., falls, medication errors).
- Backend: Python 3.13
- Database: MySQL (Relational Schema Design)
- Data Engineering:
Pandas,SQLAlchemy,Urllib(Secure Credential Masking) - Statistics/ML:
Statsmodels(Logit Regression) - Visualization:
Seaborn,Matplotlib
In the most recent analysis of 200 shifts, the model identified Nursing Experience as the primary driver of patient safety.
| Metric | Coefficient | P-Value (P>|z|) | Interpretation |
| :--- | :--- | :--- | :--- |
| Experience | -0.1420 | 0.019 | Significant. More experience reduces error risk. |
| Staffing Ratio | -0.0648 | 0.636 | Not significant in this specific sample. |
| Model Fit | Pseudo R-squ: 0.04 | LLR p-value: 0.046 | The model is statistically better than a null model. |
The system features a "self-healing" initialization script. It automatically:
- Creates the
healthcare_dbschema in MySQL if not present. - Handles special characters in database passwords via URL-encoding.
- Populates tables with synthetic, logically-weighted clinical data.
Instead of basic descriptive statistics, this project utilizes a Logistic Regression model to calculate the "Log-Odds" increase in risk. In this dataset, the model proves that Experience has a higher correlation with safety than raw Ratios.
The script identifies "Red Zone" shifts and exports them to a dedicated high_risk_shifts_alerts table in MySQL for administrative intervention.
├── staffing_optimizer.py # Main ETL and Analysis pipeline
├── requirements.txt # Project dependencies
├── README.md # Project documentation
└── staffing_risk_correlation.png # Saved visualization
- MySQL Server: Ensure you have a local instance running.
- Python 3.10+: Recommended for compatibility with
statsmodels.
Clone this repository and navigate to the project folder:
git clone [https://github.com/azucena-m/nursing-staffing-optimizer.git]cd nursing-staffing-optimizer
pip install -r requirements.txt
- Create a
.envfile in the root directory. - Add your MySQL credentials to the
.envfile (see example below):DB_USER=your_user DB_PASSWORD=your_password DB_HOST=127.0.0.1 DB_NAME=healthcare_db
python staffing_optimizer.py