Module: Cabalist::ModelAdditions
- Defined in:
- lib/cabalist/model_additions.rb
Overview
Core functionality of Cabalist.
This module is a placeholder for methods that are mixed in with ActiveRecord::Base as well as those that are created by calling acts_as_cabalist method from within the class definition of an inheriting class.
Class Method Summary (collapse)
-
+ (void) acts_as_cabalist(opts = {})
Class helper to add Cabalist functionality to a Rails model.
-
+ (ActiveRecord::Relation) auto_classified
Automatically classified records.
-
+ (Ai4r::Classifiers::Object) build_model
Build the classification model from scratch.
-
+ (Array) class_variable_domain
Show possible values for the classification.
-
+ (Ai4r::Classifiers::Object) classifier
Get the classification model for a given class.
-
+ (Symbol) get_class_variable_name
Get name of class variable.
-
+ (Array) get_feature_names
Get names of feature attributes.
-
+ (ActiveRecord::Relation) manually_classified
Manually classified records.
-
+ (ActiveRecord::Relation) not_classified
Records that have not yet been classified.
Instance Method Summary (collapse)
-
- (Object) classify
Get predicted value of the class variable.
-
- (self) classify!
Set the class variable to the value suggested by the classifier.
-
- (Object) get_class_variable
Value of the class variable.
-
- (Array) get_features
Get an array of features.
-
- (Object) set_class_variable(new_class_variable)
Set the value of the class variable.
-
- (Object) teach(new_class_variable)
Set the value of the class variable.
-
- (Ai4r::Classifiers::Object) train_model
Build the classification model from scratch and store it in cache.
Class Method Details
+ (void) acts_as_cabalist(opts = {})
This method returns an undefined value.
Class helper to add Cabalist functionality to a Rails model.
39 |
# File 'lib/cabalist/model_additions.rb', line 39 def self.acts_as_cabalist(opts={}) end |
+ (ActiveRecord::Relation) auto_classified
Automatically classified records.
Named scope which returns objects that were classified automatically. That means they have their class variable value set as well as non-nil value of autoclassified_at attribute.
57 |
# File 'lib/cabalist/model_additions.rb', line 57 def self.auto_classified() end |
+ (Ai4r::Classifiers::Object) build_model
Build the classification model from scratch.
You should probably not use this method directly as it will go ahead and compute the classifier anew each and every time instead of looking at any cached versions.
121 |
# File 'lib/cabalist/model_additions.rb', line 121 def self.build_model() end |
+ (Array) class_variable_domain
Show possible values for the classification.
This method will return all unique values of the class variable that the classifier knows about. If any new values have been added after the classifier has last been retrained, they will not find their way here.
151 |
# File 'lib/cabalist/model_additions.rb', line 151 def self.class_variable_domain() end |
+ (Ai4r::Classifiers::Object) classifier
Get the classification model for a given class.
This method will try to find a ready model in the local cache but having failed that will resort to the ‘train_model’ to create one.
142 |
# File 'lib/cabalist/model_additions.rb', line 142 def self.classifier() end |
+ (Symbol) get_class_variable_name
Get name of class variable.
This method returns the class variable name (as symbol) as it has been passed to the acts_as_cabalist method call as :class_variable option.
110 |
# File 'lib/cabalist/model_additions.rb', line 110 def self.get_class_variable_name() end |
+ (Array) get_feature_names
Get names of feature attributes.
This method returns the Array of attribute names (as symbols) as they have been passed to the acts_as_cabalist method call as :features option.
102 |
# File 'lib/cabalist/model_additions.rb', line 102 def self.get_feature_names() end |
+ (ActiveRecord::Relation) manually_classified
Manually classified records.
Named scope which returns objects that were classified but not automatically, that is they have their class variable value set but autoclassified_at nil.
48 |
# File 'lib/cabalist/model_additions.rb', line 48 def self.manually_classified() end |
+ (ActiveRecord::Relation) not_classified
Records that have not yet been classified.
Named scope which returns objects that were classified automatically. That means they have their class variable value set as well as non-nil value of autoclassified_at attribute.
66 |
# File 'lib/cabalist/model_additions.rb', line 66 def self.not_classified() end |
Instance Method Details
- (Object) classify
Get predicted value of the class variable
This method will query the classifier of the instance’s corresponding class for the predicted classification of this instance, given the value of its features.
160 |
# File 'lib/cabalist/model_additions.rb', line 160 def classify() end |
- (self) classify!
Set the class variable to the value suggested by the classifier
This method will query the classifier of the instance’s corresponding class for the predicted classification of this instance, given the value of its features and then set the class variable to that value.
169 |
# File 'lib/cabalist/model_additions.rb', line 169 def classify!() end |
- (Object) get_class_variable
Value of the class variable.
This method returns the value of an attribute passed as the :class_variable option of the acts_as_cabalist method call.
84 |
# File 'lib/cabalist/model_additions.rb', line 84 def get_class_variable() end |
- (Array) get_features
Get an array of features.
Returns an Array of values which result from methods passed as the :feature option of the acts_as_cabalist method call. Each of this methods is called upon current instance and results are returned.
76 |
# File 'lib/cabalist/model_additions.rb', line 76 def get_features() end |
- (Object) set_class_variable(new_class_variable)
Set the value of the class variable.
This method sets the value of an attribute passed as the :class_variable option of the acts_as_cabalist method call to the new value.
94 |
# File 'lib/cabalist/model_additions.rb', line 94 def set_class_variable(new_class_variable) end |
- (Object) teach(new_class_variable)
Set the value of the class variable.
This method sets the value of an attribute passed as the :class_variable option of the acts_as_cabalist method call to the new value and sets the autoclassified_at to nil so that current object is not treated as automatically classified.
180 |
# File 'lib/cabalist/model_additions.rb', line 180 def teach(new_class_variable) end |
- (Ai4r::Classifiers::Object) train_model
Build the classification model from scratch and store it in cache.
This method will use a ‘build_model’ call to create a model from scratch but once it has been created, it will also be immediately stored in the cache for further retrieval using the ‘classifier’ method.
132 |
# File 'lib/cabalist/model_additions.rb', line 132 def train_model() end |