Parallel for loops (Map or Reduce) + New versions of nnetsauce and ahead

[This article was first published on T. Moudiki's Webpage - R, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

nnetsauce

The news are (reminder: the nnetsauce.Lazy*s do automated Machine Learning benchmarking of multiple models):

  • Update LazyDeepMTS: no more LazyMTS class, instead, you can use LazyDeepMTS with n_layers=1
  • Specify forecasting horizon in LazyDeepMTS (see updated docs and examples/lazy_mts_horizon.py)
  • New class ClassicalMTS for classsical models (for now VAR and VECM adapted from statsmodels for a unified interface in nnetsauce) in multivariate time series forecasting (not available in LazyDeepMTS yet)
  • partial_fit for CustomClassifier and CustomRegressor

ahead

The Python version now contains a class FitForecaster, that does conformalized time series forecasting (that is, with uncertainty quantification). It is similar to R’s ahead::fitforecast and an example can be found here:

https://github.com/Techtonique/ahead_python/blob/main/examples/fitforecaster.py

misc

misc is a package of utility functions that I use frequently and always wanted to have stored somewhere. The functions are mostly short, but (hopefully) doing one thing well, and powerful. misc::parfor is adapted from the excellent foreach::foreach. The difference is: misc::parfor calls a function in a loop. Two of the advantages of misc::parfor over foreach::foreach are:

  • you don’t have to register a parallel backend before using it. Just specify cl to use parallel processing (NULL for all the cores).
  • you can directly monitor the progress of parallel computation with a progress bar.

Here are a few examples of use of misc::parfor:

Installation

devtools::install_github("thierrymoudiki/misc")

library(misc)

Map

misc::parfor(function(x) x^2, 1:10)

misc::parfor(function(x) x^2, 1:10, cl = 2)

misc::parfor(function(x) x^2, 1:10, verbose = TRUE)

misc::parfor(function(x) x^3, 1:10, show_progress = FALSE)

misc::parfor(function(x) x^3, 1:10, show_progress = FALSE)

foo <- function(x)
{
  print(x)
  return(x*0.5)
}
misc::parfor(foo, 1:10, show_progress = FALSE, 
verbose = TRUE, combine = rbind)

misc::parfor(foo, 1:10, show_progress = FALSE, 
verbose = TRUE, combine = cbind)

Reduce

foo2 <- function(x)
{
  print(x)
  return(x*0.5)
}
misc::parfor(foo2, 1:10, show_progress = FALSE, 
verbose = TRUE, combine = '+')
To leave a comment for the author, please follow the link and comment on their blog: T. Moudiki's Webpage - R.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)