rpuScale {rpud} | R Documentation |
The rpuScale
method performs scaling on SVM training data.
It is not supported in the free rpud
package.
rpuScale(x, y=NULL, scale=TRUE)
x |
a data matrix, a vector, or a sparse matrix (object of class
|
y |
a response vector with one label for each row/component of
|
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 |
rpuScale
returns a list with components:
x |
a scaled version of the |
y |
a scaled version of the |
x.scale |
The lower and upper bounds of the attributes in the scaled |
y.scale |
The lower and upper bounds of the scaled vector |
x.bound |
The lower and upper bounds of the attributes in the original |
y.bound |
The lower and upper bounds of the original |
r2 |
Scaling factor for the mean square error. |
Chi Yau (based on svm
in e1071
by David Meyer)
chi.yau@r-tutor.com
## 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)