PredictR is a lightweight, self-contained predictive analytics template for SaaS businesses. It allows users to upload their data (events, accounts, subscriptions), builds churn and upsell models on the fly, and visualizes key metrics in an interactive dashboard.
Built with R, Shiny, SQLite, and tidymodels (via caret).
- Data Ingestion: Upload CSVs and automatically persist them to a local SQLite database.
- Automated Feature Engineering: Calculates account tenure, MRR, and recent activity metrics.
- Churn Prediction: Trains a logistic regression model to identify high-risk accounts.
- Upsell Modeling: Identifies accounts with high usage potential for plan upgrades.
- Revenue Dashboard: Visualizes MRR distribution and plan tiers.
-
app/: Contains the Shiny application (ui.R,server.R,global.R). -
R/: Core logic libraries.data_prep.R: Data cleaning and validation.feature_engineering.R: Feature creation pipeline.models_*.R: Model training and prediction logic.metrics.R: Evaluation metrics and plotting.db.R: Database helper functions.
-
data/sample/: Synthetic sample data to get started quickly. -
sql/: Database schema definitions. -
deploy/: Docker configuration for deployment.PredictR/ │ ├── app/ # Shiny application (UI + Server) │ ├── global.R │ ├── ui.R │ └── server.R │ ├── R/ # Core analytics logic │ ├── data_prep.R │ ├── feature_engineering.R │ ├── models_churn.R │ ├── models_upsell.R │ ├── metrics.R │ └── db.R │ ├── data/ │ └── sample/ # Synthetic starter data (CSV) │ ├── sql/ │ └── schema.sql # SQLite schema │ ├── deploy/ │ ├── Dockerfile │ └── run.sh # Build + run script │ └── README.md
┌────────────────────────┐
│ CSV Upload │
│ (events / accounts / │
│ subscriptions) │
└────────────┬───────────┘
│
▼
┌──────────────────────┐
│ Data Ingestion │
│ • Validation │
│ • Cleaning │
└────────────┬─────────┘
│
▼
┌──────────────────────────┐
│ SQLite Database │
│ (DBI + RSQLite) │
└────────────┬────────────┘
│
▼
┌──────────────────────────────┐
│ Feature Engineering │
│ tenure / MRR / recency / │
│ aggregation / normalization │
└────────────┬─────────────────┘
│
▼
┌──────────────────────────────┐ ┌──────────────────────────────┐
│ Churn Model │ │ Upsell Model │
│ (Tidymodels + caret LR) │ │ (Probability-based scoring) │
└────────────┬─────────────────┘ └────────────┬─────────────────┘
│ │
└──────────────────┬───────────────────┘
▼
┌───────────────────────┐
│ Shiny Dashboard │
│ • Metrics │
│ • ROC curves │
│ • Account lists │
└───────────────────────┘
Requires R and the following packages: shiny, dplyr, ggplot2, DT, DBI, RSQLite, readr, tidyr, caret, pROC, e1071.
- Clone the repository.
- Open R or RStudio in the project root.
- Run the app:
shiny::runApp("app")
- Build and run the container using the helper script:
./deploy/run.sh
- Open your browser to http://localhost.
- Load Data: Go to the "Data" tab. You can upload your own CSVs or click "Load Sample Data" to see the app in action.
- Train Models: Navigate to "Churn Model" or "Upsell Model" and click "Train Model".
- Analyze: View the ROC curves, metrics, and the list of high-risk/high-opportunity accounts.
