Generates PFA Documents from R Code and Optionally Runs Them

Provides tools for converting R objects and syntax into the Portable Format for Analytics (PFA). Allows for testing validity and runtime behavior of PFA documents through rPython and Titus, a more complete implementation of PFA for Python. The Portable Format for Analytics is a specification for event-based processors that perform predictive or analytic calculations and is aimed at helping smooth the transition from statistical model development to large-scale and/or online production. See <> for more information.

Build Status Coverage Status

aurelius is a toolkit for translating models and analytics from the R programming language into the Portal Format for Analytics (PFA). There are functions for importing, exporting and converting common R classes of models into PFA. There are also functions for converting variable assignment, control structures, and other elements of the R syntax into PFA.

Getting Started

devtools::install_github('opendatagroup/hadrian', subdir='aurelius')

Build a Model and Save as PFA

The main purpose of the package is to create PFA documents based on logic created in R. This example shows how to build a simple linear regression model and save as PFA. PFA is a plain-text JSON format.

# build a model
lm_model <- lm(mpg ~ hp, data = mtcars)
# convert the lm object to a list of lists PFA representation
lm_model_as_pfa <- pfa(lm_model)

The model can be saved as PFA JSON and used in other systems.

# save as plain-text JSON
write_pfa(lm_model_as_pfa, file = "my-model.pfa")

Just as models can be written as a PFA file, they can be read.

my_model <- read_pfa("my-model.pfa")

Supported Models

The pfa() function in this package supports direct conversion to PFA for objects created by the following functions:

Model Function Prediction Libraries
Autoregressive Integrated Moving Average (ARIMA) arima(), Arima(), auto.arima() Time Series stats, forecast
Classification and Regression Trees (CART) rpart() Classification, Regression, Survival rpart
Exponential Smoothing State Space ets(), ses(), hw(), holt() Time Series forecast
Generalized Boosted Regression Models gbm() Classification, Regression, Survival gbm
Generalized Linear Model glm() Classification, Regression stats
Holt-Winters Filtering HoltWinters() Time Series stats, forecast
K-Centroids Clustering kcca() Clustering flexclust
K-Means Clustering kmeans() Clustering stats
k-Nearest Neighbour knn3(), knnreg(), ipredknn() Classification, Regression caret, ipred
Linear Discriminant Analysis lda() Classification MASS
Linear Model lm() Regression stats
Naive Bayes Classifier naiveBayes() Classification e1071
Random Forest randomForest() Classification, Regression randomForest
Regularized Generalized Linear Models glmnet(), cv.glmnet() Classification, Regression, Survival glmnet


The aurelius package is licensed under the Apache License 2.0.



  • Add typical R package structure including, README, NEWS, CONTRIBUTING, .travis.yml, .Rbuildignore, and others) (@reportmort).

  • Add functions to convert "glm" and "lm" S3 objects directly to PFA (@reportmort, #27, #28).

aurelius 0.8.4

  • Adopt Apache License 2.0

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.


0.8.4 by Steven Mortimer, 4 years ago

Report a bug at

Browse source code at

Authors: Steven Mortimer [aut, cre] , Collin Bennett [aut] , Open Data Group [cph]

Documentation:   PDF Manual  

Task views: Model Deployment with R

Apache License 2.0 | file LICENSE license

Imports methods, stats, utils, jsonlite, gbm, glmnet

Suggests knitr, rmarkdown, testthat, MASS, forecast, caret, ipred, flexclust, e1071, randomForest, rpart

Enhances rPython

See at CRAN