Class Classifier

Inheritance Relationships

Derived Types

Class Documentation

class cpphots::Classifier

An interface for a generic distance-based classification method.

Given a new features this classifier will search the stored set of feature to find the closest one.

The classifier can maintain a list of labels which can be the output of the classification. Alternatively, it can work with class indexes.

Prior to using any of the classify methods, the features should be initialized with setClassFeatures.

Subclassed by cpphots::BhattacharyyaClassifier, cpphots::NormalizedClassifier, cpphots::StandardClassifier

Public Functions

explicit Classifier(size_t n_classes)

Construct a new Classifier object.

The constructed classifier will only work with class indexes.

Parameters

n_classes – the number of classes for the classification task

explicit Classifier(const std::vector<std::string> &l_classes)

Construct a new Classifier object.

The constructed classifier will work with both class labels and indexes.

Parameters

l_classes – a list of class labels

explicit Classifier(Classifier *other)

Copy-construct a new Classifier object.

This constructed classifier will copy the class-features associations from the argument. The argument should be a classifier where the setClassFeatures method has already been called.

Parameters

other – an alrady set-up classifier

void setClassFeatures(size_t cid, const Features &feats)

Assign features to a class.

Parameters
  • cid – index of the class

  • feats – features to assign to the class

void setClassFeatures(const std::string &clabel, const Features &feats)

Assign features to a class.

Parameters
  • clabel – label of the class

  • feats – features to assign to the class

size_t classifyID(const Features &feats) const

Classify features.

This method outputs the ID of the predicted class.

Parameters

feats – features

Returns

index the predicted class

std::string classifyName(const Features &feats) const

Classify features.

This method outputs the label of the predicted class. This method will raise an erro if the Classifier has not been constructed using labels.

Parameters

feats – features

Returns

label of the predicted class