Skip to contents

Create a comparison plot showing both PCA and UMAP projections of the same data, making it easy to see how different dimensionality reduction methods reveal anomalies. For large datasets, automatic sampling is applied to improve speed.

Usage

plot_anomaly_projection_all(
  model,
  data,
  method = "mtt",
  contamination = 0.05,
  point_size = 2,
  point_alpha = 0.6,
  umap_n_neighbors = 15,
  umap_min_dist = 0.1,
  sample_rate = 0.05
)

Arguments

model

An isoForest model object

data

The original data (must be numeric)

method

Threshold method for anomaly detection (default: "mtt")

contamination

Contamination rate (only used if method = "contamination")

point_size

Size of points in the plot (default: 2)

point_alpha

Transparency of points (default: 0.6)

umap_n_neighbors

Number of neighbors for UMAP (default: 15)

umap_min_dist

Minimum distance for UMAP (default: 0.1)

sample_rate

Target anomaly rate in the displayed data (default: 0.05). Set to NULL to disable sampling.

Value

A combined ggplot2 object showing both PCA and UMAP projections

Examples

if (FALSE) { # \dontrun{
model <- isoForest(iris[1:4])
comparison_plot <- plot_anomaly_projection_all(model, iris[1:4])
print(comparison_plot)
} # }