Class: DecisionAgent::Explainability::ExplainabilityResult
- Inherits:
-
Object
- Object
- DecisionAgent::Explainability::ExplainabilityResult
- Defined in:
- lib/decision_agent/explainability/explainability_result.rb
Overview
Container for all explainability data from a decision evaluation
Instance Attribute Summary collapse
-
#evaluator_name ⇒ Object
readonly
Returns the value of attribute evaluator_name.
-
#rule_traces ⇒ Object
readonly
Returns the value of attribute rule_traces.
Instance Method Summary collapse
- #all_failed_conditions ⇒ Object
- #all_passed_conditions ⇒ Object
-
#because(verbose: false) ⇒ Object
rubocop:disable Lint/UnusedMethodArgument.
- #failed_conditions(verbose: false) ⇒ Object
-
#initialize(evaluator_name:, rule_traces: []) ⇒ ExplainabilityResult
constructor
A new instance of ExplainabilityResult.
- #matched_rules ⇒ Object
- #to_h(verbose: false) ⇒ Object
Constructor Details
#initialize(evaluator_name:, rule_traces: []) ⇒ ExplainabilityResult
Returns a new instance of ExplainabilityResult.
9 10 11 12 13 |
# File 'lib/decision_agent/explainability/explainability_result.rb', line 9 def initialize(evaluator_name:, rule_traces: []) @evaluator_name = evaluator_name.to_s.freeze @rule_traces = Array(rule_traces).freeze freeze end |
Instance Attribute Details
#evaluator_name ⇒ Object (readonly)
Returns the value of attribute evaluator_name.
7 8 9 |
# File 'lib/decision_agent/explainability/explainability_result.rb', line 7 def evaluator_name @evaluator_name end |
#rule_traces ⇒ Object (readonly)
Returns the value of attribute rule_traces.
7 8 9 |
# File 'lib/decision_agent/explainability/explainability_result.rb', line 7 def rule_traces @rule_traces end |
Instance Method Details
#all_failed_conditions ⇒ Object
23 24 25 |
# File 'lib/decision_agent/explainability/explainability_result.rb', line 23 def all_failed_conditions @rule_traces.flat_map(&:failed_conditions) end |
#all_passed_conditions ⇒ Object
19 20 21 |
# File 'lib/decision_agent/explainability/explainability_result.rb', line 19 def all_passed_conditions @rule_traces.flat_map(&:passed_conditions) end |
#because(verbose: false) ⇒ Object
rubocop:disable Lint/UnusedMethodArgument
27 28 29 30 |
# File 'lib/decision_agent/explainability/explainability_result.rb', line 27 def because(verbose: false) # rubocop:disable Lint/UnusedMethodArgument # verbose parameter kept for API compatibility, but currently both modes return same format all_passed_conditions.map(&:description) end |
#failed_conditions(verbose: false) ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/decision_agent/explainability/explainability_result.rb', line 32 def failed_conditions(verbose: false) if verbose all_failed_conditions.map(&:to_h) else all_failed_conditions.map(&:description) end end |
#matched_rules ⇒ Object
15 16 17 |
# File 'lib/decision_agent/explainability/explainability_result.rb', line 15 def matched_rules @rule_traces.select(&:matched) end |
#to_h(verbose: false) ⇒ Object
40 41 42 43 44 45 46 47 |
# File 'lib/decision_agent/explainability/explainability_result.rb', line 40 def to_h(verbose: false) { evaluator_name: @evaluator_name, rule_traces: @rule_traces.map(&:to_h), # Always include full rule traces for reconstruction because: because(verbose: verbose), failed_conditions: failed_conditions(verbose: verbose) } end |