Class: LaunchDarklyApi::TreatmentResultRep

Inherits:
Object
  • Object
show all
Defined in:
lib/launchdarkly_api/models/treatment_result_rep.rb

Defined Under Namespace

Classes: EnumAttributeValidator

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ TreatmentResultRep

Initializes the object

Parameters:

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

    Model attributes in the form of hash



156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
# File 'lib/launchdarkly_api/models/treatment_result_rep.rb', line 156

def initialize(attributes = {})
  if (!attributes.is_a?(Hash))
    fail ArgumentError, "The input argument (attributes) must be a hash in `LaunchDarklyApi::TreatmentResultRep` initialize method"
  end

  # check to see if the attribute exists and convert string to symbol for hash key
  attributes = attributes.each_with_object({}) { |(k, v), h|
    if (!self.class.attribute_map.key?(k.to_sym))
      fail ArgumentError, "`#{k}` is not a valid attribute in `LaunchDarklyApi::TreatmentResultRep`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
    end
    h[k.to_sym] = v
  }

  if attributes.key?(:'treatment_id')
    self.treatment_id = attributes[:'treatment_id']
  end

  if attributes.key?(:'treatment_name')
    self.treatment_name = attributes[:'treatment_name']
  end

  if attributes.key?(:'mean')
    self.mean = attributes[:'mean']
  end

  if attributes.key?(:'data_mean')
    self.data_mean = attributes[:'data_mean']
  end

  if attributes.key?(:'data_std_dev')
    self.data_std_dev = attributes[:'data_std_dev']
  end

  if attributes.key?(:'credible_interval')
    self.credible_interval = attributes[:'credible_interval']
  end

  if attributes.key?(:'p_best')
    self.p_best = attributes[:'p_best']
  end

  if attributes.key?(:'relative_differences')
    if (value = attributes[:'relative_differences']).is_a?(Array)
      self.relative_differences = value
    end
  end

  if attributes.key?(:'units')
    self.units = attributes[:'units']
  end

  if attributes.key?(:'traffic')
    self.traffic = attributes[:'traffic']
  end

  if attributes.key?(:'event_values_sum')
    self.event_values_sum = attributes[:'event_values_sum']
  end

  if attributes.key?(:'distribution')
    self.distribution = attributes[:'distribution']
  end

  if attributes.key?(:'correlation')
    self.correlation = attributes[:'correlation']
  end

  if attributes.key?(:'standard_deviation_ratio')
    self.standard_deviation_ratio = attributes[:'standard_deviation_ratio']
  end

  if attributes.key?(:'covariate_imbalance')
    self.covariate_imbalance = attributes[:'covariate_imbalance']
  end

  if attributes.key?(:'variance_reduction')
    self.variance_reduction = attributes[:'variance_reduction']
  end

  if attributes.key?(:'model')
    self.model = attributes[:'model']
  end

  if attributes.key?(:'bayesian_normal')
    self.bayesian_normal = attributes[:'bayesian_normal']
  end

  if attributes.key?(:'bayesian_beta')
    self.bayesian_beta = attributes[:'bayesian_beta']
  end
end

Instance Attribute Details

#bayesian_betaObject

Returns the value of attribute bayesian_beta.



69
70
71
# File 'lib/launchdarkly_api/models/treatment_result_rep.rb', line 69

def bayesian_beta
  @bayesian_beta
end

#bayesian_normalObject

Returns the value of attribute bayesian_normal.



67
68
69
# File 'lib/launchdarkly_api/models/treatment_result_rep.rb', line 67

def bayesian_normal
  @bayesian_normal
end

#correlationObject

The outcome-covariate correlation



53
54
55
# File 'lib/launchdarkly_api/models/treatment_result_rep.rb', line 53

def correlation
  @correlation
end

#covariate_imbalanceObject

The imbalance between the covariate mean for the arm and the covariate mean for the experiment



