Parameters' description can be found at https://techtonique.github.io/nnetsauce/

CustomRegressor(
  obj,
  n_hidden_features = 5L,
  activation_name = "relu",
  a = 0.01,
  nodes_sim = "sobol",
  bias = TRUE,
  dropout = 0,
  direct_link = TRUE,
  n_clusters = 2L,
  cluster_encode = TRUE,
  type_clust = "kmeans",
  col_sample = 1,
  row_sample = 1,
  seed = 123L,
  backend = c("cpu", "gpu", "tpu")
)

Examples


set.seed(123)
n <- 50 ; p <- 3
X <- matrix(rnorm(n * p), n, p) # no intercept!
y <- rnorm(n)

(index_train <- base::sample.int(n = nrow(X),
                                 size = floor(0.8*nrow(X)),
                                 replace = FALSE))
#>  [1] 47 23  3  9 39 30 31 45 50 36 34 22 28 29 33 19 12 21 17 44 40 48 25 18 15
#> [26] 46 37 35 27 32  6 10  8 49 16 41 13  4 20 14
X_train <- X[index_train, ]
y_train <- y[index_train]
X_test <- X[-index_train, ]
y_test <- y[-index_train]

obj <- sklearn$linear_model$ElasticNet()
obj2 <- CustomRegressor(obj)
obj2$fit(X_train, y_train)
#> Error in py_call_impl(callable, call_args$unnamed, call_args$named): AttributeError: 'list' object has no attribute 'dtype'
#> Run `reticulate::py_last_error()` for details.
print(obj2$score(X_test, y_test))
#> Error in py_call_impl(callable, call_args$unnamed, call_args$named): sklearn.exceptions.NotFittedError: This ElasticNet instance is not fitted yet. Call 'fit' with appropriate arguments before using this estimator.
#> Run `reticulate::py_last_error()` for details.