groupPredict: Group Predict

Description Usage Arguments Value Author(s) Examples

View source: R/groupPredict.r

Description

This function is used to predict the subtype of new patients.

Usage

1
groupPredict(train, test, groups, K=20, alpha=0.5, t=20, method=1)

Arguments

train

Training data. Has the same number of view and columns as test data.

test

Test data. Has the same number of view and columns as training data.

groups

The label for the training data.

K

Number of neighbors.

alpha

Hyperparameter used in constructing similarity network.

t

Number of iterations.

method

A indicator of which method to use to predict the label. method = 0 means to use local and global consistency; method = 1 means to use label propagation.

Value

Returns the prediction of which group the test data belongs to.

Author(s)

Dr. Anna Goldenberg, Bo Wang, Aziz Mezlini, Feyyaz Demir

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# Provide an example of predicting the new labels with label propagation

# Load views into list "dataL" and the cluster assignment into vector "label"
data(dataL)
data(label)

# Create the training and test data
n = floor(0.8*length(label)) # number of training cases
trainSample = sample.int(length(label), n)
train = lapply(dataL, function(x) x[trainSample, ]) # Use the first 150 samples for training
test = lapply(dataL, function(x) x[-trainSample, ]) # Test the rest of the data set
groups = label[trainSample]

# Set the other
K = 20
alpha = 0.5
t = 20
method = TRUE

# Apply the prediction function to the data
newLabel = groupPredict(train,test,groups,K,alpha,t,method)

# Compare the prediction accuracy
accuracy = sum(label[-trainSample] == newLabel[-c(1:n)])/(length(label) - n)

SNFtool documentation built on June 11, 2021, 9:06 a.m.