isotree.set.reference.points: Set Reference Points to Calculate Distances or Kernels With

View source: R/isoforest.R

isotree.set.reference.pointsR Documentation

Set Reference Points to Calculate Distances or Kernels With

Description

Sets some points as pre-defined landmarks with respect to which distances and/or isolation kernel values will be calculated for arbitrary new points in calls to 'predict' with types '"dist"', '"avg_sep"', '"kernel"'. If any points have already been set as references in the model object, they will be overwritten with the new points passed here.

Be aware that adding reference points requires building a tree indexer.

Usage

isotree.set.reference.points(
  model,
  data,
  with_distances = FALSE,
  nthreads = model$nthreads
)

Arguments

model

An Isolation Forest model (as returned by function isolation.forest) for which reference points for distance and/or kernel calculations will be set.

The object will be modified in-place. If there were any previous references, they will be overwritten with the new ones passed here.

data

Observations to set as reference points for future distance and/or isolation kernel calculations. Same format as for predict.isolation_forest.

with_distances

Whether to pre-calculate node distances (this is required to calculate distance from arbitrary points to the reference points).

Note that reference points for distances can only be set when using 'assume_full_distr=FALSE' (which is the default).

nthreads

Number of parallel threads to use.

Details

Note that points are added in terms of their terminal node indices, but the raw data about them is not kept - thus, calling isotree.add.tree later on a model with reference points requires passing those reference points again to add their node indices to the new tree.

If using 'lazy_serialization=TRUE', and the process fails while setting references (e.g. due to out-of-memory errors), previous references that the model might have had will be lost.

Value

The same 'model' object (as invisible), but now with added reference points that can be used for new distance and/or kernel calculations with respect to other arbitrary points.

See Also

isotree.build.indexer


isotree documentation built on May 29, 2024, 11:24 a.m.