Class: OCI::AiLanguage::Models::NamedEntityRecognitionModelMetrics

Inherits:
Object
  • Object
show all
Defined in:
lib/oci/ai_language/models/named_entity_recognition_model_metrics.rb

Overview

Model level named entity recognition metrics

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ NamedEntityRecognitionModelMetrics

Initializes the object

Parameters:

  • attributes (Hash) (defaults to: {})

    Model attributes in the form of hash

Options Hash (attributes):

  • :micro_f1 (Float)

    The value to assign to the #micro_f1 property

  • :micro_precision (Float)

    The value to assign to the #micro_precision property

  • :micro_recall (Float)

    The value to assign to the #micro_recall property

  • :macro_f1 (Float)

    The value to assign to the #macro_f1 property

  • :macro_precision (Float)

    The value to assign to the #macro_precision property

  • :macro_recall (Float)

    The value to assign to the #macro_recall property

  • :weighted_f1 (Float)

    The value to assign to the #weighted_f1 property

  • :weighted_precision (Float)

    The value to assign to the #weighted_precision property

  • :weighted_recall (Float)

    The value to assign to the #weighted_recall property



96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
# File 'lib/oci/ai_language/models/named_entity_recognition_model_metrics.rb', line 96

def initialize(attributes = {})
  return unless attributes.is_a?(Hash)

  # convert string to symbol for hash key
  attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }

  self.micro_f1 = attributes[:'microF1'] if attributes[:'microF1']

  raise 'You cannot provide both :microF1 and :micro_f1' if attributes.key?(:'microF1') && attributes.key?(:'micro_f1')

  self.micro_f1 = attributes[:'micro_f1'] if attributes[:'micro_f1']

  self.micro_precision = attributes[:'microPrecision'] if attributes[:'microPrecision']

  raise 'You cannot provide both :microPrecision and :micro_precision' if attributes.key?(:'microPrecision') && attributes.key?(:'micro_precision')

  self.micro_precision = attributes[:'micro_precision'] if attributes[:'micro_precision']

  self.micro_recall = attributes[:'microRecall'] if attributes[:'microRecall']

  raise 'You cannot provide both :microRecall and :micro_recall' if attributes.key?(:'microRecall') && attributes.key?(:'micro_recall')

  self.micro_recall = attributes[:'micro_recall'] if attributes[:'micro_recall']

  self.macro_f1 = attributes[:'macroF1'] if attributes[:'macroF1']

  raise 'You cannot provide both :macroF1 and :macro_f1' if attributes.key?(:'macroF1') && attributes.key?(:'macro_f1')

  self.macro_f1 = attributes[:'macro_f1'] if attributes[:'macro_f1']

  self.macro_precision = attributes[:'macroPrecision'] if attributes[:'macroPrecision']

  raise 'You cannot provide both :macroPrecision and :macro_precision' if attributes.key?(:'macroPrecision') && attributes.key?(:'macro_precision')

  self.macro_precision = attributes[:'macro_precision'] if attributes[:'macro_precision']

  self.macro_recall = attributes[:'macroRecall'] if attributes[:'macroRecall']

  raise 'You cannot provide both :macroRecall and :macro_recall' if attributes.key?(:'macroRecall') && attributes.key?(:'macro_recall')

  self.macro_recall = attributes[:'macro_recall'] if attributes[:'macro_recall']

  self.weighted_f1 = attributes[:'weightedF1'] if attributes[:'weightedF1']

  raise 'You cannot provide both :weightedF1 and :weighted_f1' if attributes.key?(:'weightedF1') && attributes.key?(:'weighted_f1')

  self.weighted_f1 = attributes[:'weighted_f1'] if attributes[:'weighted_f1']

  self.weighted_precision = attributes[:'weightedPrecision'] if attributes[:'weightedPrecision']

  raise 'You cannot provide both :weightedPrecision and :weighted_precision' if attributes.key?(:'weightedPrecision') && attributes.key?(:'weighted_precision')

  self.weighted_precision = attributes[:'weighted_precision'] if attributes[:'weighted_precision']

  self.weighted_recall = attributes[:'weightedRecall'] if attributes[:'weightedRecall']

  raise 'You cannot provide both :weightedRecall and :weighted_recall' if attributes.key?(:'weightedRecall') && attributes.key?(:'weighted_recall')

  self.weighted_recall = attributes[:'weighted_recall'] if attributes[:'weighted_recall']
end

Instance Attribute Details

#macro_f1Float

[Required] F1-score, is a measure of a modelu2019s accuracy on a dataset

Returns:

  • (Float)


25
26
27
# File 'lib/oci/ai_language/models/named_entity_recognition_model_metrics.rb', line 25

def macro_f1
  @macro_f1
end

#macro_precisionFloat

[Required] Precision refers to the number of true positives divided by the total number of positive predictions (i.e., the number of true positives plus the number of false positives)

Returns:

  • (Float)


29
30
31
# File 'lib/oci/ai_language/models/named_entity_recognition_model_metrics.rb', line 29

def macro_precision
  @macro_precision
end

#macro_recallFloat

[Required] Measures the model's ability to predict actual positive classes. It is the ratio between the predicted true positives and what was actually tagged. The recall metric reveals how many of the predicted classes are correct.

Returns:

  • (Float)


33
34
35
# File 'lib/oci/ai_language/models/named_entity_recognition_model_metrics.rb', line 33

def macro_recall
  @macro_recall
end

#micro_f1Float

[Required] F1-score, is a measure of a modelu2019s accuracy on a dataset

Returns:

  • (Float)


13
14
15
# File 'lib/oci/ai_language/models/named_entity_recognition_model_metrics.rb', line 13

def micro_f1
  @micro_f1
end

#micro_precisionFloat

[Required] Precision refers to the number of true positives divided by the total number of positive predictions (i.e., the number of true positives plus the number of false positives)

Returns:

  • (Float)


17
18
19
# File 'lib/oci/ai_language/models/named_entity_recognition_model_metrics.rb', line 17

def micro_precision
  @micro_precision
end

#micro_recallFloat

[Required] Measures the model's ability to predict actual positive classes. It is the ratio between the predicted true positives and what was actually tagged. The recall metric reveals how many of the predicted classes are correct.

Returns:

  • (Float)


21
22
23
# File 'lib/oci/ai_language/models/named_entity_recognition_model_metrics.rb', line 21

def micro_recall
  @micro_recall
end

#weighted_f1Float

F1-score, is a measure of a modelu2019s accuracy on a dataset

Returns:

  • (Float)


37
38
39
# File 'lib/oci/ai_language/models/named_entity_recognition_model_metrics.rb', line 37

def weighted_f1
  @weighted_f1
end

#weighted_precisionFloat

Precision refers to the number of true positives divided by the total number of positive predictions (i.e., the number of true positives plus the number of false positives)

Returns:

  • (Float)


41
42
43
# File 'lib/oci/ai_language/models/named_entity_recognition_model_metrics.rb', line 41

def weighted_precision
  @weighted_precision
end

#weighted_recallFloat

Measures the model's ability to predict actual positive classes. It is the ratio between the predicted true positives and what was actually tagged. The recall metric reveals how many of the predicted classes are correct.

Returns:

  • (Float)


45
46
47
# File 'lib/oci/ai_language/models/named_entity_recognition_model_metrics.rb', line 45

def weighted_recall
  @weighted_recall
end

Class Method Details

.attribute_mapObject

Attribute mapping from ruby-style variable name to JSON key.



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/oci/ai_language/models/named_entity_recognition_model_metrics.rb', line 48

def self.attribute_map
  {
    # rubocop:disable Style/SymbolLiteral
    'micro_f1': :'microF1',
    'micro_precision': :'microPrecision',
    'micro_recall': :'microRecall',
    'macro_f1': :'macroF1',
    'macro_precision': :'macroPrecision',
    'macro_recall': :'macroRecall',
    'weighted_f1': :'weightedF1',
    'weighted_precision': :'weightedPrecision',
    'weighted_recall': :'weightedRecall'
    # rubocop:enable Style/SymbolLiteral
  }
