Posts by T. Moudiki
Author: T. Moudiki
News from ESGtoolkit, ycinterextra, and nnetsauce
Feed: R-bloggers. Author: T. Moudiki. In this post, I introduce new versions of ESGtoolkit, ycinterextra, and nnetsauce. ESGtoolkit (for R) is a toolkit for Monte Carlo Simulation in Finance, Economics, Insurance, Physics, etc. ycinterextra (for R) is used for yield curve interpolation and extrapolation nnetsauce (for Python and R) does supervised Statistical/Machine Learning using Randomized and Quasi-Randomized neural networks Contents Feel free to jump directly to the section that has your interest: ESGtoolkit is no longer available from CRAN (archived). It can be installed from GitHub or from R universe. From Github: library(devtools) devtools::install_github("Techtonique/ESGtoolkit") From R universe: # Enable universe(s) ... Read More
New version of nnetsauce — various quasi-randomized networks
Feed: R-bloggers. Author: T. Moudiki. A new version of nnetsauce, v0.10.0, is available on Pypi (for Python) and GitHub (for R). To those who’ve never heard about nnetsauce: it’s a package for supervised learning (as of February 2022, you can solve regression, classification, and time series forecasting problems with nnetsauce) based on various combinations of components (g(XW+b)), with: (X), a matrix of explanatory variables or multivariate (univariate works too, but hasn’t been tested enough yet) time series (W), a matrix which contains quasirandom numbers, that help in achieving a kind of automated feature engineering ((XW)) (b), a bias term (g), ... Read More
A dashboard illustrating bivariate time series forecasting with `ahead`
Feed: R-bloggers. Author: T. Moudiki. Here is a link to a dashboard illustrating bivariate time series forecasting with the package ahead: https://thierry.shinyapps.io/ridge2shiny/ This dashboard is more specifically about ahead::ridge2f (in R) and ahead.Ridge2Regressor (in Python) hyperparameters’ meaning and impact. In the first two rows of the figure, everything related to ahead::ridge2f and ahead.Ridge2Regressor is colored in blue, in-sample and out-of-sample, whereas input series’ observed values are colored in red. Here are a few things you could try: Illustrating overfitting: Leave every other parameter constant – to their default value. Set the number of lags to 3, and increase the number ... Read More
Hundreds of Statistical/Machine Learning models for univariate time series, using ahead, ranger, xgboost, and caret
Feed: R-bloggers. Author: T. Moudiki. Today, we examine some nontrivial use cases for ahead::dynrmfforecasting. Indeed, the examples presented in the package’s README work quite smoothly – for randomForest::randomForest and e1071::svm – because: the fitting function can handle matricial inputs (can be called as fitting_func(x, y), also said to have a x/y interface), and not only a formula input (can be called as fitting_func(y ~ ., data=df), the formula interface) the predict functions associated to randomForest::randomForest and e1071::svm do have a prototype like predict(object, newx) or predict(object, newdata), which are both well-understood input formats for ahead::dynrmf. After reading this post, you’ll ... Read More
Time series cross-validation using `crossvalidation` (Part 2)
Feed: R-bloggers. Author: T. Moudiki. In a previous blog post, I presented time series cross-validation with crossvalidation::crossval_ts. The most recent version of package crossvalidation, v0.4.1, contains a new function called eval_ts. How does crossvalidation::eval_ts work? As described in the graph below: crossvalidation::crossval_ts and crossvalidation::eval_ts have the same arguments, except, an argument p for crossval_ts and an argument q for eval_ts. p is the percentage of original data used for cross-validation and hyperparameter tuning, and q is the percentage of unseen data used for model validation. In addition, and most importantly, we must have p + q = 1, to avoid ... Read More
Fast and scalable forecasting with ahead::ridge2f
Feed: R-bloggers. Author: T. Moudiki. Two weeks ago I presented ahead, an R package for univariate and multivariate time series forecasting. And last week, I’ve shown how ahead::dynrmf could be used for automatic univariate forecasting. This week, I compare the speeds of execution of ahead::ridge2f (quasi-randomized autoregressive network) and ahead::varf (Vector AutoRegressive model), with their default parameters (notably 1 lag, and 5-steps-ahead forecasting). For more examples of multivariate time series forecasting with ahead, you can type ?ahead::ridge2f, ?ahead::varf(x), or ?ahead::plot.mtsforecast in R console, once the package is installed and loaded. Here’s how to install ahead: 1st method: from R-universe In ... Read More
Automatic Forecasting with `ahead::dynrmf` and Ridge regression
Feed: R-bloggers. Author: T. Moudiki. Last week I presented ahead, an R package for univariate and multivariate time series forecasting. In particular, the function dynrmf was introduced for univariate time series, with examples of Random Forest and Support Vector Machines fitting functions (fitting and predicting through fit_func and predict_func arguments of dynrmf). First things first, here’s how to install R package ahead: 1st method: from R-universe In R console: options(repos = c( techtonique = 'https://techtonique.r-universe.dev', CRAN = 'https://cloud.r-project.org')) install.packages("ahead") 2nd method: from Github In R console: devtools::install_github("Techtonique/ahead") Or remotes::install_github("Techtonique/ahead") In version 0.2.0 of ahead, Ridge regression is the default fitting ... Read More
Forecasting with `ahead`
Feed: R-bloggers. Author: T. Moudiki. A few weeks ago, I introduced a Forecasting API that I deployed on Heroku. Under the hood, this API is built on top of ahead (and through Python packages rpy2 and Flask); an R package for univariate and multivariate time series forecasting. As of October 13th, 2021, 5 forecasting methods are implemented in ahead: armagarchf: univariate time series forecasting method using simulation of an ARMA(1, 1) – GARCH(1, 1) dynrmf: univariate time series forecasting method adapted from forecast::nnetar to support any Statistical/Machine learning model (such as Ridge Regression, Random Forest, Support Vector Machines, etc.) eatf: ... Read More
`crossvalidation` and random search for calibrating support vector machines
Feed: R-bloggers. Author: T. Moudiki. options( repos = c(techtonique = 'https://techtonique.r-universe.dev', CRAN = 'https://cloud.r-project.org') ) install.packages("crossvalidation") library(crossvalidation) library(e1071) transforming model response into a factor y <- as.factor(as.numeric(iris$Species)) explanatory variables X <- as.matrix(iris[, c("Sepal.Length", "Sepal.Width", "Petal.Length", "Petal.Width")]) OF <- function(xx) { res <- crossvalidation::crossval_ml( x = X, y = y, k = 5, repeats = 3, p = 0.8, fit_func = e1071::svm, predict_func = predict, packages = "e1071", fit_params = list(gamma = xx[1], cost = xx[2]) ) # default metric is accuracy return(res$mean_training) } There are many, many ways to maximize this objective function. simulation of SVM’s hyperparameters’ matrix n_points <- ... Read More
parallel grid search cross-validation using `crossvalidation`
Feed: R-bloggers. Author: T. Moudiki. options(repos = c( techtonique = 'https://techtonique.r-universe.dev', CRAN = 'https://cloud.r-project.org')) install.packages("crossvalidation") library(crossvalidation) library(randomForest) library(microbenchmark) set.seed(123) n <- 1000 ; p <- 10 X <- matrix(rnorm(n * p), n, p) y <- rnorm(n) tuning_grid <- base::expand.grid(mtry = c(2, 3, 4), ntree = c(100, 200, 300)) n_params <- nrow(tuning_grid) print(tuning_grid) n_cores <- 4 Sequential f1 <- function() base::lapply(1:n_params, function(i) crossvalidation::crossval_ml( x = X, y = y, k = 5, repeats = 3, fit_func = randomForest::randomForest, predict_func = predict, packages = "randomForest", fit_params = list(mtry = tuning_grid[i, "mtry"], ntree = tuning_grid[i, "ntree"]) )) Parallel 1 f2 <- function() parallel::mclapply(1:n_params, ... Read More
Recent Comments