# NOT RUN {
library(elmNNRcpp)
#-----------
# Regression
#-----------
data(Boston, package = 'KernelKnn')
Boston = as.matrix(Boston)
dimnames(Boston) = NULL
x = Boston[, -ncol(Boston)]
y = matrix(Boston[, ncol(Boston)], nrow = length(Boston[, ncol(Boston)]), ncol = 1)
out_regr = elm_train(x, y, nhid = 20, actfun = 'purelin', init_weights = 'uniform_negative')
pr_regr = elm_predict(out_regr, x)
#---------------
# Classification
#---------------
data(ionosphere, package = 'KernelKnn')
x_class = ionosphere[, -c(2, ncol(ionosphere))]
x_class = as.matrix(x_class)
dimnames(x_class) = NULL
y_class = as.numeric(ionosphere[, ncol(ionosphere)])
y_class_onehot = onehot_encode(y_class - 1) # class labels should begin from 0
out_class = elm_train(x_class, y_class_onehot, nhid = 20, actfun = 'relu')
pr_class = elm_predict(out_class, x_class, normalize = TRUE)
# }
Run the code above in your browser using DataLab