59
60
61
# File 'lib/launchdarkly_api/models/treatment_result_rep.rb', line 59

def covariate_imbalance
  @covariate_imbalance
end

#credible_intervalObject

Returns the value of attribute credible_interval.



33
34
35
# File 'lib/launchdarkly_api/models/treatment_result_rep.rb', line 33

def credible_interval
  @credible_interval
end

#data_meanObject

The mean of the data, with no priors effecting the result.



28
29
30
# File 'lib/launchdarkly_api/models/treatment_result_rep.rb', line 28

def data_mean
  @data_mean
end

#data_std_devObject

The standard deviation of the data, with no priors effecting the result.



31
32
33
# File 'lib/launchdarkly_api/models/treatment_result_rep.rb', line 31

def data_std_dev
  @data_std_dev
end

#distributionObject

Returns the value of attribute distribution.



50
51
52
# File 'lib/launchdarkly_api/models/treatment_result_rep.rb', line 50

def distribution
  @distribution
end

#event_values_sumObject

The sum of the event values for the units exposed to this treatment.



48
49
50
# File 'lib/launchdarkly_api/models/treatment_result_rep.rb', line 48

def event_values_sum
  @event_values_sum
end

#meanObject

The average value of the variation in this sample. It doesn’t capture the uncertainty in the measurement, so it should not be the only measurement you use to make decisions.



25
26
27
# File 'lib/launchdarkly_api/models/treatment_result_rep.rb', line 25

def mean
  @mean
end

#modelObject

The model used to calculate the results. Parameters specific to this model will be defined under the field under the same name



65
66
67
# File 'lib/launchdarkly_api/models/treatment_result_rep.rb', line 65

def model
  @model
end

#p_bestObject

The likelihood that this variation has the biggest effect on the primary metric. The variation with the highest probability is likely the best of the variations you’re testing



36
37
38
# File 'lib/launchdarkly_api/models/treatment_result_rep.rb', line 36

def p_best
  @p_best
end

#relative_differencesObject

Estimates of the relative difference between this treatment’s mean and the mean of each other treatment



39
40
41
# File 'lib/launchdarkly_api/models/treatment_result_rep.rb', line 39

def relative_differences
  @relative_differences
end

#standard_deviation_ratioObject

The ratio of the outcome SD to covariate SD



56
57
58
# File 'lib/launchdarkly_api/models/treatment_result_rep.rb', line 56

def standard_deviation_ratio
  @standard_deviation_ratio
end

#trafficObject

The number of units exposed to this treatment.



45
46
47
# File 'lib/launchdarkly_api/models/treatment_result_rep.rb', line 45

def traffic
  @traffic
end

#treatment_idObject

The ID of the treatment



19
20
21
# File 'lib/launchdarkly_api/models/treatment_result_rep.rb', line 19

def treatment_id
  @treatment_id
end

#treatment_nameObject

The name of the treatment



22
23
24
# File 'lib/launchdarkly_api/models/treatment_result_rep.rb', line 22

def treatment_name
  @treatment_name
end

#unitsObject

The number of units exposed to this treatment that have event values, including those that are configured to default to 0



42
43
44
# File 'lib/launchdarkly_api/models/treatment_result_rep.rb', line 42

def units
  @units
end

#variance_reductionObject

The reduction in variance resulting from CUPED



62
63
64
# File 'lib/launchdarkly_api/models/treatment_result_rep.rb', line 62

def variance_reduction
  @variance_reduction
end

Class Method Details

.acceptable_attributesObject

Returns all the JSON keys this model knows about



119
120
121
# File 'lib/launchdarkly_api/models/treatment_result_rep.rb', line 119

def self.acceptable_attributes
  attribute_map.values
end

.attribute_mapObject

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



94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/launchdarkly_api/models/treatment_result_rep.rb', line 94

