Skip to main content

RcfConfig

Struct RcfConfig 

Source
#[non_exhaustive]
pub struct RcfConfig { pub num_trees: usize, pub sample_size: usize, pub time_decay: f64, pub seed: Option<u64>, pub num_threads: Option<usize>, pub initial_accept_fraction: f64, pub feature_scales: Option<Vec<f64>>, }
Expand description

Validated forest hyperparameters (dimension is encoded separately at the type level).

§Examples

use anomstream_core::{ForestBuilder, RcfConfig};

let builder = ForestBuilder::<4>::new()
    .num_trees(50)
    .sample_size(64);
let cfg: &RcfConfig = builder.config();
assert_eq!(cfg.num_trees, 50);
cfg.validate().unwrap();

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§num_trees: usize

Number of trees in the forest (num_trees).

§sample_size: usize

Maximum reservoir size per tree (num_samples_per_tree).

§time_decay: f64

Time-decay factor applied to reservoir sampling weights. A value of 0.0 restores strict uniform sampling; positive values bias the reservoir toward recent points. Default resolved by ForestBuilder is 0.1 / sample_size, matching the AWS Java CompactSampler reference.

§seed: Option<u64>

Optional deterministic seed; None falls back to entropy.

§num_threads: Option<usize>

Optional dedicated rayon thread pool size for the parallel cargo feature. None means “use rayon’s global pool” (configurable via the RAYON_NUM_THREADS env var). Some(n) builds a per-forest rayon::ThreadPool of n workers so callers can isolate this forest from the rest of the application’s rayon workload. Ignored without parallel.

§initial_accept_fraction: f64

Warmup admission fraction forwarded to every per-tree crate::ReservoirSampler. See that type’s module-level docs for semantics. 1.0 disables the gate; smaller values ramp admission during the cold-start period so the reservoir is less dominated by the first few stream entries.

§feature_scales: Option<Vec<f64>>

Optional per-dimension multiplicative weights applied to every point before it reaches the forest’s hot paths (update, score, attribution, bootstrap, delete_by_value). Length must match the forest’s compile-time dimension D.

Intended for per-feature scale normalisation: when different input dimensions have wildly different dynamic ranges (packet-rate in [10², 10⁶], protocol-mix ratios in [0, 1], entropy in [0, 8] bits), a naive random cut weights each dimension by its raw range. Pre-scaling with 1 / stddev[d] recovers a unit-variance input space where every dim pulls its weight. For full z-score normalisation the caller should still mean-centre upstream — feature_scales is a weight, not a full affine transform.

None keeps the classic “forest sees the raw caller point” behaviour. The field is #[serde(default)] so old snapshots deserialise without migration.

Implementations§

Source§

impl RcfConfig

Source

pub fn validate(&self) -> RcfResult<()>

Validate the configuration against the AWS hyperparameter bounds. The forest’s compile-time dimension D is checked separately via Self::validate_dimension so non-const callers can apply the AWS bounds without instantiating a generic.

§Errors

Returns RcfError::InvalidConfig with the offending parameter when any bound is violated.

Source

pub fn validate_feature_scales_dimension(&self, d: usize) -> RcfResult<()>

Validate the declared RcfConfig::feature_scales against a target per-point dimension d. When feature_scales is None, the check is a no-op.

§Errors

Returns RcfError::DimensionMismatch when the scales vector length does not equal d.

Source

pub fn validate_dimension(dimension: usize) -> RcfResult<()>

Validate the compile-time dimension D against the AWS feature_dim bounds. Called by ForestBuilder::build so every user-facing entry point gates on the AWS limits.

§Errors

Returns RcfError::InvalidConfig when D is outside [MIN_DIMENSION, MAX_DIMENSION].

Trait Implementations§

Source§

impl Clone for RcfConfig

Source§

fn clone(&self) -> RcfConfig

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for RcfConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for RcfConfig

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for RcfConfig

Source§

fn eq(&self, other: &RcfConfig) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for RcfConfig

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for RcfConfig

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,