Class: ModelFox::MulticlassClassificationPredictOutput
- Inherits:
-
Object
- Object
- ModelFox::MulticlassClassificationPredictOutput
- Defined in:
- lib/modelfox/modelfox.rb
Overview
‘predict` outputs `MulticlassClassificationPredictOutput` when the model’s task is multiclass classification.
Instance Attribute Summary collapse
-
#class_name ⇒ Object
readonly
This is the name of the predicted class.
-
#feature_contributions ⇒ Object
readonly
If computing feature contributions was enabled in the predict options, this value will explain the model’s output, showing how much each feature contributed to the output.
-
#probabilities ⇒ Object
readonly
This value maps from class names to the probability the model assigned to each class.
-
#probability ⇒ Object
readonly
This is the probability the model assigned to the predicted class.
Instance Method Summary collapse
-
#initialize(class_name:, probability:, probabilities:, feature_contributions:) ⇒ MulticlassClassificationPredictOutput
constructor
A new instance of MulticlassClassificationPredictOutput.
- #to_json(*args) ⇒ Object
Constructor Details
#initialize(class_name:, probability:, probabilities:, feature_contributions:) ⇒ MulticlassClassificationPredictOutput
Returns a new instance of MulticlassClassificationPredictOutput.
77 78 79 80 81 82 |
# File 'lib/modelfox/modelfox.rb', line 77 def initialize(class_name:, probability:, probabilities:, feature_contributions:) @class_name = class_name @probability = probability @probabilities = probabilities @feature_contributions = feature_contributions end |
Instance Attribute Details
#class_name ⇒ Object (readonly)
This is the name of the predicted class.
70 71 72 |
# File 'lib/modelfox/modelfox.rb', line 70 def class_name @class_name end |
#feature_contributions ⇒ Object (readonly)
If computing feature contributions was enabled in the predict options, this value will explain the model’s output, showing how much each feature contributed to the output. This value maps from class names to ‘FeatureContributions` values for each class. The class with the `FeatureContributions` value with the highest `output_value` is the predicted class.
76 77 78 |
# File 'lib/modelfox/modelfox.rb', line 76 def feature_contributions @feature_contributions end |
#probabilities ⇒ Object (readonly)
This value maps from class names to the probability the model assigned to each class.
74 75 76 |
# File 'lib/modelfox/modelfox.rb', line 74 def probabilities @probabilities end |
#probability ⇒ Object (readonly)
This is the probability the model assigned to the predicted class.
72 73 74 |
# File 'lib/modelfox/modelfox.rb', line 72 def probability @probability end |
Instance Method Details
#to_json(*args) ⇒ Object
83 84 85 |
# File 'lib/modelfox/modelfox.rb', line 83 def to_json(*args) {'class_name' => @class_name, "probability" => @probability, "probabilities" => @probabilities}.to_json(*args) end |