Skip to content
TARUN S / PORTFOLIOTAP OR PRESS ANY KEY TO SKIP

Developer

000

Plastic Waste Flow & Recycling Prediction

TYPE
Data analytics & ML platform
STACK
14 COMPONENTS
STATUS
SOURCE AVAILABLE
FEATURED
—

01 / OVERVIEW

A full data-science pipeline that models global plastic waste as a trade network, forecasts future production, and flags anomalous or high-risk countries — built for an Advanced Data Analytics course project.

Built as a semester-long Advanced Data Analytics (CSE-AIML) project, this platform stitches together three heterogeneous datasets — Our World in Data's global plastics production series (1950-2019), country-level mismanaged plastic waste per capita, and ~31,000 UN Comtrade plastic waste trade transactions (2012-2023) — into a single analysis pipeline. I worked on the core modules: a DataLoader that normalises inconsistent CSV schemas (including a Comtrade export with column-count mismatches that needed manual csv.DictReader parsing instead of pandas' native reader), a preprocessing layer that cleans and engineers features across all three datasets, a NetworkX-based flow analyzer that treats countries as nodes and trade volume as weighted edges to compute PageRank, betweenness, and critical-node analysis, a forecasting module offering ARIMA, Prophet, and LSTM with automatic fallback logic when a forecast returns NaNs, and a clustering/anomaly-detection module combining K-Means, hierarchical clustering, DBSCAN, Isolation Forest, and Z-score methods to surface countries and trade flows that look statistically unusual. Everything feeds into a Plotly/Dash dashboard and a set of standalone HTML visualizations (choropleth maps, network graphs, forecast comparisons) generated by a single orchestrating `app.py` script.

02/ STACK & ARCHITECTURE

FRONTEND

  • Plotly
  • Plotly Dash
  • Dash Bootstrap Components
  • HTML/CSS (generated visualizations)

BACKEND

  • Python
  • Pandas
  • NumPy
  • Scikit-learn
  • Statsmodels (ARIMA)
  • Prophet
  • TensorFlow/Keras (LSTM)
  • NetworkX
  • SciPy
  • Jupyter

03 / WHAT WAS ACTUALLY HARD

  1. 01

    Multi-source data ingestion & cleaning

    A DataLoader handles three structurally different sources — a clean OWID production time series, a country-level waste-per-capita snapshot, and a malformed UN Comtrade export — using csv.DictReader with UTF-8/latin-1 fallback to work around column-mismatch issues that broke pandas' default parser. A DataPreprocessor then standardises types, removes regional aggregates, derives features (YoY change, decade buckets, cumulative production, waste categorisation, normalised rankings), and produces trade network edge lists and yearly aggregates ready for downstream analysis.

  2. 02

    Trade network & flow analysis

    Countries are modelled as nodes in a directed, weighted NetworkX graph built from aggregated export/import flows. The FlowAnalyzer computes degree, betweenness, closeness, eigenvector centrality, and weighted PageRank to rank countries by trade influence, detects critical nodes whose removal would most disrupt the network, and runs greedy-modularity community detection to surface regional trading clusters.

  3. 03

    Multi-model time-series forecasting

    A Forecaster module runs ADF stationarity tests, then produces production forecasts via ARIMA, Prophet, and an LSTM (with a configurable lookback window and train/test split). Each model includes defensive fallback logic — e.g. ARIMA retries with `.forecast()` and `.predict()` if `get_forecast()` fails, and NaN forecasts are patched via linear extrapolation from recent trend — plus a comparison utility that aligns all models' outputs and computes MAE/MAPE/RMSE/R² against actuals.

  4. 04

    Clustering & anomaly detection for hotspot identification

    Country-level waste data is clustered with K-Means (with an elbow-method helper for choosing k), hierarchical clustering, and DBSCAN, while PCA supports dimensionality reduction for visualization. Anomalies are flagged two ways: an Isolation Forest and Z-score statistical outlier detection on waste-per-capita, plus a trade-flow anomaly detector that surfaces unusually large shipments and irregular per-kg pricing — useful for spotting potential illegal dumping or mislabelled trade.

  5. 05

    Automated visualization suite & dashboard

    A Visualizer class generates a full set of Plotly HTML artifacts — production trend and YoY growth charts, a waste-per-capita choropleth, top-N country bar charts, an interactive trade network graph, clustering and anomaly scatter plots, forecast-comparison overlays, and a 2×2 summary dashboard — all orchestrated end-to-end by a single `app.py` that also prints a clickable terminal link to the generated dashboard.