Skip to main content

RandProjOps

Trait RandProjOps 

Source
pub trait RandProjOps {
    // Required methods
    fn project_columns_with_batch_correction_seeded<T>(
        &self,
        target_dim: usize,
        block_size: Option<usize>,
        batch_membership: Option<&[T]>,
        seed: u64,
    ) -> Result<RandColProjOut>
       where T: Sync + Send + Hash + Eq + Clone + ToString;
    fn project_columns_weighted_seeded<T>(
        &self,
        target_dim: usize,
        block_size: Option<usize>,
        batch_membership: Option<&[T]>,
        row_weights: &[f32],
        seed: u64,
    ) -> Result<RandColProjOut>
       where T: Sync + Send + Hash + Eq + Clone + ToString;
    fn partition_columns_to_groups(
        &mut self,
        proj_kn: &DMatrix<f32>,
        num_features: Option<usize>,
        ncols_per_group: Option<usize>,
    ) -> Result<usize>;
    fn assign_group_labels(&mut self, labels: &[usize]);

    // Provided methods
    fn project_columns(
        &self,
        target_dim: usize,
        block_size: Option<usize>,
    ) -> Result<RandColProjOut> { ... }
    fn project_columns_with_batch_correction<T>(
        &self,
        target_dim: usize,
        block_size: Option<usize>,
        batch_membership: Option<&[T]>,
    ) -> Result<RandColProjOut>
       where T: Sync + Send + Hash + Eq + Clone + ToString { ... }
    fn project_columns_weighted<T>(
        &self,
        target_dim: usize,
        block_size: Option<usize>,
        batch_membership: Option<&[T]>,
        row_weights: &[f32],
    ) -> Result<RandColProjOut>
       where T: Sync + Send + Hash + Eq + Clone + ToString { ... }
    fn partition_columns_to_mixed_groups<T>(
        &mut self,
        proj_kn: &DMatrix<f32>,
        num_features: Option<usize>,
        batch_membership: &[T],
        min_batches: usize,
        merge_levels: usize,
    ) -> Result<usize>
       where T: Hash + Eq + Clone { ... }
}

Required Methods§

Source

fn project_columns_with_batch_correction_seeded<T>( &self, target_dim: usize, block_size: Option<usize>, batch_membership: Option<&[T]>, seed: u64, ) -> Result<RandColProjOut>
where T: Sync + Send + Hash + Eq + Clone + ToString,

Seeded variant of RandProjOps::project_columns_with_batch_correction: seed pins the random basis so identical-config runs are byte-identical.

Source

fn project_columns_weighted_seeded<T>( &self, target_dim: usize, block_size: Option<usize>, batch_membership: Option<&[T]>, row_weights: &[f32], seed: u64, ) -> Result<RandColProjOut>
where T: Sync + Send + Hash + Eq + Clone + ToString,

Seeded variant of RandProjOps::project_columns_weighted: seed pins the random basis so identical-config runs are byte-identical.

Source

fn partition_columns_to_groups( &mut self, proj_kn: &DMatrix<f32>, num_features: Option<usize>, ncols_per_group: Option<usize>, ) -> Result<usize>

Assign each column/cell to random group by binary encoding

§Arguments
  • proj_kn - random projection matrix (feature x column/cell)

  • num_features - number of top features (if None, use all of them)

Source

fn assign_group_labels(&mut self, labels: &[usize])

Assign each column to the group of its label.

Provided Methods§

Source

fn project_columns( &self, target_dim: usize, block_size: Option<usize>, ) -> Result<RandColProjOut>

Create K x ncol projection by concatenating data across columns and returns the random basis matrix D x target_dim and the projection result target_dim x N

§Arguments
  • target_dim: target dimensionality
  • block_size: block size for parallel computation
§Output
  • basis: D x K random basis matrix
  • proj: K x N projection results

Uses DEFAULT_PROJECTION_SEED for the basis; for a caller-controlled seed see RandProjOps::project_columns_with_batch_correction_seeded.

Source

fn project_columns_with_batch_correction<T>( &self, target_dim: usize, block_size: Option<usize>, batch_membership: Option<&[T]>, ) -> Result<RandColProjOut>
where T: Sync + Send + Hash + Eq + Clone + ToString,

Create K x ncol projection by concatenating data across columns and returns the random basis matrix D x target_dim and the projection result target_dim x N

§Arguments
  • target_dim: target dimensionality
  • block_size: block size for parallel computation
§Output
  • basis: D x K random basis matrix
  • proj: K x N projection results

Uses DEFAULT_PROJECTION_SEED; delegates to RandProjOps::project_columns_with_batch_correction_seeded.

Source

fn project_columns_weighted<T>( &self, target_dim: usize, block_size: Option<usize>, batch_membership: Option<&[T]>, row_weights: &[f32], ) -> Result<RandColProjOut>
where T: Sync + Send + Hash + Eq + Clone + ToString,

Like project_columns_with_batch_correction but with per-row (per-feature) weights applied to the random basis. Features with weight 0 are excluded from the projection geometry.

Uses DEFAULT_PROJECTION_SEED; delegates to RandProjOps::project_columns_weighted_seeded.

Source

fn partition_columns_to_mixed_groups<T>( &mut self, proj_kn: &DMatrix<f32>, num_features: Option<usize>, batch_membership: &[T], min_batches: usize, merge_levels: usize, ) -> Result<usize>
where T: Hash + Eq + Clone,

Like RandProjOps::partition_columns_to_groups, but bins that hold fewer than min_batches batches merge up the code tree, for at most merge_levels levels (see crate::alg::batch_mixing). min_batches is capped by the number of batches. Returns the number of groups.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§