Learn R Programming

FSinR (version 1.0.8)

sa: Simulated Annealing

Description

The sa method KirkpatrickGelattVecchi1983FSinR starts with a certain set of features and in each iteration modifies an element of the previous feature vector and decreases the temperature. If the energy of the new feature vector is better than that of the old vector, it is accepted and moved towards it, otherwise it is moved towards the new vector according to an acceptance probability. The algorithm ends when the minimum temperature has been reached. Additionally, a number of internal iterations can be performed within each iteration of the algorithm. In this case, the same temperature value of the outer iteration is used for the inner iterations

Usage

sa(
  data,
  class,
  featureSetEval,
  start = sample(0:1, ncol(data) - 1, replace = TRUE),
  temperature = 1,
  temperature_min = 0.01,
  reduction = 0.6,
  innerIter = 1,
  verbose = FALSE
)

Arguments

data
  • A data frame with the features and the class of the examples

class
  • The name of the dependent variable

featureSetEval
  • The measure for evaluate features

start
  • Binary vector with the set of initial features

temperature
  • Temperature initial

temperature_min
  • Temperature to stops in the outer loop

reduction
  • Temperature reduction in the outer loop

innerIter
  • Number of iterations of inner loop. By default no inner iterations are established

verbose
  • Print the partial results in each iteration

Value

A list is returned containing for each repetition of the algorithm:

bestFeatures

A vector with all features. Selected features are marked with 1, unselected features are marked with 0

bestFitness

Evaluation measure obtained with the feature selection

initialVector

The vector with which the algorithm started

initialEnergy

The evaluation measure of the initial vector

traceOutter

Matrix with the results of each iteration. Contains the number of the iteration, the value of the temperature, the subset of features of the iteration, its evaluation measure and whether there has been a movement from the previous iteration to obtain the subset of features in the current iteration.

traceInner

List containing as many lists as outer iterations have been performed. In each iteration of these lists the same values are shown as for traceOutter but referring to each internal iteration.

References

Examples

Run this code
# NOT RUN {
## Simulated Annealing for iris dataset (filter method)
sa(iris, 'Species', roughsetConsistency, temperature = 5, temperature_min=0.01,
   reduction=0.6, verbose=TRUE)
# }

Run the code above in your browser using DataLab