ModErn Text Analysis
META Enumerates Textual Applications
Public Member Functions | Static Public Attributes | Private Attributes | List of all members
meta::classify::one_vs_one Class Reference

Ensemble method adaptor for extending binary_classifiers to the multi-class classification case by using a one-vs-one strategy. More...

#include <one_vs_one.h>

Inheritance diagram for meta::classify::one_vs_one:
meta::classify::classifier

Public Member Functions

template<class Function >
 one_vs_one (std::shared_ptr< index::forward_index > idx, Function &&create)
 Constructs a new one_vs_one classifier using the given forward_index to retrieve document information and using the given function to create individual binary_classifiers for each pair of classes. 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-one"
 The identifier for this classifier.
 

Private Attributes

std::vector< std::unique_ptr< binary_classifier > > classifiers_
 the set of classifiers used in the ensemble
 

Additional Inherited Members

- Protected Attributes inherited from meta::classify::classifier
std::shared_ptr< index::forward_indexidx_
 the index that the classifer is run on
 

Detailed Description

Ensemble method adaptor for extending binary_classifiers to the multi-class classification case by using a one-vs-one strategy.

This entails creating a classifier for each pair of classes, and assigning the label which gets the most "votes" from each individual binary_classifier as the label for a given document.

Constructor & Destructor Documentation

template<class Function >
meta::classify::one_vs_one::one_vs_one ( std::shared_ptr< index::forward_index idx,
Function &&  create 
)
inline

Constructs a new one_vs_one classifier using the given forward_index to retrieve document information and using the given function to create individual binary_classifiers for each pair of classes.

Parameters
idxThe forward_index to retrieve documents from
createA function to create binary_classifiers: should return a unique_ptr to a binary_classifier when given two class labels as parameters

Member Function Documentation

void meta::classify::one_vs_one::train ( const std::vector< doc_id > &  docs)
overridevirtual

Creates a classification model based on training documents.

Parameters
docsThe training documents

Implements meta::classify::classifier.

class_label meta::classify::one_vs_one::classify ( doc_id  d_id)
overridevirtual

Classifies a document into a specific group, as determined by training data.

Parameters
d_idThe document to classify
Returns
the class it belongs to

Implements meta::classify::classifier.


The documentation for this class was generated from the following files: