Skip to content

Instantly share code, notes, and snippets.

@sdsdkkk
Last active August 29, 2015 14:12
Show Gist options
  • Save sdsdkkk/82d527b234e72cc17975 to your computer and use it in GitHub Desktop.
Save sdsdkkk/82d527b234e72cc17975 to your computer and use it in GitHub Desktop.
Train Classifier or Classifier Reborn's Bayes Classifier Using CSV File
require 'classifier'
require 'csv'
content = ''
File.open('training_set.csv', 'r') do |file|
content = file.read
end
training_set = CSV.parse content
b = Classifier::Bayes.new "label1", "label2", "label3" #put every category for the classification here
training_set.each do |t|
b.send("train_#{t.first}", t.last)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment