Class: Synthra::QualityMetrics::QualityReport

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

Overview

Quality analysis report

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**attributes) ⇒ QualityReport

Returns a new instance of QualityReport.



305
306
307
308
309
310
311
312
313
314
# File 'lib/synthra/quality_metrics.rb', line 305

def initialize(**attributes)
  @total_records = attributes[:total_records]
  @uniqueness = attributes[:uniqueness]
  @distribution = attributes[:distribution]
  @completeness = attributes[:completeness]
  @type_consistency = attributes[:type_consistency]
  @realism_score = attributes[:realism_score]
  @patterns = attributes[:patterns]
  @anomalies = attributes[:anomalies]
end

Instance Attribute Details

#anomaliesObject (readonly)

Returns the value of attribute anomalies.



303
304
305
# File 'lib/synthra/quality_metrics.rb', line 303

def anomalies
  @anomalies
end

#completenessObject (readonly)

Returns the value of attribute completeness.



302
303
304
# File 'lib/synthra/quality_metrics.rb', line 302

def completeness
  @completeness
end

#distributionObject (readonly)

Returns the value of attribute distribution.



302
303
304
# File 'lib/synthra/quality_metrics.rb', line 302

def distribution
  @distribution
end

#patternsObject (readonly)

Returns the value of attribute patterns.



303
304
305
# File 'lib/synthra/quality_metrics.rb', line 303

def patterns
  @patterns
end

#realism_scoreObject (readonly)

Returns the value of attribute realism_score.



303
304
305
# File 'lib/synthra/quality_metrics.rb', line 303

def realism_score
  @realism_score
end

#total_recordsObject (readonly)

Returns the value of attribute total_records.



302
303
304
# File 'lib/synthra/quality_metrics.rb', line 302

def total_records
  @total_records
end

#type_consistencyObject (readonly)

Returns the value of attribute type_consistency.



303
304
305
# File 'lib/synthra/quality_metrics.rb', line 303

def type_consistency
  @type_consistency
end

#uniquenessObject (readonly)

Returns the value of attribute uniqueness.



302
303
304
# File 'lib/synthra/quality_metrics.rb', line 302

def uniqueness
  @uniqueness
end

Instance Method Details

#passes?(threshold: 80) ⇒ Boolean

Check if data passes quality threshold

Parameters:

  • threshold (Float) (defaults to: 80)

    minimum realism score (0-100)

Returns:

  • (Boolean)


321
322
323
# File 'lib/synthra/quality_metrics.rb', line 321

def passes?(threshold: 80)
  realism_score >= threshold && anomalies.empty?
end

#summaryString

Get a summary string

Returns:

  • (String)


329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
# File 'lib/synthra/quality_metrics.rb', line 329

def summary
  lines = [
    "Quality Report (#{total_records} records)",
    "=" * 40,
    "Realism Score: #{realism_score}%",
    "Completeness: #{completeness}%",
    "",
    "Uniqueness:",
    *uniqueness.map { |f, u| "  #{f}: #{u}%" },
    ""
  ]

  if anomalies.any?
    lines << "Anomalies:"
    anomalies.each do |a|
      lines << "  ⚠️  #{a[:type]} in #{a[:field]}"
    end
  else
    lines << "✅ No anomalies detected"
  end

  lines.join("\n")
end

#to_hObject

Convert to hash



354
355
356
357
358
359
360
361
362
363
364
365
# File 'lib/synthra/quality_metrics.rb', line 354

def to_h
  {
    total_records: total_records,
    uniqueness: uniqueness,
    distribution: distribution,
    completeness: completeness,
    type_consistency: type_consistency,
    realism_score: realism_score,
    patterns: patterns,
    anomalies: anomalies
  }
end

#to_json(*args) ⇒ Object



367
368
369
# File 'lib/synthra/quality_metrics.rb', line 367

def to_json(*args)
  to_h.to_json(*args)
end