demo.rb 442 B

1234567891011121314
  1. require 'confusion_matrix'
  2. cm = ConfusionMatrix.new :pos, :neg # the matrix has two classes
  3. cm.add_for(:pos, :pos, 10) # add 10 observations of (:pos, :pos)
  4. 3.times { cm.add_for(:pos, :neg) } # add 3 observations separately
  5. 20.times { cm.add_for(:neg, :neg) }
  6. 5.times { cm.add_for(:neg, :pos) }
  7. puts "Precision: #{cm.precision}" # results for :pos class
  8. puts "Recall: #{cm.recall}"
  9. puts "MCC: #{cm.matthews_correlation}"
  10. puts
  11. puts(cm.to_s)