computeSupervised | R Documentation |
Perform supervised classification based on the use of a training set.
computeSupervised( data.sample, prototypes, method.name = "K-NN", model = NULL, RclusTool.env = initParameters() )
data.sample |
list containing features, profiles and clustering results. |
prototypes |
data.frame containing the features of each prototype associated to a class. |
method.name |
character vector specifying the supervised algorithm to use. Must be 'K-NN' (K-Nearest Neighbor by default), 'MLP' (MultiLayer Perceptron), 'SVM' (Support Vector Machine) or 'RF' (Random Forest). |
model |
option to predict directly from model |
RclusTool.env |
environment in which all global parameters, raw data and results are stored. |
computeSupervised performs supervised classification based on the use of a training set
The function returns a list containing:
label |
vector of labels. |
summary |
data.frame containing classes summaries (min, max, sum, average, sd). |
nbItems |
number of observations. |
prototypes |
data.frame containing the features of each prototype associated to a class. |
readTrainSet
rep <- system.file("extdata", package="RclusTool") featuresFile <- file.path(rep, "sample_example_features.csv") features <- read.csv(featuresFile, header = TRUE) features$ID <- NULL traindir <- file.path(rep, "train_example") tf <- tempfile() write.table(features, tf, sep=",", dec=".") x <- importSample(file.features=tf, dir.save=dirname(tf)) train <- readTrainSet(traindir) res <- computeSupervised(x, prototypes=train) plot(features[,3], features[,4], type = "p", xlab = "x", ylab = "y", col = res$label, main = "K-Nearest-Neighbor classification")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.