ModErn Text Analysis
META Enumerates Textual Applications
|
Generalizes binary classifiers to operate over multiclass types using the one vs all method. More...
#include <one_vs_all.h>
Public Member Functions | |
template<class Function > | |
one_vs_all (std::shared_ptr< index::forward_index > idx, Function &&create) | |
Constructs a new one_vs_all classifier on the given index by using the given function to create binary_classifiers. More... | |
void | train (const std::vector< doc_id > &docs) override |
Creates a classification model based on training documents. More... | |
class_label | classify (doc_id d_id) override |
Classifies a document into a specific group, as determined by training data. More... | |
void | reset () override |
Clears any learning data associated with this classifier. | |
Public Member Functions inherited from meta::classify::classifier | |
classifier (std::shared_ptr< index::forward_index > idx) | |
virtual confusion_matrix | test (const std::vector< doc_id > &docs) |
Classifies a collection document into specific groups, as determined by training data; this function will make repeated calls to classify(). More... | |
virtual confusion_matrix | cross_validate (const std::vector< doc_id > &input_docs, size_t k, bool even_split=false, int seed=1) |
Performs k-fold cross-validation on a set of documents. More... | |
Static Public Attributes | |
static const std::string | id = "one-vs-all" |
The identifier for this classifier. | |
Private Attributes | |
std::unordered_map< class_label, std::unique_ptr< binary_classifier > > | classifiers_ |
The set of classifiers this ensemble uses for classification. | |
Additional Inherited Members | |
Protected Attributes inherited from meta::classify::classifier | |
std::shared_ptr< index::forward_index > | idx_ |
the index that the classifer is run on | |
Generalizes binary classifiers to operate over multiclass types using the one vs all method.
|
inline |
Constructs a new one_vs_all classifier on the given index by using the given function to create binary_classifiers.
The create
parameter must take a single parameter: the positive label for the binary classifier to be created.
idx | The forward_index to be passed to each binary_classifier created for the ensemble |
create | A Callable (function object, lambda, etc.) that is used to create the individual binary_classifiers. |
|
overridevirtual |
Creates a classification model based on training documents.
docs | The training documents |
Implements meta::classify::classifier.
|
overridevirtual |
Classifies a document into a specific group, as determined by training data.
d_id | The document to classify |
Implements meta::classify::classifier.