Class: Tangram::BinaryClassificationPredictOutput

Inherits:
Object
  • Object
show all
Defined in:
lib/tangram/tangram.rb

Overview

`predict` outputs `BinaryClassificationPredictOutput` when the model's task is binary classification.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(class_name:, probability:, feature_contributions:) ⇒ BinaryClassificationPredictOutput

Returns a new instance of BinaryClassificationPredictOutput.


57
58
59
60
61
# File 'lib/tangram/tangram.rb', line 57

def initialize(class_name:, probability:, feature_contributions:)
  @class_name = class_name
  @probability = probability
  @feature_contributions = feature_contributions
end

Instance Attribute Details

#class_nameObject (readonly)

This is the name of the predicted class.


52
53
54
# File 'lib/tangram/tangram.rb', line 52

def class_name
  @class_name
end

#feature_contributionsObject (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.


56
57
58
# File 'lib/tangram/tangram.rb', line 56

def feature_contributions
  @feature_contributions
end

#probabilityObject (readonly)

This is the probability the model assigned to the predicted class.


54
55
56
# File 'lib/tangram/tangram.rb', line 54

def probability
  @probability
end

Instance Method Details

#to_json(*args) ⇒ Object


62
63
64
# File 'lib/tangram/tangram.rb', line 62

def to_json(*args)
  {'class_name' => @class_name, "probability" => @probability}.to_json(*args)
end