knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" ) library(deeptriangle) library(tidyverse)
This is the companion repository to the DeepTriangle paper.
A preview of the current draft can be found at https://kasaai.github.io/deeptriangle/manuscript.pdf.
A citeable preprint can be found at https://arxiv.org/abs/1804.09253.
To get started, either clone the repo and build the R package, or install with
devtools::install_github("kasaai/deeptriangle")
You will also need the insurance package, which can be installed with
devtools::install_github("kasaai/insurance")
The experiments can be found in analysis/main.R
. It is recommended that you use a GPU since many instances of the models are fit.
For convenience, we provide a predictions.feather
file in the release.
predictions <- feather::read_feather("datasets/predictions.feather") model_results <- dt_compute_metrics(predictions) %>% bind_rows(stochastic_model_results) %>% bind_rows(read_csv("datasets/automl_results.csv")) %>% gather(metric, value, mape, rmspe) dt_tabulate_metrics(model_results, metric = "mape") %>% knitr::kable(booktabs = "T", digits = 3)
To create actual vs. predicted plots, use the dt_plot_predictions()
function. Here are successful and unsuccessful examples of the model's forecasting attempts.
Company 1767 commercial auto.
library(cowplot) p1 <- dt_plot_predictions(predictions, "1767", "commercial_auto", "paid_loss") + xlab("") p2 <- dt_plot_predictions(predictions, "1767", "commercial_auto", "claims_outstanding") p12 <- plot_grid( p1 + theme(legend.position = "none"), p2 + theme(legend.position = "none"), align = "v", ncol = 1 ) legend <- get_legend(p1) plot_grid(p12, legend, rel_widths = c(1, 0.2), nrow = 1)
Company 337 workers' compensation.
library(cowplot) p1 <- dt_plot_predictions(predictions, "337", "workers_compensation", "paid_loss") + xlab("") p2 <- dt_plot_predictions(predictions, "337", "workers_compensation", "claims_outstanding") p12 <- plot_grid( p1 + theme(legend.position = "none"), p2 + theme(legend.position = "none"), align = "v", ncol = 1 ) legend <- get_legend(p1) plot_grid(p12, legend, rel_widths = c(1, 0.2), nrow = 1)
If you would like to try out different architectures or hyperparameters, you can do so by providing a function that returns a keras model. See the source code of dt_model()
for a template.
For more details on the keras R package, visit https://keras.rstudio.com/.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.