Description Usage Arguments Value Examples
Function that train a neural network on the training data and gets the correct clusters and weights for making predictions
1 | fn.train_amnfis(df, X, d, formula, n_clusters)
|
df |
input dataframe with the training data. Should also contains the class column |
X |
input numeric matrix which contains the input data without the class column |
d |
input numeric vector with correct classes for the training data |
formula |
input formula specifying which are the descriptors and which is the class column in the df. i.e V9~. |
n_clusters |
the number of clusters to find |
object with the best centroids and the best parameters for the network (weights)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | library(mlbench)
library(dplyr)
library(caret)
data("PimaIndiansDiabetes")
pima_all <- PimaIndiansDiabetes %>% mutate(diabetes = ifelse(diabetes == "pos", 1, 0))
## split the data to get the training set
pima_train_index <- createDataPartition(y = pima_all$diabetes, p = 0.7989, list = FALSE, times = 1)
df.pima_train <- pima_all[pima_train_index, ]
## get all the columns but not the class
mat.pima_train <- as.matrix(df.pima_train[,1:8])
vec.pima_out_train <- df.pima_train$diabetes
## this instruction get the rigth parameters to make predictions on the test set
obj.res_pima <- fn.train_amnfis(df=df.pima_train, X=mat.pima_train, d=vec.pima_out_train, formula=diabetes~., n_clusters=8)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.