Skip to content
Home
Projects
Time Series Forecasting — cover
Academic · University of Minho·Data Science & ML2022

Time Series Forecasting

This app was built to predict the number of visits a Mall would have in a certain week so the marketing campaigns would be appropriately set up during each day.

3 min read

Languages
Frameworks & Libraries
Infrastructure & DevOps

Project Overview

Developed as part of the Artificial Intelligence Techniques in Forecasting and Optimization in Business Systems (TIAPOSE) course at the University of Minho (MIEGSI), this project addresses a real-world decision-support problem in commercial retail management. Using daily visitor traffic data provided by an industry partner from a pilot deployment, the system combines time series predictive forecasting with prescriptive optimization to guide 7-day marketing campaign allocations and maximize business profitability.

The implementation strictly leveraged R and Professor Paulo Cortez’s rminer framework, integrating temporal forecasting techniques, scenario-based pre-processing, and web app deployment via R Shiny.


Technical Architecture & Methodology

The project strictly adhered to the CRISP-DM (Cross-Industry Standard Process for Data Mining) framework across six structured stages:

1. Business Understanding

  • Defined the core objective: transform raw foot-traffic time-series data into actionable business intelligence by forecasting daily entrance counts and determining optimal marketing spend.
  • Formulated the dual-stage framework: Stage 1 predicts daily visitor volumes, while Stage 2 feeds these predictions into an optimization algorithm to select the most profitable promotional campaign strategy for a target 7-day window.

2. Data Understanding & Exploratory Analysis (EDA)

  • Conducted comprehensive exploratory analysis on historic visitor entry records provided by the IT pilot project.
  • Identified temporal patterns, weekly seasonality, peak foot-traffic days, and variance trends across different time horizons.
  • Examined data quality, cardinality, missing values, and statistical distribution properties to establish baseline expectations for regression performance.

3. Data Preparation & Scenario Engineering

  • Feature Engineering: Formulated synthetic temporal attributes, combined collinear indicators, and engineered lag variables to capture autoregressive behavior.
  • Outlier & Error Handling: Cleaned anomalies, imputing or adjusting extreme values that could distort regression boundaries.
  • Scenario Testing: Designed three distinct pre-processing scenarios with varying feature subsets (selected through manual correlation matrix analysis and automated grid search experiments) to compare model sensitivity across pre-processed inputs.

4. Modeling & Backtesting Evaluation

  • Model Families: Constructed univariate, multivariate, and hybrid time-series regression models using the rminer and forecast packages in R.
  • Temporal Validation: Implemented rolling-window backtesting and time-aware cross-validation to prevent data leakage and ensure realistic out-of-sample performance evaluation on sequential time-series data.
  • Performance Metrics: Tracked regression evaluation metrics (RMSE, MAE, MAPE) across each scenario to select the optimal model configuration.

5. Prescriptive Optimization Engine

  • Fed the 7-day forecasted visitor numbers into a mathematical optimization script.
  • Evaluated marketing campaign options against expected visitor traffic conversion rates to determine the optimal budget distribution that maximizes ROI while minimizing marketing acquisition cost.

6. Application Deployment

  • Developed an interactive web application using R Shiny in RStudio, encapsulating model loading, dynamic prediction generation, and interactive optimization controls.
  • Deployed the full production app on Shinyapps.io, enabling real-time scenario simulation and web-based decision making.

Key Challenges & Technical Insights

  • Transitioning from Python to R: Migrated machine learning paradigms from Python/Scikit-Learn to R’s specialized data science library ecosystem (rminer, forecast).
  • Time Series Backtesting: Mastered time-aware evaluation strategies (rolling window backtesting) to properly measure model generalization without exposing future temporal information.
  • Predictive-to-Prescriptive Integration: Successfully linked a predictive regression engine directly into a downstream optimization function, converting raw numbers into strategic marketing decisions.
  • End-to-End App Architecture: Built and published a functional web UI and RESTful processing logic in R Shiny from scratch.

Project Gallery

See it in action