Acts as Classifiable plugin
Plugin details
Documentation
ruby script/plugin install http://opensvn.csie.org/sksinghi/acts_as_classifiable/
Next your database needs to have a table named `classifier_models'. This is used as a persitent store for the built classifier model.
create_table :classifier_models, :force => true do |t| t.column :identifier, :int t.column :classifiable_type, :string, :null => false t.column :data, :blob end
Now, to use this plugin in your model, put:
class Comment < ActiveRecords::Base acts_as_classifiable :fields => ["text"], :categories => ["Spam", "Legit"] end
Let us assume that we have an instance of the above model in '@comment'. Then the classifier can be trained by calling the method `train'
@comment.train :legit
or
@comment.train :spam
Better have some additional helper functions in the model which will do so.
You can also untrain (use it with care) an instance, by using
@comment.untrain :spam
Bulk training and untraining is also possible by
Comment.train @comments, @classifications
where both @comments and @classifications are arrays, such that @classifications contain categorization of each message in @comments.
To use, the classifier to make classification:
@comment.classify
this will return either "Spam" or "Legit". Bulk classification is also possible.
If you want the comment class to have multiple classifiers, one for each user, then all the above methods can be given an additional argument `identifier'.
@comment.train :legit, @user.id
This will create and store a classifier for that particular model, identified by the `identifier'. This can be used in scenarios when one wants to track preference of each user and then want to make suggestions.
The Bayesian classifier in the gem classifier needs some work, but more about it later.
Further Documentation
There is currently no advanced documentation for this plugin.
New documentationEdit plugin | (0 older versions) | Last edited by: hardway, about 1 year ago