def self.attribute_map
  {
    :'treatment_id' => :'treatmentId',
    :'treatment_name' => :'treatmentName',
    :'mean' => :'mean',
    :'data_mean' => :'dataMean',
    :'data_std_dev' => :'dataStdDev',
    :'credible_interval' => :'credibleInterval',
    :'p_best' => :'pBest',
    :'relative_differences' => :'relativeDifferences',
    :'units' => :'units',
    :'traffic' => :'traffic',
    :'event_values_sum' => :'eventValuesSum',
    :'distribution' => :'distribution',
    :'correlation' => :'correlation',
    :'standard_deviation_ratio' => :'standardDeviationRatio',
    :'covariate_imbalance' => :'covariateImbalance',
    :'variance_reduction' => :'varianceReduction',
    :'model' => :'model',
    :'bayesian_normal' => :'bayesianNormal',
    :'bayesian_beta' => :'bayesianBeta'
  }
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



314
315
316
# File 'lib/launchdarkly_api/models/treatment_result_rep.rb', line 314

def self.build_from_hash(attributes)
  new.build_from_hash(attributes)
end

.openapi_nullableObject

List of attributes with nullable: true



149
150
151
152
# File 'lib/launchdarkly_api/models/treatment_result_rep.rb', line 149

def self.openapi_nullable
  Set.new([
  ])
end

.openapi_typesObject

Attribute type mapping.



124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
# File 'lib/launchdarkly_api/models/treatment_result_rep.rb', line 124

