rpuScale {rpud}R Documentation

Scaling SVM Training Data

Description

The rpuScale method performs scaling on SVM training data. It is not supported in the free rpud package.

Usage

rpuScale(x, y=NULL, scale=TRUE)

Arguments

x

a data matrix, a vector, or a sparse matrix (object of class Matrix provided by the Matrix package, or of class matrix.csr provided by the SparseM package.

y

a response vector with one label for each row/component of x. Can be either a factor (for classification tasks) or a numeric vector (for regression).

scale

It can be a numeric vector or a single logical value. If it is a numeric vector, the first and second vector elements will be the lower and upper bounds of each attributes in the x component after scaling. The third and fourth optional vector elements will be the lower and upper bounds of the y component after scaling. This is ignored if y is of factor type. If scale is a single logical TRUE value, the default scale vector c(0, 1, -1, 1) will be applied.

Value

rpuScale returns a list with components:

x

a scaled version of the x input.

y

a scaled version of the y input.

x.scale

The lower and upper bounds of the attributes in the scaled x.

y.scale

The lower and upper bounds of the scaled vector y.

x.bound

The lower and upper bounds of the attributes in the original x input matrix.

y.bound

The lower and upper bounds of the original y input vector.

r2

Scaling factor for the mean square error.

Author(s)

Chi Yau (based on svm in e1071 by David Meyer)
chi.yau@r-tutor.com

See Also

matrix.csr

Examples

## Not run: 

library(rpud)
library(SparseM)

cadata1.path <- file.path(.path.package(package="rpud"), "runit/data/cadata-sample")
cadata1.data <- read.svm.data(cadata1.path, fac=FALSE)
cadata1.rpusvm <- rpusvm(cadata1.data$x, cadata1.data$y, type=type)
cadata1.fitted <- fitted(cadata1.rpusvm)

cadata1.scaled <- rpuScale(cadata1.data$x, cadata1.data$y)
cadata2.rpusvm <- rpusvm(cadata1.scaled$x, cadata1.scaled$y, type=type, scale=FALSE)
cadata2.fitted <- fitted(cadata2.rpusvm)

cadata1.yrange <- cadata1.scaled$y.bound[2]-cadata1.scaled$y.bound[1]
cadata1.yscale <- cadata1.scaled$y.scale[2]-cadata1.scaled$y.scale[1]

cadata2.fitted.scaled <-
        (cadata2.fitted - cadata1.scaled$y.scale[1])*cadata1.yrange/cadata1.yscale +
        cadata1.scaled$y.bound[1]
all.equal(cadata1.fitted, cadata2.fitted.scaled, tol=50)



## End(Not run)

[Package rpud version 0.7.0 Index]