predict.graphclass: Prediction function for graph classifier

View source: R/predict.graphclass.r

predict.graphclassR Documentation

Prediction function for graph classifier

Description

Given an object of type graphclass, this function obtains the fitted classes for a new data.

Usage

## S3 method for class 'graphclass'
predict(object, newdata, type = c("class", "prob", "error"), Ytest, ...)

Arguments

type

Indicates the type of response: class for class predictions, prob for predicted probabilities, error for misclassification error (if Ytest is provided).

Ytest

If type = "error", true classes to compare.

gc

A trained graph classifier object

X

A matrix containing rows with vectorized upper triangular adjacency matrices (column-major order)

Value

A vector containing the predicted classes.

Examples

data(COBRE.data)
X <- COBRE.data$X.cobre
Y <- COBRE.data$Y.cobre

#Split into train and test
test <- runif(length(Y)) <= 0.1
gc <- graphclass(X = X[!test, ], Y = factor(Y[!test]), type = "intersection",
               lambda = 1e-4, rho = 1, gamma = 1e-5)
               
gc.test <- predict(gc, X[test, ]) 
predict(gc, X[test, ], "error", Ytest = Y[test])

jesusdaniel/graphclass documentation built on Aug. 10, 2022, 3:10 p.m.