def self.openapi_types
  {
    :'treatment_id' => :'String',
    :'treatment_name' => :'String',
    :'mean' => :'Float',
    :'data_mean' => :'Float',
    :'data_std_dev' => :'Float',
    :'credible_interval' => :'CredibleIntervalRep',
    :'p_best' => :'Float',
    :'relative_differences' => :'Array<RelativeDifferenceRep>',
    :'units' => :'Integer',
    :'traffic' => :'Integer',
    :'event_values_sum' => :'Float',
    :'distribution' => :'Distribution',
    :'correlation' => :'Float',
    :'standard_deviation_ratio' => :'Float',
    :'covariate_imbalance' => :'Float',
    :'variance_reduction' => :'Float',
    :'model' => :'String',
    :'bayesian_normal' => :'BayesianNormalStatsRep',
    :'bayesian_beta' => :'BayesianBetaBinomialStatsRep'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
# File 'lib/launchdarkly_api/models/treatment_result_rep.rb', line 275

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      treatment_id == o.treatment_id &&
      treatment_name == o.treatment_name &&
      mean == o.mean &&
      data_mean == o.data_mean &&
      data_std_dev == o.data_std_dev &&
      credible_interval == o.credible_interval &&
      p_best == o.p_best &&
      relative_differences == o.relative_differences &&
      units == o.units &&
      traffic == o.traffic &&
      event_values_sum == o.event_values_sum &&
      distribution == o.distribution &&
      correlation == o.correlation &&
      standard_deviation_ratio == o.standard_deviation_ratio &&
      covariate_imbalance == o.covariate_imbalance &&
      variance_reduction == o.variance_reduction &&
      model == o.model &&
      bayesian_normal == o.bayesian_normal &&
      bayesian_beta == o.bayesian_beta
end

#_deserialize(type, value) ⇒ Object

Deserializes the data based on type

Parameters:

  • string

    type Data type

  • string

    value Value to be deserialized

Returns:

  • (Object)

    Deserialized data



345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
# File 'lib/launchdarkly_api/models/treatment_result_rep.rb', line 345

def _deserialize(type, value)
  case type.to_sym
  when :Time
    Time.parse(value)
  when :Date
    Date.parse(value)
  when :String
    value.to_s
  when :Integer
    value.to_i
  when :Float
    value.to_f
  when :Boolean
    if value.to_s =~ /\A(true|t|yes|y|1)\z/i
      true
    else
      false
    end
  when :Object
    # generic object (usually a Hash), return directly
    value
  when /\AArray<(?<inner_type>.+)>\z/
    inner_type = Regexp.last_match[:inner_type]
    value.map { |v| _deserialize(inner_type, v) }
  when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
    k_type = Regexp.last_match[:k_type]
    v_type = Regexp.last_match[:v_type]
    {}.tap do |hash|
      value.each do |k, v|
        hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
      end
    end
  else # model
    # models (e.g. Pet) or oneOf
    klass = LaunchDarklyApi.const_get(type)
    klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
  end
end

#_to_hash(value) ⇒ Hash

Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value

Parameters:

  • value (Object)

    Any valid value

Returns:

  • (Hash)

    Returns the value in the form of hash



416
417
418
419
420
421
422
423
424
425
426
427
428
# File 'lib/launchdarkly_api/models/treatment_result_rep.rb', line 416

def _to_hash(value)
  if value.is_a?(Array)
    value.compact.map { |v| _to_hash(v) }
  elsif value.is_a?(Hash)
    {}.tap do |hash|
      value.each { |k, v| hash[k] = _to_hash(v) }
    end
  elsif value.respond_to? :to_hash
    value.to_hash
  else
    value
  end
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



321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
# File 'lib/launchdarkly_api/models/treatment_result_rep.rb', line 321

def build_from_hash(attributes)
  return nil unless attributes.is_a?(Hash)
  attributes = attributes.transform_keys(&:to_sym)
  self.class.openapi_types.each_pair do |key, type|
    if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
      self.send("#{key}=", nil)
    elsif type =~ /\AArray<(.*)>/i
      # check to ensure the input is an array given that the attribute
      # is documented as an array but the input is not
      if attributes[self.class.attribute_map[key]].is_a?(Array)
        self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
      end
    elsif !attributes[self.class.attribute_map[key]].nil?
      self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
    end
  end

  self
end

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


301
302
303
# File 'lib/launchdarkly_api/models/treatment_result_rep.rb', line 301

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • (Integer)

    Hash code



307
308
309
# File 'lib/launchdarkly_api/models/treatment_result_rep.rb', line 307

def hash
  [treatment_id, treatment_name, mean, data_mean, data_std_dev, credible_interval, p_best, relative_differences, units, traffic, event_values_sum, distribution, correlation, standard_deviation_ratio, covariate_imbalance, variance_reduction, model, bayesian_normal, bayesian_beta].hash
end

#list_invalid_propertiesObject

Show invalid properties with the reasons. Usually used together with valid?

Returns:

  • Array for valid properties with the reasons



250
251
252
253
# File 'lib/launchdarkly_api/models/treatment_result_rep.rb', line 250

def list_invalid_properties
  invalid_properties = Array.new
  invalid_properties
end

#to_bodyHash

to_body is an alias to to_hash (backward compatibility)

Returns:

  • (Hash)

    Returns the object in the form of hash



392
393
394
# File 'lib/launchdarkly_api/models/treatment_result_rep.rb', line 392

def to_body
  to_hash
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



398
399
400
401
402
403
404
405
406
407
408
409
410
# File 'lib/launchdarkly_api/models/treatment_result_rep.rb', line 398

def to_hash
  hash = {}
  self.class.attribute_map.each_pair do |attr, param|
    value = self.send(attr)
    if value.nil?
      is_nullable = self.class.openapi_nullable.include?(attr)
      next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
    end

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

#to_sString

Returns the string representation of the object

Returns:

  • (String)

    String presentation of the object



386
387
388
# File 'lib/launchdarkly_api/models/treatment_result_rep.rb', line 386

def to_s
  to_hash.to_s
end

#valid?Boolean

Check to see if the all the properties in the model are valid

Returns:

  • (Boolean)

    true if the model is valid



257
258
259
260
261
# File 'lib/launchdarkly_api/models/treatment_result_rep.rb', line 257

def valid?
  model_validator = EnumAttributeValidator.new('String', ["bayesianNormal", "bayesianBeta"])
  return false unless model_validator.valid?(@model)
  true
end