Instead of choosing new projections at random like the grand tour, the guided tour always tries to find a projection that is more interesting than the current projection.

guided_tour(
  index_f,
  d = 2,
  cooling = 0.99,
  max.tries = 25,
  max.i = Inf,
  search_f = search_geodesic,
  n_jellies = 30,
  n_sample = 100,
  alpha = 0.5,
  ...
)

Arguments

index_f

the index function to optimise.

d

target dimensionality

cooling

the amount the size of the search window should be adjusted by after each step

max.tries

the maximum number of unsuccessful attempts to find a better projection before giving up

max.i

the maximum index value, stop search if a larger value is found

search_f

the search strategy to use: search_geodesic, search_better, search_better_random, search_polish. Default is search_geodesic.

n_jellies

only used for search_jellyfish, the number of jellyfish to use

n_sample

number of samples to generate if search_f is search_polish

alpha

the initial size of the search window, in radians

...

arguments sent to the search_f

Details

Currently the index functions only work in 2d.

Usually, you will not call this function directly, but will pass it to a method that works with tour paths like animate, save_history or render.

See also

cmass, holes and lda_pp for examples of index functions. The function should take a numeric matrix and return a single number, preferably between 0 and 1. search_geodesic, search_better, search_better_random for different search strategies

Examples

flea_std <- apply(flea[,1:6], 2, function(x) (x-mean(x))/sd(x))
animate_xy(flea_std, guided_tour(holes()), sphere = TRUE)
#> Target: 0.844, 2.7% better 
#> Using half_range 3.8


# \donttest{
animate_xy(flea_std, guided_tour(holes(), search_f = search_better_random), sphere = TRUE)
#> Target: 0.809, try: 1, probabilistic accept p = 0.090
#> Using half_range 3.8


animate_dist(flea_std, guided_tour(holes(), 1), sphere = TRUE)
#> Target: 0.834, 16.9% better 
#> Using half_range 3.8


animate_xy(flea_std, guided_tour(lda_pp(flea$species)), sphere = TRUE, col = flea$species)
#> Target: 0.791, 38.6% better 
#> Using half_range 3.8


# save_history is particularly useful in conjunction with the
# guided tour as it allows us to look at the tour path in many different
# ways
f <- flea_std[, 1:3]
tries <- replicate(5, save_history(f, guided_tour(holes())), simplify = FALSE)
#> Target: 0.883, 32.9% better 
#> Target: 0.972, 10.1% better 
#> No better bases found after 25 tries.  Giving up.
#> Final projection: 
#>  0.973   0.150  
#> -0.006   0.775  
#> -0.231   0.613  
#> Target: 0.968, 5.6% better 
#> Target: 0.970, 0.2% better 
#> Target: 0.972, 0.2% better 
#> No better bases found after 25 tries.  Giving up.
#> Final projection: 
#> -0.959  -0.158  
#> -0.274   0.742  
#>  0.079   0.652  
#> Target: 0.904, 24.0% better 
#> Target: 0.970, 7.4% better 
#> Target: 0.972, 0.2% better 
#> No better bases found after 25 tries.  Giving up.
#> Final projection: 
#>  0.776   0.601  
#> -0.373   0.683  
#> -0.508   0.416  
#> Target: 0.814, 9.0% better 
#> Target: 0.967, 18.7% better 
#> Target: 0.972, 0.6% better 
#> No better bases found after 25 tries.  Giving up.
#> Final projection: 
#> -0.748  -0.628  
#>  0.390  -0.678  
#>  0.537  -0.382  
#> Target: 0.738, 12.7% better 
#> Target: 0.909, 23.2% better 
#> Target: 0.972, 6.8% better 
#> No better bases found after 25 tries.  Giving up.
#> Final projection: 
#>  0.670   0.713  
#> -0.501   0.640  
#> -0.548   0.286  
# }