pub struct FeatureExporter { /* private fields */ }Expand description
Feature exporter for aprender format
Implementations§
Source§impl FeatureExporter
impl FeatureExporter
Sourcepub fn new(format: ExportFormat) -> Self
pub fn new(format: ExportFormat) -> Self
Sourcepub fn to_matrix(features: &[CommitFeatures]) -> Result<Matrix<f32>>
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]Errif 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 dimensionsSourcepub fn encode_label(category: DefectCategory) -> u8
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);Sourcepub fn decode_label(label: u8) -> Result<DefectCategory>
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 validErrif 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());Sourcepub fn encode_labels(categories: &[DefectCategory]) -> Vec<u8> ⓘ
pub fn encode_labels(categories: &[DefectCategory]) -> Vec<u8> ⓘ
Sourcepub fn category_names() -> Vec<String>
pub fn category_names() -> Vec<String>
Sourcepub fn export(
&self,
features: &[CommitFeatures],
categories: &[DefectCategory],
) -> Result<ExportedDataset>
pub fn export( &self, features: &[CommitFeatures], categories: &[DefectCategory], ) -> Result<ExportedDataset>
Sourcepub fn load<P: AsRef<Path>>(
path: P,
format: ExportFormat,
) -> Result<ExportedDataset>
pub fn load<P: AsRef<Path>>( path: P, format: ExportFormat, ) -> Result<ExportedDataset>
Sourcepub fn to_aprender_matrix(dataset: &ExportedDataset) -> Result<Matrix<f32>>
pub fn to_aprender_matrix(dataset: &ExportedDataset) -> Result<Matrix<f32>>
Trait Implementations§
Auto Trait Implementations§
impl Freeze for FeatureExporter
impl RefUnwindSafe for FeatureExporter
impl Send for FeatureExporter
impl Sync for FeatureExporter
impl Unpin for FeatureExporter
impl UnwindSafe for FeatureExporter
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
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
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
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.