Class: RailsErrorDashboard::Services::StatisticalClassifier
- Inherits:
-
Object
- Object
- RailsErrorDashboard::Services::StatisticalClassifier
- Defined in:
- lib/rails_error_dashboard/services/statistical_classifier.rb
Overview
Pure algorithm: Classification methods for statistical values
No database access — accepts values, returns classification symbols. Groups related threshold-based classification logic in one place.
Class Method Summary collapse
-
.correlation_strength(correlation) ⇒ Symbol
Classify correlation coefficient into strength categories.
-
.spike_severity(multiplier) ⇒ Symbol
Classify error spike severity based on multiplier over average.
-
.trend_direction(change_percentage) ⇒ Symbol
Classify percentage change into trend direction.
Class Method Details
.correlation_strength(correlation) ⇒ Symbol
Classify correlation coefficient into strength categories
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/rails_error_dashboard/services/statistical_classifier.rb', line 18 def self.correlation_strength(correlation) abs_corr = correlation.abs if abs_corr >= 0.8 :strong elsif abs_corr >= 0.5 :moderate else :weak end end |
.spike_severity(multiplier) ⇒ Symbol
Classify error spike severity based on multiplier over average
50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/rails_error_dashboard/services/statistical_classifier.rb', line 50 def self.spike_severity(multiplier) case multiplier when 0...2 :normal when 2...5 :elevated when 5...10 :high else :critical end end |
.trend_direction(change_percentage) ⇒ Symbol
Classify percentage change into trend direction
33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/rails_error_dashboard/services/statistical_classifier.rb', line 33 def self.trend_direction(change_percentage) if change_percentage > 20 :increasing_significantly elsif change_percentage > 5 :increasing elsif change_percentage < -20 :decreasing_significantly elsif change_percentage < -5 :decreasing else :stable end end |