RandomBagClassifier.Rd
Parameters description can be found at https://techtonique.github.io/nnetsauce/
RandomBagClassifier(
obj,
n_estimators = 50L,
n_hidden_features = 5L,
activation_name = "relu",
a = 0.01,
nodes_sim = "sobol",
bias = TRUE,
dropout = 0,
direct_link = FALSE,
n_clusters = 2L,
cluster_encode = TRUE,
type_clust = "kmeans",
col_sample = 1,
row_sample = 1,
n_jobs = NULL,
seed = 123L,
verbose = 1L,
backend = c("cpu", "gpu", "tpu")
)
library(datasets)
X <- as.matrix(iris[, 1:4])
y <- as.integer(iris[, 5]) - 1L
(index_train <- base::sample.int(n = nrow(X),
size = floor(0.8*nrow(X)),
replace = FALSE))
#> [1] 127 41 8 52 67 2 65 135 29 20 124 80 7 45 76 25 91 94
#> [19] 150 12 148 71 121 15 83 49 107 39 115 87 35 6 129 4 74 81
#> [37] 48 130 53 146 108 112 101 14 28 119 9 33 46 64 19 98 1 92
#> [55] 147 133 68 90 75 5 100 120 103 69 61 23 149 63 125 128 110 136
#> [73] 145 18 117 72 144 11 57 56 132 96 86 36 3 138 79 118 40 109
#> [91] 37 24 38 139 66 73 10 142 85 134 59 32 143 55 54 70 31 102
#> [109] 50 89 43 113 82 116 17 141 88 62 13 34
X_train <- X[index_train, ]
y_train <- y[index_train]
X_test <- X[-index_train, ]
y_test <- y[-index_train]
obj <- sklearn$tree$DecisionTreeClassifier()
obj2 <- RandomBagClassifier(obj, n_estimators=50L,
n_hidden_features=5L)
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): AssertionError: no estimator found in `RandomBag` ensemble
#> Run `reticulate::py_last_error()` for details.
print(obj2$predict_proba(X_test))
#> Error in py_call_impl(callable, call_args$unnamed, call_args$named): AssertionError: no estimator found in `RandomBag` ensemble
#> Run `reticulate::py_last_error()` for details.