gpuSvmPredict {gputools} | R Documentation |
This function classifies points in a dataset with a support vector machine using a GPU. The negative category is represented by -1.f and the positive one by 1.f. The underlying code is adapted from Austin Carpenter's cuSVM which can be found at http://patternsonascreen.net/cuSVM.html
gpuSvmPredict(data, supportVectors, svCoefficients, svOffset, kernelWidth = 0.125, isRegression = FALSE)
data |
a matrix of floating point numbers. Each row will be placed into one of two categories -1.f or 1.f. Note that ncol(data) should equal ncol(supportVectors). |
supportVectors |
a matrix of floating point numbers. Each row of the matrix is a support vector. This matrix can be obtained from gpuSvmTrain, for example. Note that ncol(supportVector) should equal ncol(data). |
svCoefficients |
a vector of floating point numbers representing coefficients corresponding to the support vectors. This vector can be obtained from gpuSvmTrain, for example. Each support vector supportVectors[i,] has coefficient svCoefficients[i]. |
svOffset |
a single floating point number. It is the offset for the prediction function. The offset can be obtained from gpuSvmTrain, for example. |
kernelWidth |
a single floating point number. This is the scalar Gaussian kernel parameter. |
isRegression |
a single logical value indicating if the supportVectors result from regression. |
a vector of nrow(data) entries, each either -1.f or 1.f. Each entry i corresponds to the support vector machine's prediction for the category of data[i,].
Carpenter, Austin, cuSVM: a cuda implementation of support vector classification and regression, http://http://patternsonascreen.net/cuSVM.html
# y is discrete: -1 or 1 and we set isRegression to FALSE y <- round(runif(20, min = 0, max = 1)) for(i in 1:20) { if(y[i] == 0) {y[i] <- -1}} x <- matrix(runif(200), 20, 10) a <- gpuSvmTrain(y, x, isRegression = FALSE) print(a) b <- gpuSvmPredict(x, a$supportVectors, a$svCoefficients, a$svOffset, isRegression = FALSE) print(b) # this time around, y : -1 or 1 and we set isRegression to FALSE y <- runif(20, min = -1, max = 1) x <- matrix(runif(200), 20, 10) a <- gpuSvmTrain(y, x, isRegression = TRUE) print(a) b <- gpuSvmPredict(x, a$supportVectors, a$svCoefficients, a$svOffset, isRegression = TRUE) print(b)