exhaustive.search: Exhaustive search

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

Description

The algorithm for searching atrribute subset space.

Usage

1

Arguments

attributes

a character vector of all attributes to search in

eval.fun

a function taking as first parameter a character vector of all attributes and returning a numeric indicating how important a given subset is

Details

The algorithm searches the whole attribute subset space in breadth-first order.

Value

A character vector of selected attributes.

Author(s)

Piotr Romanski

See Also

forward.search, backward.search, best.first.search, hill.climbing.search

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
  library(rpart)
  data(iris)
  
  evaluator <- function(subset) {
    #k-fold cross validation
    k <- 5
    splits <- runif(nrow(iris))
    results = sapply(1:k, function(i) {
      test.idx <- (splits >= (i - 1) / k) & (splits < i / k)
      train.idx <- !test.idx
      test <- iris[test.idx, , drop=FALSE]
      train <- iris[train.idx, , drop=FALSE]
      tree <- rpart(as.simple.formula(subset, "Species"), train)
      error.rate = sum(test$Species != predict(tree, test, type="c")) / nrow(test)
      return(1 - error.rate)
    })
    print(subset)
    print(mean(results))
    return(mean(results))
  }
  
  subset <- exhaustive.search(names(iris)[-5], evaluator)
  f <- as.simple.formula(subset, "Species")
  print(f)

  

Example output

OpenJDK 64-Bit Server VM warning: Can't detect initial thread stack location - find_vma failed
[1] "Sepal.Length"
[1] 0.7311724
[1] "Sepal.Width"
[1] 0.5237945
[1] "Petal.Length"
[1] 0.9449967
[1] "Petal.Width"
[1] 0.9533575
[1] "Sepal.Length" "Sepal.Width" 
[1] 0.6929157
[1] "Sepal.Length" "Petal.Length"
[1] 0.9325456
[1] "Sepal.Length" "Petal.Width" 
[1] 0.959846
[1] "Sepal.Width"  "Petal.Length"
[1] 0.9312038
[1] "Sepal.Width" "Petal.Width"
[1] 0.9527244
[1] "Petal.Length" "Petal.Width" 
[1] 0.9376265
[1] "Sepal.Length" "Sepal.Width"  "Petal.Length"
[1] 0.9314532
[1] "Sepal.Length" "Sepal.Width"  "Petal.Width" 
[1] 0.9505012
[1] "Sepal.Length" "Petal.Length" "Petal.Width" 
[1] 0.9281088
[1] "Sepal.Width"  "Petal.Length" "Petal.Width" 
[1] 0.9493737
[1] "Sepal.Length" "Sepal.Width"  "Petal.Length" "Petal.Width" 
[1] 0.9265963
Species ~ Sepal.Length + Petal.Width
<environment: 0x3dc04c0>
Warning message:
system call failed: Cannot allocate memory 

FSelector documentation built on May 2, 2019, 4:52 p.m.