end

.swagger_typesObject

Attribute type mapping.



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/oci/ai_language/models/named_entity_recognition_model_metrics.rb', line 65

def self.swagger_types
  {
    # rubocop:disable Style/SymbolLiteral
    'micro_f1': :'Float',
    'micro_precision': :'Float',
    'micro_recall': :'Float',
    'macro_f1': :'Float',
    'macro_precision': :'Float',
    'macro_recall': :'Float',
    'weighted_f1': :'Float',
    'weighted_precision': :'Float',
    'weighted_recall': :'Float'
    # rubocop:enable Style/SymbolLiteral
  }
end

Instance Method Details

#==(other) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • other (Object)

    the other object to be compared



164
165
166
167
168
169
170
171
172
173
174
175
176
177
# File 'lib/oci/ai_language/models/named_entity_recognition_model_metrics.rb', line 164

def ==(other)
  return true if equal?(other)

  self.class == other.class &&
    micro_f1 == other.micro_f1 &&
    micro_precision == other.micro_precision &&
    micro_recall == other.micro_recall &&
    macro_f1 == other.macro_f1 &&
    macro_precision == other.macro_precision &&
    macro_recall == other.macro_recall &&
    weighted_f1 == other.weighted_f1 &&
    weighted_precision == other.weighted_precision &&
    weighted_recall == other.weighted_recall
end

#build_from_hash(attributes) ⇒ Object

Builds the object from hash

Parameters:

  • attributes (Hash)

    Model attributes in the form of hash

Returns:

  • (Object)

    Returns the model itself



202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
# File 'lib/oci/ai_language/models/named_entity_recognition_model_metrics.rb', line 202

def build_from_hash(attributes)
  return nil unless attributes.is_a?(Hash)

  self.class.swagger_types.each_pair do |key, type|
    if type =~ /^Array<(.*)>/i
      # check to ensure the input is an array given that the the attribute
      # is documented as an array but the input is not
      if attributes[self.class.attribute_map[key]].is_a?(Array)
        public_method("#{key}=").call(
          attributes[self.class.attribute_map[key]]
            .map { |v| OCI::Internal::Util.convert_to_type(Regexp.last_match(1), v) }
        )
      end
    elsif !attributes[self.class.attribute_map[key]].nil?
      public_method("#{key}=").call(
        OCI::Internal::Util.convert_to_type(type, attributes[self.class.attribute_map[key]])
      )
    end
    # or else data not found in attributes(hash), not an issue as the data can be optional
  end

  self
end

#eql?(other) ⇒ Boolean

Parameters:

  • other (Object)

    the other object to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


182
183
184
# File 'lib/oci/ai_language/models/named_entity_recognition_model_metrics.rb', line 182

def eql?(other)
  self == other
end

#hashFixnum

Calculates hash code according to all attributes.

Returns:

  • (Fixnum)

    Hash code



191
192
193
# File 'lib/oci/ai_language/models/named_entity_recognition_model_metrics.rb', line 191

def hash
  [micro_f1, micro_precision, micro_recall, macro_f1, macro_precision, macro_recall, weighted_f1, weighted_precision, weighted_recall].hash
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



235
236
237
238
239
240
241
242
243
244
# File 'lib/oci/ai_language/models/named_entity_recognition_model_metrics.rb', line 235

def to_hash
  hash = {}
  self.class.attribute_map.each_pair do |attr, param|
    value = public_method(attr).call
    next if value.nil? && !instance_variable_defined?("@#{attr}")

    hash[param] = _to_hash(value)
  end
  hash
end

#to_sString

Returns the string representation of the object

Returns:

  • (String)

    String presentation of the object



229
230
231
# File 'lib/oci/ai_language/models/named_entity_recognition_model_metrics.rb', line 229

def to_s
  to_hash.to_s
end