RBFNN_predict: Predict using a Radial Basis Function Neural Network.

Description Usage Arguments Value Examples

View source: R/RBFNN.R

Description

Predict using a Radial Basis Function Neural Network.

Usage

1
RBFNN_predict(model, X, centroids, stds, inputType = "original_dataset")

Arguments

model

The trained RBFNN.

X

original dataset, distance matrix or gaussian kernel matrix.

centroids

centroids of the model.

stds

standard deviations of each RBF.

inputType

type of X. Available types: original_dataset (original dataset), distance_matrix (Euclidean distance matrix ) and kernel_matrix (Gaussian kernel matrix).

Value

The predicted labels (in classification) or the value (in regression).

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
data(iris)
iris <- iris
## Random permutation because the labels are ordered and therefore the accuracy would not
## be correct (only for this dataset).
iris <- iris[sample(nrow(iris)), ]

dataset <- iris[, 1:4]
labels <- iris[, 5]

X_train <- dataset[1:100, ]
y_train <- labels[1:100]
X_test <- dataset[101:150, ]
y_test <- labels[101:150]

neurons <- 10
seed_val <- 1
RBFNN <- RBFNN_train(as.matrix(X_train), as.matrix(y_train), neurons, seed_val)

model <- RBFNN$model
centroids <- RBFNN$centroids
stds <- RBFNN$stds

predictions <- RBFNN_predict(model, X_test, centroids, stds)
table(predictions, y_test)
accuracy <- sum(diag(table(predictions, y_test)))/nrow(X_test)

xmartin46/RBFNN documentation built on Jan. 1, 2021, 1:43 p.m.