|
|
|
@ -182,7 +182,6 @@ impl PatternAnalyticUnit {
|
|
|
|
|
|
|
|
|
|
#[async_trait] |
|
|
|
|
impl AnalyticUnit for PatternAnalyticUnit { |
|
|
|
|
|
|
|
|
|
fn set_config(&mut self, config: AnalyticUnitConfig) { |
|
|
|
|
if let AnalyticUnitConfig::Pattern(cfg) = config { |
|
|
|
|
self.config = cfg; |
|
|
|
@ -363,21 +362,21 @@ impl AnalyticUnit for PatternAnalyticUnit {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
{ |
|
|
|
|
let model_positive = { |
|
|
|
|
let mut backet = Vec::<f64>::new(); |
|
|
|
|
for j in 0..pattern_match_len { |
|
|
|
|
backet.push(nan_to_zero(ts[i + j].1)); |
|
|
|
|
} |
|
|
|
|
let fs = PatternAnalyticUnit::get_features(&backet); |
|
|
|
|
let detected = lr.model.lock().predict(Array::from_vec(fs.to_vec())); |
|
|
|
|
if detected { |
|
|
|
|
pattern_match_score += self.config.model_score; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
lr.model.lock().predict(Array::from_vec(fs.to_vec())) |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
if pattern_match_score - anti_pattern_match_score * self.config.anti_correlation_score |
|
|
|
|
>= self.config.threshold_score |
|
|
|
|
{ |
|
|
|
|
let mut score = pattern_match_score * self.config.correlation_score; |
|
|
|
|
score -= anti_pattern_match_score * self.config.anti_correlation_score; |
|
|
|
|
if model_positive { |
|
|
|
|
score += self.config.model_score; |
|
|
|
|
} |
|
|
|
|
if score >= self.config.threshold_score { |
|
|
|
|
results.push((ts[i].0, ts[i + pattern_match_len - 1].0)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|