Class: Synthra::QualityMetrics::QualityReport
- Inherits:
-
Object
- Object
- Synthra::QualityMetrics::QualityReport
- Defined in:
- lib/synthra/quality_metrics.rb
Overview
Quality analysis report
Instance Attribute Summary collapse
-
#anomalies ⇒ Object
readonly
Returns the value of attribute anomalies.
-
#completeness ⇒ Object
readonly
Returns the value of attribute completeness.
-
#distribution ⇒ Object
readonly
Returns the value of attribute distribution.
-
#patterns ⇒ Object
readonly
Returns the value of attribute patterns.
-
#realism_score ⇒ Object
readonly
Returns the value of attribute realism_score.
-
#total_records ⇒ Object
readonly
Returns the value of attribute total_records.
-
#type_consistency ⇒ Object
readonly
Returns the value of attribute type_consistency.
-
#uniqueness ⇒ Object
readonly
Returns the value of attribute uniqueness.
Instance Method Summary collapse
-
#initialize(**attributes) ⇒ QualityReport
constructor
A new instance of QualityReport.
-
#passes?(threshold: 80) ⇒ Boolean
Check if data passes quality threshold.
-
#summary ⇒ String
Get a summary string.
-
#to_h ⇒ Object
Convert to hash.
- #to_json(*args) ⇒ Object
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
#anomalies ⇒ Object (readonly)
Returns the value of attribute anomalies.
303 304 305 |
# File 'lib/synthra/quality_metrics.rb', line 303 def anomalies @anomalies end |
#completeness ⇒ Object (readonly)
Returns the value of attribute completeness.
302 303 304 |
# File 'lib/synthra/quality_metrics.rb', line 302 def completeness @completeness end |
#distribution ⇒ Object (readonly)
Returns the value of attribute distribution.
302 303 304 |
# File 'lib/synthra/quality_metrics.rb', line 302 def distribution @distribution end |
#patterns ⇒ Object (readonly)
Returns the value of attribute patterns.
303 304 305 |
# File 'lib/synthra/quality_metrics.rb', line 303 def patterns @patterns end |
#realism_score ⇒ Object (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_records ⇒ Object (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_consistency ⇒ Object (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 |
#uniqueness ⇒ Object (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
321 322 323 |
# File 'lib/synthra/quality_metrics.rb', line 321 def passes?(threshold: 80) realism_score >= threshold && anomalies.empty? end |
#summary ⇒ String
Get a summary 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_h ⇒ Object
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 |