A classifier which classifies documents as "positive" or "negative".
More...
#include <binary_classifier.h>
|
| 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 |
|
| 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.
|
|
|
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".
|
|
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.
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
-
idx | The forward_index to read documents from |
positive | The class label to return for "positive" documents |
negative | The class label to return for "negative" documents |
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_id | The 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_id | The 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: