Class: Treat::Workers::Learners::Classifiers::ID3
- Inherits:
-
Object
- Object
- Treat::Workers::Learners::Classifiers::ID3
- Defined in:
- lib/treat/workers/learners/classifiers/id3.rb
Overview
Classification based on Ross Quinlan’s ID3 (Iterative Dichotomiser 3) decision tree algorithm.
Original paper: Quinlan, J. R. 1986. Induction of Decision Trees. Mach. Learn. 1, 1 (Mar. 1986), 81-106.
Constant Summary collapse
- @@classifiers =
{}
Class Method Summary collapse
Class Method Details
.classify(entity, options = {}) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/treat/workers/learners/classifiers/id3.rb', line 14 def self.classify(entity, = {}) dset = [:training] prob = dset.problem if !@@classifiers[prob] dec_tree = DecisionTree::ID3Tree.new( prob.feature_labels.map { |l| l.to_s }, dset.items.map { |i| i[:features] }, prob.question.default, prob.question.type) dec_tree.train @@classifiers[prob] = dec_tree else dec_tree = @@classifiers[prob] end vect = prob.export_features(entity, false) dec_tree.predict(vect) end |