Skip to main content

CorpusFeatures

Struct CorpusFeatures 

Source
pub struct CorpusFeatures {
    pub n_items: usize,
    pub n_categories: usize,
    pub dim: usize,
    pub mean_members_per_category: f64,
    pub category_size_entropy: f64,
    pub mean_sparsity: f64,
    pub axis_utilization_entropy: f64,
    pub noise_estimate: f64,
    pub mean_intra_category_similarity: f64,
    pub mean_inter_category_similarity: f64,
    pub category_separation_ratio: f64,
}
Expand description

Low-dimensional profile of a corpus. Computed once per corpus; fed into any MetaModel to predict the pipeline config that’s likely to work best on it.

Fields§

§n_items: usize

Total item count.

§n_categories: usize

Unique category count.

§dim: usize

Embedding dimensionality.

§mean_members_per_category: f64

n_items / n_categories.

§category_size_entropy: f64

Shannon entropy of the category-size distribution, normalized to [0, 1] by dividing by log(n_categories). High = balanced category sizes; low = heavily skewed.

§mean_sparsity: f64

Mean per-item active-axis fraction: |active axes| / dim, averaged over items. An axis is active when |v_i| > active_threshold.

§axis_utilization_entropy: f64

Entropy of how often each axis is active across the corpus, normalized by log(dim). High = all axes used similarly; low = a few axes dominate.

§noise_estimate: f64

Median of |v_i| across inactive entries (|v_i| ≤ threshold), averaged across items. A proxy for the noise floor.

§mean_intra_category_similarity: f64

Mean intra-category cosine similarity in embedding space. High = items within a category are tightly clustered.

§mean_inter_category_similarity: f64

Mean inter-category cosine similarity in embedding space. High = categories overlap heavily; low = categories are semantically distinct.

§category_separation_ratio: f64

mean_intra / max(mean_inter, eps). A ratio-based separation signal: values > 1 mean categories separate well in embedding space; values near 1 mean the corpus is difficult to partition.

Implementations§

Source§

impl CorpusFeatures

Source

pub fn feature_names() -> [&'static str; 10]

Stable feature names aligned with Self::to_vec. Useful for logging, feature importance reports, and CSV headers.

Note: category_separation_ratio is deliberately excluded — it’s a derived ratio of two features already named here, so including it would double-count under any distance metric. See Self::to_vec.

Source

pub fn to_vec(&self) -> [f64; 10]

Fixed-length flattened representation in the order declared by Self::feature_names. Suitable as input to any nearest-neighbor or regression meta-model. category_separation_ratio is intentionally excluded because it’s a derived ratio of two features already in the vector — keeping it in would double-count.

Source

pub fn extract( categories: &[String], embeddings: &[Vec<f64>], ) -> Result<Self, String>

Extract features from a corpus using default Laplacian config (for the active_threshold used in sparsity/noise estimation).

Returns an error if the inputs are invalid (empty corpus, mismatched lengths, zero-dim embeddings, or ragged rows).

Source

pub fn extract_with_threshold( categories: &[String], embeddings: &[Vec<f64>], active_threshold: f64, ) -> Result<Self, String>

Extract features with an explicit active-axis threshold. Use this when you want feature values comparable across different Laplacian configurations.

Returns an error if the inputs are invalid (empty corpus, mismatched lengths, zero-dim embeddings, or ragged rows).

Trait Implementations§

Source§

impl Clone for CorpusFeatures

Source§

fn clone(&self) -> CorpusFeatures

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for CorpusFeatures

Source§

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

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

impl<'de> Deserialize<'de> for CorpusFeatures

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 Serialize for CorpusFeatures

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

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more