computeSupervised: Supervised classification

View source: R/supervised.R

computeSupervisedR Documentation

Supervised classification

Description

Perform supervised classification based on the use of a training set.

Usage

computeSupervised(
  data.sample,
  prototypes,
  method.name = "K-NN",
  model = NULL,
  RclusTool.env = initParameters()
)

Arguments

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.

Details

computeSupervised performs supervised classification based on the use of a training set

Value

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.

See Also

readTrainSet

Examples


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")



RclusTool documentation built on May 29, 2024, 5:23 a.m.