Skip to contents

The 'partykit' image+ The 'futurize' hexlogo= The 'future' logo

The futurize package allows you to easily turn sequential code into parallel code by piping the sequential code to the futurize() function. Easy!

TL;DR

library(futurize)
plan(multisession)
library(partykit)

cf <- partykit::cforest(dist ~ speed, data = cars) |> futurize()

Introduction

The partykit package provides the breakpoints() function for estimating one or more change points in a data trace, e.g. in time-series data.

Example: Conditional random forests inference

Example adopted from help("cforest", package = "partykit"):

library(futurize)
plan(multisession)
library(partykit)

## basic example: conditional inference forest for cars data
cf <- cforest(dist ~ speed, data = cars) |> futurize()

## prediction of fitted mean and visualization
nd <- data.frame(speed = 4:25)
nd$mean  <- predict(cf, newdata = nd, type = "response")
plot(dist ~ speed, data = cars)
lines(mean ~ speed, data = nd)

This will parallelize the computations of the variable selection criterion, given that we have set up parallel workers, e.g.

plan(multisession)

The built-in multisession backend parallelizes on your local computer and works on all operating systems. There are other parallel backends to choose from, including alternatives to parallelize locally as well as distributed across remote machines, e.g.

plan(future.mirai::mirai_multisession)

and

plan(future.batchtools::batchtools_slurm)

Supported Functions

The following partykit functions are supported by futurize():