Python-bloggers

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

This article was first published on T. Moudiki's Webpage - Python , and kindly contributed to python-bloggers. (You can report issue about the content on this page here)
Want to share your content on python-bloggers? click here.

nnetsauce

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

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:

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 - Python .

Want to share your content on python-bloggers? click here.
Exit mobile version