Class: Legion::Extensions::Agentic::Inference::PredictiveCoding::Helpers::PredictionError
- Inherits:
-
Object
- Object
- Legion::Extensions::Agentic::Inference::PredictiveCoding::Helpers::PredictionError
- Defined in:
- lib/legion/extensions/agentic/inference/predictive_coding/helpers/prediction_error.rb
Instance Attribute Summary collapse
-
#actual ⇒ Object
readonly
Returns the value of attribute actual.
-
#domain ⇒ Object
readonly
Returns the value of attribute domain.
-
#error_magnitude ⇒ Object
readonly
Returns the value of attribute error_magnitude.
-
#precision ⇒ Object
readonly
Returns the value of attribute precision.
-
#predicted ⇒ Object
readonly
Returns the value of attribute predicted.
-
#timestamp ⇒ Object
readonly
Returns the value of attribute timestamp.
-
#weighted_error ⇒ Object
readonly
Returns the value of attribute weighted_error.
Instance Method Summary collapse
-
#initialize(domain:, predicted:, actual:, precision: Constants::DEFAULT_PRECISION) ⇒ PredictionError
constructor
A new instance of PredictionError.
- #level ⇒ Object
- #surprising? ⇒ Boolean
- #to_h ⇒ Object
Constructor Details
#initialize(domain:, predicted:, actual:, precision: Constants::DEFAULT_PRECISION) ⇒ PredictionError
Returns a new instance of PredictionError.
12 13 14 15 16 17 18 19 20 |
# File 'lib/legion/extensions/agentic/inference/predictive_coding/helpers/prediction_error.rb', line 12 def initialize(domain:, predicted:, actual:, precision: Constants::DEFAULT_PRECISION) @domain = domain @predicted = predicted @actual = actual @error_magnitude = compute_error_magnitude(predicted, actual) @precision = precision @weighted_error = @error_magnitude * @precision @timestamp = Time.now.utc end |
Instance Attribute Details
#actual ⇒ Object (readonly)
Returns the value of attribute actual.
10 11 12 |
# File 'lib/legion/extensions/agentic/inference/predictive_coding/helpers/prediction_error.rb', line 10 def actual @actual end |
#domain ⇒ Object (readonly)
Returns the value of attribute domain.
10 11 12 |
# File 'lib/legion/extensions/agentic/inference/predictive_coding/helpers/prediction_error.rb', line 10 def domain @domain end |
#error_magnitude ⇒ Object (readonly)
Returns the value of attribute error_magnitude.
10 11 12 |
# File 'lib/legion/extensions/agentic/inference/predictive_coding/helpers/prediction_error.rb', line 10 def error_magnitude @error_magnitude end |
#precision ⇒ Object (readonly)
Returns the value of attribute precision.
10 11 12 |
# File 'lib/legion/extensions/agentic/inference/predictive_coding/helpers/prediction_error.rb', line 10 def precision @precision end |
#predicted ⇒ Object (readonly)
Returns the value of attribute predicted.
10 11 12 |
# File 'lib/legion/extensions/agentic/inference/predictive_coding/helpers/prediction_error.rb', line 10 def predicted @predicted end |
#timestamp ⇒ Object (readonly)
Returns the value of attribute timestamp.
10 11 12 |
# File 'lib/legion/extensions/agentic/inference/predictive_coding/helpers/prediction_error.rb', line 10 def @timestamp end |
#weighted_error ⇒ Object (readonly)
Returns the value of attribute weighted_error.
10 11 12 |
# File 'lib/legion/extensions/agentic/inference/predictive_coding/helpers/prediction_error.rb', line 10 def weighted_error @weighted_error end |
Instance Method Details
#level ⇒ Object
26 27 28 |
# File 'lib/legion/extensions/agentic/inference/predictive_coding/helpers/prediction_error.rb', line 26 def level Constants::PREDICTION_ERROR_LEVELS.find { |_k, range| range.cover?(@error_magnitude) }&.first || :unknown end |
#surprising? ⇒ Boolean
22 23 24 |
# File 'lib/legion/extensions/agentic/inference/predictive_coding/helpers/prediction_error.rb', line 22 def surprising? @error_magnitude >= Constants::SURPRISE_THRESHOLD end |
#to_h ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/legion/extensions/agentic/inference/predictive_coding/helpers/prediction_error.rb', line 30 def to_h { domain: @domain, predicted: @predicted, actual: @actual, error_magnitude: @error_magnitude, precision: @precision, weighted_error: @weighted_error, surprising: surprising?, level: level, timestamp: @timestamp } end |