FeatureExporter

Struct FeatureExporter 

Source
pub struct FeatureExporter { /* private fields */ }
Expand description

Feature exporter for aprender format

Implementations§

Source§

impl FeatureExporter

Source

pub fn new(format: ExportFormat) -> Self

Create a new feature exporter with specified format

§Arguments
  • format - Export format (Json, Binary, or Parquet)
§Examples
use organizational_intelligence_plugin::export::{FeatureExporter, ExportFormat};

let exporter = FeatureExporter::new(ExportFormat::Json);
Source

pub fn to_matrix(features: &[CommitFeatures]) -> Result<Matrix<f32>>

Convert CommitFeatures to aprender Matrix

§Arguments
  • features - Slice of CommitFeatures to convert
§Returns
  • Ok(Matrix<f32>) with shape [n_samples, FEATURE_DIMENSION]
  • Err if features slice is empty
§Examples
use organizational_intelligence_plugin::export::FeatureExporter;
use organizational_intelligence_plugin::features::CommitFeatures;

let features = vec![
    CommitFeatures {
        defect_category: 0,
        files_changed: 2.0,
        lines_added: 10.0,
        lines_deleted: 5.0,
        complexity_delta: 0.0,
        timestamp: 1700000000.0,
        hour_of_day: 14,
        day_of_week: 2,
        ..Default::default()
    },
];

let matrix = FeatureExporter::to_matrix(&features).unwrap();
assert_eq!(matrix.n_rows(), 1);
assert_eq!(matrix.n_cols(), 14);  // NLP-014: 14 dimensions
Source

pub fn encode_label(category: DefectCategory) -> u8

Encode DefectCategory to label index (0-17)

§Arguments
  • category - DefectCategory to encode
§Returns
  • Label index (0-17)
§Examples
use organizational_intelligence_plugin::export::FeatureExporter;
use organizational_intelligence_plugin::classifier::DefectCategory;

let label = FeatureExporter::encode_label(DefectCategory::MemorySafety);
assert_eq!(label, 0);

let label = FeatureExporter::encode_label(DefectCategory::TraitBounds);
assert_eq!(label, 17);
Source

pub fn decode_label(label: u8) -> Result<DefectCategory>

Decode label index back to DefectCategory

§Arguments
  • label - Label index (0-17)
§Returns
  • Ok(DefectCategory) if label is valid
  • Err if label is out of range
§Examples
use organizational_intelligence_plugin::export::FeatureExporter;
use organizational_intelligence_plugin::classifier::DefectCategory;

let category = FeatureExporter::decode_label(0).unwrap();
assert_eq!(category, DefectCategory::MemorySafety);

let result = FeatureExporter::decode_label(18);
assert!(result.is_err());
Source

pub fn encode_labels(categories: &[DefectCategory]) -> Vec<u8>

Encode multiple DefectCategories to label vector

§Arguments
  • categories - Slice of DefectCategories
§Returns
  • Vector of label indices
Source

pub fn category_names() -> Vec<String>

Get all category names in label order

§Returns
  • Vector of category names indexed by label
Source

pub fn export( &self, features: &[CommitFeatures], categories: &[DefectCategory], ) -> Result<ExportedDataset>

Export features and labels to ExportedDataset

§Arguments
  • features - CommitFeatures to export
  • categories - Corresponding DefectCategories
§Returns
  • Ok(ExportedDataset) with features and labels
  • Err if lengths mismatch or empty input
Source

pub fn save<P: AsRef<Path>>( &self, dataset: &ExportedDataset, path: P, ) -> Result<()>

Save exported dataset to file

§Arguments
  • dataset - ExportedDataset to save
  • path - Output file path
§Returns
  • Ok(()) if successful
  • Err if write fails
Source

pub fn load<P: AsRef<Path>>( path: P, format: ExportFormat, ) -> Result<ExportedDataset>

Load exported dataset from file

§Arguments
  • path - Input file path
  • format - Format to expect
§Returns
  • Ok(ExportedDataset) if successful
  • Err if read/parse fails
Source

pub fn to_aprender_matrix(dataset: &ExportedDataset) -> Result<Matrix<f32>>

Convert ExportedDataset to aprender Matrix

§Arguments
  • dataset - ExportedDataset to convert
§Returns
  • Ok(Matrix<f32>) feature matrix

Trait Implementations§

Source§

impl Default for FeatureExporter

Source§

fn default() -> Self

Returns the “default value” for a type. 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> 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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
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> 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
Source§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,