Class | Ai4r::Classifiers::Prism |
In: |
lib/ai4r/classifiers/prism.rb
|
Parent: | Classifier |
This is an implementation of the PRISM algorithm (Cendrowska, 1987) Given a set of preclassified examples, it builds a set of rules to predict the class of other instaces.
International Journal of Man-Machine Studies. 27(4):349-370.
data_set | [R] | |
rules | [R] |
Build a new Prism classifier. You must provide a DataSet instance as parameter. The last attribute of each item is considered as the item class.
You can evaluate new data, predicting its class. e.g.
classifier.eval(['New York', '<30', 'F']) # => 'Y'
This method returns the generated rules in ruby code. e.g.
classifier.get_rules # => if age_range == '<30' then marketing_target = 'Y' elsif age_range == '>80' then marketing_target = 'Y' elsif city == 'Chicago' and age_range == '[30-50)' then marketing_target = 'Y' else marketing_target = 'N' end
It is a nice way to inspect induction results, and also to execute them:
age_range = '[30-50)' city = 'New York' eval(classifier.get_rules) puts marketing_target 'Y'
pt = [p, t] p = occurrences of attribute value with instance classified as class_value t = occurrences of attribute value a pt is better if:
1- its ratio is higher 2- its ratio is equal, and has a higher p
Returns a structure with the folloring format:
attr2_label => { :attr2_value1 => [p, t], attr2_value2 => [p, t], ... }, ... }
where p is the number of instances classified as class_value with that attribute value, and t is the total number of instances with that attribute value