cluster_classify {GSgalgoR}R Documentation

Distance to centroid classifier function

Description

Given an n x m matrix of centroids, where m are the prototypic centroids with n features, classify new samples according to the distance to the centroids.

Usage

cluster_classify(data, centroid, method = "pearson")

Arguments

data

a data.frame of dimensions n x p with the samples to classify, were n are the same set of features as in the centroids

centroid

a data.frame of dimensions n x m, where each column is a prototypic centroid to classify the samples

method

Character string indicating which method to use to calculate distance to centroid. Options are "pearson" (default), "kendall", or "spearman"

Value

Returns a numeric vector of length p with the class assigned to each sample according to the shortest distance to centroid

Examples


# load example dataset
require(iC10TrainingData)
require(pamr)

data(train.Exp)
data(IntClustMemb)
TrainData <- list(x = train.Exp, y = IntClustMemb)

# Create prototypic centroids
pam <- pamr.train(TrainData)
centroids <- pam$centroids

Class <- cluster_classify(train.Exp, centroids)
table(Class, IntClustMemb)

[Package GSgalgoR version 1.4.0 Index]