kmeans_label_rematch: kmeans_label_rematch

Description Usage Arguments Value Examples

View source: R/kmeans_label_rematch.R

Description

match the true label based on the label existed

Usage

1
kmeans_label_rematch(Y_train, Y_actual, Y_test = NULL, Y_test_actual = NULL)

Arguments

Y_train

label got from the kmeans_cluster from training data

Y_actual

the actual label

Y_test

predict label for testing data (optional)

Y_test_actual

the actual test label(optional)

Value

the vector of matched label and training_accuracy. If Y_test_actual and Y_test are not null, return the matched test label and testing accuracy respectively.

Examples

1
2
3
4
5
6
7
8
X1 = c(1,3,2,2,1,2,2)
X2 = c(2,5,1,1,1,1,1)

# Function will determine match label based on majority vote
# Cluster label 1 will match 2
# cluster label 3 will match 5
# Cluster label 2 will match 1
kmeans_label_rematch(X1,X2)

zhaodyleo/Kmeans documentation built on Dec. 23, 2021, 9:18 p.m.