pub enum HybridClassifier {
RuleBased(RuleBasedClassifier),
Hybrid {
ml_model: Box<TrainedModel>,
fallback: RuleBasedClassifier,
confidence_threshold: f32,
},
}Expand description
Hybrid classifier combining rule-based and ML approaches
NLP-010: Integrates trained ML models with fallback to rule-based classification Implements three-tier architecture from nlp-models-techniques-spec.md:
- Tier 1: Rule-based (fast, <10ms)
- Tier 2: TF-IDF + Random Forest (medium, <100ms)
- Tier 3: Transformer models (future work)
Variants§
RuleBased(RuleBasedClassifier)
Rule-based only (Tier 1)
Hybrid
ML model with rule-based fallback (Tier 2 + Tier 1)
Implementations§
Source§impl HybridClassifier
impl HybridClassifier
Sourcepub fn new_rule_based() -> Self
pub fn new_rule_based() -> Self
Create a new rule-based classifier (Tier 1 only)
§Examples
use organizational_intelligence_plugin::classifier::HybridClassifier;
let classifier = HybridClassifier::new_rule_based();Sourcepub fn new_hybrid(ml_model: TrainedModel, confidence_threshold: f32) -> Self
pub fn new_hybrid(ml_model: TrainedModel, confidence_threshold: f32) -> Self
Sourcepub fn classify_from_message(&self, message: &str) -> Option<Classification>
pub fn classify_from_message(&self, message: &str) -> Option<Classification>
Classify a commit message
Uses ML model if available and confident, otherwise falls back to rule-based.
§Arguments
message- Commit message to classify
§Returns
Some(Classification)if a category is detectedNoneif no patterns match
§Examples
use organizational_intelligence_plugin::classifier::HybridClassifier;
let classifier = HybridClassifier::new_rule_based();
if let Some(result) = classifier.classify_from_message("fix: null pointer") {
println!("Category: {:?}, Confidence: {:.2}", result.category, result.confidence);
}Sourcepub fn classify_multi_label(
&self,
message: &str,
top_n: usize,
min_confidence: f32,
) -> Result<MultiLabelClassification>
pub fn classify_multi_label( &self, message: &str, top_n: usize, min_confidence: f32, ) -> Result<MultiLabelClassification>
Classify with multiple labels
§Arguments
message- Commit message to classifytop_n- Maximum number of categories to returnmin_confidence- Minimum confidence threshold (0.0 to 1.0)
§Returns
Ok(MultiLabelClassification)with top-N categories
§Examples
use organizational_intelligence_plugin::classifier::HybridClassifier;
let classifier = HybridClassifier::new_rule_based();
let result = classifier.classify_multi_label("fix: null pointer in parser", 3, 0.60).unwrap();
println!("Primary: {:?} ({:.2})", result.primary_category, result.primary_confidence);Trait Implementations§
Auto Trait Implementations§
impl Freeze for HybridClassifier
impl !RefUnwindSafe for HybridClassifier
impl !Send for HybridClassifier
impl !Sync for HybridClassifier
impl Unpin for HybridClassifier
impl !UnwindSafe for HybridClassifier
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 more