SA: Simulated Annealing for variable selection in classification

Description Usage Arguments Details Value Author(s) References See Also Examples

Description

A set of functions implementing simple variable selection in classification applications using simulated annealing

Usage

1
2
3
4
5
6
SAfun(x, response, eval.fun, Tinit, niter = 100,
      cooling = 0.05, fraction = 0.3, ...)
SAfun2(x, response, eval.fun, Tinit, niter = 100,
       cooling = 0.05, fraction = 0.3, ...)

SAstep(curr.set, maxvar, fraction = .3, size.dev = 1)

Arguments

x

Data matrix: independent variables used by eval.fun

response

Class vector, used by eval.fun

eval.fun

evaluation function. Should take a data matrix, a class vector (or factor), and a subset argument

Tinit

Initial temperature

niter

Maximal number of iterations

cooling

Cooling speed

fraction

Size of the desired subset, as a fraction of the total number of variables

...

Further arguments to the evaluation function

curr.set

Current trial solution

maxvar

The total number of variables to choose from

size.dev

Parameter governing the variability in size of subsequent subsets

Details

Simulated Annealing (SA) starts with a random subset, and proceeds by random moves in the solution space. In this implementation, a new solution may deviate in length at most size.dev variables: at most two variables may be swapped in or out at each step. If a step is an improvement, it is unconditionally accepted. If not, acceptance is a stochastic process depending on the current temperature - with high temperatures, "bad" moves are more likely to be accepted than with low temperatures. The process stops after a predefined number of iterations.

Value

Functions SAfun and SAfun2 both return a list containing the following fields:

best

The best subset

best.q

The quality of the best subset

In addition, the outcome of SAfun2 also contains

qualities

A vector containing quality values of solutions seen throughout the optimization

accepts

A vector containing logicals indicating which solutions were accepted and which were rejected

Author(s)

Ron Wehrens

References

R. Wehrens. "Chemometrics with R - Multivariate Data Analysis in the Natural Sciences and Life Sciences". Springer, Heidelberg, 2011.

See Also

Evaluation, GA

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
if (require("pls")) {
data(gasoline, package = "pls")
## usually more than 50 iterations are needed
SAobj <- SAfun(gasoline$NIR, gasoline$octane,
               eval.fun = pls.cvfun, Tinit = 3,
               fraction = .02, niter = 50, ncomp = 2)
SAobj
} else {
  cat("Package pls not available.\nInstall it by typing 'install.packages(\"pls\")'")
}

ChemometricsWithR documentation built on May 2, 2019, 10:25 a.m.