Master of Science in Computer Science • Implemented machine-learning proof of concept

COVID-19 Case Forecasting Model

A machine-learning pipeline for forecasting future COVID-19 case counts from county-level health data.

Excerpt from the model training and evaluation pipeline
from pathlib import Path
import numpy as np
import pandas as pd
from joblib import load
from sklearn.ensemble import RandomForestRegressor
from sklearn.model_selection import train_test_split
from sklearn.metrics import mean_absolute_error, mean_squared_error

BASE_DIR = Path(__file__).resolve().parent

TARGET_COLUMN = "Case_Count"
SCALED_COLUMNS = ["Case_Count", "Monitoring_Week", "Monitoring_Month", "Monitoring_Year"]
FUTURE_WEEKS = 12

# Read the cleaned/scaled data and scaler file.
data = pd.read_excel(BASE_DIR / "Covid19_Cleaned_After_Scaling.xlsx")
scaler = load(BASE_DIR / "Covid19_scaler.joblib")

# X = inputs, y = what we want to predict.
feature_columns = [column for column in data.columns if column != TARGET_COLUMN]
X = data[feature_columns]
y = data[TARGET_COLUMN]

# Split data into training and testing sets.
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)

# Train model.
model = RandomForestRegressor(random_state=42)
model.fit(X_train, y_train)

# Evaluate model performance on test data.
r2 = model.score(X_test, y_test)
y_pred = model.predict(X_test)
mae = mean_absolute_error(y_test, y_pred)
mse = mean_squared_error(y_test, y_pred)
rmse = np.sqrt(mse)

# Convert metrics from scaled values to case counts.
case_count_index = SCALED_COLUMNS.index(TARGET_COLUMN)
mae_cases = mae * scaler.scale_[case_count_index]
mse_cases = mse * (scaler.scale_[case_count_index] ** 2)
rmse_cases = rmse * scaler.scale_[case_count_index]

print(f"R^2: {r2:.4f}")
print(f"MAE (Case Count): {mae_cases:.2f}")
print(f"MSE (Case Count): {mse_cases:.2f}")
print(f"RMSE (Case Count): {rmse_cases:.2f}")
Sample rows from the twelve-week prediction workbook
DATEFacility_TypeBaltimoreMontgomeryWashington
2021-11-21 00:00:00Inmates: State and Local Affected Facilities1960478
2021-11-21 00:00:00Patients: State and Local Affected Facilities26002
2021-11-21 00:00:00Residents: Nursing, Assisted Living, Group Homes Affected Facilities1347215239
2021-11-21 00:00:00Staff: Nursing, Assisted Living, Group Homes Affected Facilities1074339211

Project objective

Create a reproducible proof of concept that transforms raw spreadsheet data into model-ready features and produces evaluated future predictions.

What I produced

  • Built a cleaning script for missing values, feature selection, and dataset preparation.
  • Created before-scaling and after-scaling workbooks for transparency.
  • Trained a Random Forest regression model with scikit-learn.
  • Saved the scaler for consistent future transformations.
  • Generated a twelve-week prediction workbook and analyzed ethical and design concerns.

Key decisions

  • Use Random Forest because it handles nonlinear relationships and interactions without requiring a linear model assumption.
  • Separate data cleaning from model training for repeatability.
  • Preserve intermediate datasets so transformations can be reviewed.
  • Discuss bias, privacy, interpretability, and misuse rather than treating prediction accuracy as the only concern.
12 weeksFuture predictions generated
Separate pipeline stagesCleaning, scaling, modeling, and export
Ethics reviewBias, privacy, and model-design concerns

Validation and analysis

  • Used a holdout dataset and regression performance measures.
  • Reviewed model stability and parameter choices.
  • Saved forecasts and supporting datasets as separate artifacts.