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

A classifier which classifies documents as "positive" or "negative". More...

#include <binary_classifier.h>

Inheritance diagram for meta::classify::binary_classifier:
meta::classify::classifier meta::classify::sgd

Public Member Functions

 binary_classifier (std::shared_ptr< index::forward_index > idx, class_label positive, class_label negative)
 Creates a new binary classifier using the given index to retrieve documents, treating anything with the given positive label as a positive example and everything else as a negative example. More...
 
class_label classify (doc_id d_id) final
 Classifies a document into a specific group, as determined by training data. More...
 
virtual double predict (doc_id d_id) const =0
 
const class_label & positive_label () const
 
const class_label & negative_label () const
 
- Public Member Functions inherited from meta::classify::classifier
 classifier (std::shared_ptr< index::forward_index > idx)
 
virtual void train (const std::vector< doc_id > &docs)=0
 Creates a classification model based on training documents. More...
 
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...
 
virtual void reset ()=0
 Clears any learning data associated with this classifier.
 

Private Attributes

const class_label positive_
 The label that marks positive examples.
 
const class_label negative_
 The label to return when an example is classified as "negative".
 

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

A classifier which classifies documents as "positive" or "negative".

This classifier must be given the label to consider as a "positive" example and the label to return for a "negative" example.

Constructor & Destructor Documentation

meta::classify::binary_classifier::binary_classifier ( std::shared_ptr< index::forward_index idx,
class_label  positive,
class_label  negative 
)

Creates a new binary classifier using the given index to retrieve documents, treating anything with the given positive label as a positive example and everything else as a negative example.

The negative class label will be returned for anything that is deemed negative.

Parameters
idxThe forward_index to read documents from
positiveThe class label to return for "positive" documents
negativeThe class label to return for "negative" documents

Member Function Documentation

class_label meta::classify::binary_classifier::classify ( doc_id  d_id)
finalvirtual

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.

virtual double meta::classify::binary_classifier::predict ( doc_id  d_id) const
pure virtual
Parameters
d_idThe document to classify
Returns
the "confidence" that this document is a positive example

Implemented in meta::classify::sgd.

const class_label & meta::classify::binary_classifier::positive_label ( ) const
Returns
the "positive" label for this classifier
const class_label & meta::classify::binary_classifier::negative_label ( ) const
Returns
the "negative" label for this classifier

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