select_landmarks() chooses a representative subset of observations and
returns its row indices together with the complementary query rows. Selection
is deterministic for a fixed seed. It uses standardized low-dimensional
features formed from up to four original columns and four seeded random
projections, then spreads landmarks across projection quantiles. For at most
2,000 landmarks, quantile candidates are reduced with greedy farthest-point
sampling; larger selections use the projection-quantile rows directly. The
function selects rows only: it does not fit an embedding or project queries.
Arguments
- data
Numeric matrix, data frame, or
float::float32matrix.- landmarks
TRUEfor an automatic count, a fraction in(0, 1), a landmark count, or explicit row indices.- seed
Random seed used by projection-based landmark selection.
- n.cores
Number of CPU cores used for float32 selection features.
Value
A fastEmbedR_landmark_selection object. indices identifies the
landmark/reference rows, query_indices is its disjoint complement, and
the remaining fields record the input dimensions, selected fraction,
selection method, and seed.
Details
With landmarks = TRUE, the automatic count is all rows for at
most three observations, approximately half the rows up to 80 observations,
at least 80 rows up to 1,000 observations, and at least 300 rows for larger
data. Above 80 observations, the size grows as
ceiling(7 * sqrt(nrow(data))) and never reaches the full data size.
A scalar in (0, 1) selects ceiling(nrow(data) * landmarks) rows. A
scalar of at least one must be a whole-number count. A vector supplies
explicit
row indices, which are sorted and deduplicated. Requesting at least all
rows returns every row as the reference and an empty query set.
Examples
x <- scale(as.matrix(iris[, 1:4]))
selection <- select_landmarks(x, landmarks = 0.5, seed = 1)
selection$indices
#> [1] 7 12 14 15 16 17 19 22 23 24 26 32 33 37 38 42 44 46 47
#> [20] 48 51 52 60 61 62 63 64 65 68 71 73 74 76 77 78 82 83 84
#> [39] 85 86 88 90 94 96 99 102 103 104 106 107 109 110 113 114 115 118 119
#> [58] 120 122 123 124 125 126 128 129 130 131 132 135 136 138 142 145 147 149