pub struct DefectPredictor { /* private fields */ }Expand description
Defect predictor using linear model (placeholder for GradientBoosting)
When ml feature is enabled, uses aprender’s GradientBoostingClassifier.
Otherwise uses a simple linear model as fallback.
Implementations§
Source§impl DefectPredictor
impl DefectPredictor
Sourcepub fn with_weights(weights: CategoryWeights) -> Self
pub fn with_weights(weights: CategoryWeights) -> Self
Create with custom category weights
Sourcepub fn train(&mut self, samples: &[DefectSample]) -> Result<()>
pub fn train(&mut self, samples: &[DefectSample]) -> Result<()>
Train on samples (linear model fallback)
Uses gradient descent to optimize feature weights.
§Errors
Returns an error if samples is empty.
Sourcepub fn predict(&self, features: &CommitFeatures, code: &str) -> DefectPrediction
pub fn predict(&self, features: &CommitFeatures, code: &str) -> DefectPrediction
Predict defect probability for code
Sourcepub fn predict_features(&self, features: &CommitFeatures) -> DefectPrediction
pub fn predict_features(&self, features: &CommitFeatures) -> DefectPrediction
Predict for features only (without code for category)
Sourcepub fn stats(&self) -> &DefectPredictorStats
pub fn stats(&self) -> &DefectPredictorStats
Get training statistics
Sourcepub fn is_trained(&self) -> bool
pub fn is_trained(&self) -> bool
Is model trained?
Sourcepub fn category_weights(&self) -> &CategoryWeights
pub fn category_weights(&self) -> &CategoryWeights
Get category weights
Sourcepub fn prioritize(&self, samples: &[(CommitFeatures, String)]) -> Vec<usize>
pub fn prioritize(&self, samples: &[(CommitFeatures, String)]) -> Vec<usize>
Prioritize samples by defect likelihood
Returns indices sorted by priority (highest defect probability first)
Trait Implementations§
Source§impl Debug for DefectPredictor
impl Debug for DefectPredictor
Auto Trait Implementations§
impl Freeze for DefectPredictor
impl RefUnwindSafe for DefectPredictor
impl Send for DefectPredictor
impl Sync for DefectPredictor
impl Unpin for DefectPredictor
impl UnsafeUnpin for DefectPredictor
impl UnwindSafe for DefectPredictor
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> 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 more