File label_vector_set.hpp

Functions

std::unique_ptr<ILabelVectorSet> createLabelVectorSet()

Creates and returns a new object of the type ILabelVectorSet.

Returns:

An unique pointer to an object of type ILabelVectorSet that has been created

class ILabelVectorSet : public ILabelSpaceInfo
#include <label_vector_set.hpp>

Defines an interface for all classes that provide access to a set of unique label vectors.

Subclassed by LabelVectorSet

Public Types

typedef std::function<void(const LabelVector&, uint32)> LabelVectorVisitor

A visitor function for handling objects of the type LabelVector and their frequencies.

Public Functions

inline virtual ~ILabelVectorSet() override
virtual void addLabelVector(std::unique_ptr<LabelVector> labelVectorPtr, uint32 frequency) = 0

Adds a label vector to the set.

Parameters:
  • labelVectorPtr – An unique pointer to an object of type LabelVector

  • frequency – The frequency of the label vector

virtual void visit(LabelVectorVisitor visitor) const = 0

Invokes the given visitor function for each label vector that has been added to the set.

Parameters:

visitor – The visitor function for handling objects of the type LabelVector

class LabelVectorSet : public ILabelVectorSet
#include <label_vector_set.hpp>

An implementation of the type ILabelVectorSet that stores a set of unique label vectors, as well as their frequency.

Public Types

typedef std::vector<std::unique_ptr<LabelVector>>::const_iterator const_iterator

An iterator that provides read-only access to the label vectors.

typedef std::vector<uint32>::const_iterator frequency_const_iterator

An iterator that provides read-only access to the frequency of the label lectors.

Public Functions

LabelVectorSet()
LabelVectorSet(const IRowWiseLabelMatrix &labelMatrix)
Parameters:

labelMatrix – A reference to an object of type IRowWiseLabelMatrix that stores the label vectors that should be added to the set

const_iterator cbegin() const

Returns a const_iterator to the beginning of the label vectors in the set.

Returns:

A const_iterator to the beginning

const_iterator cend() const

Returns a const_iterator to the end of the label vectors in the set.

Returns:

A const_iterator to the end

frequency_const_iterator frequencies_cbegin() const

Returns a frequency_const_iterator to the beginning of the frequencies.

Returns:

frequency_const_iterator A frequency_const_iterator to the beginning

frequency_const_iterator frequencies_cend() const

Returns a frequency_const_iterator to the end of the frequencies.

Returns:

frequency_const_iterator A frequency_const_iterator to the end

uint32 getNumLabelVectors() const

Returns the number of label vectors in the set.

Returns:

The number of label vectors

virtual void addLabelVector(std::unique_ptr<LabelVector> labelVectorPtr, uint32 frequency) override

Adds a label vector to the set.

Parameters:
  • labelVectorPtr – An unique pointer to an object of type LabelVector

  • frequency – The frequency of the label vector

virtual void visit(LabelVectorVisitor visitor) const override

Invokes the given visitor function for each label vector that has been added to the set.

Parameters:

visitor – The visitor function for handling objects of the type LabelVector

virtual std::unique_ptr<IJointProbabilityCalibrator> createJointProbabilityCalibrator(const IJointProbabilityCalibratorFactory &factory, const IMarginalProbabilityCalibrationModel &marginalProbabilityCalibrationModel) const override

Creates and returns a new instance of the class IJointProbabilityCalibrator, based on the type of this information about the label space.

Parameters:
Returns:

An unique pointer to an object of type IJointProbabilityPredictor that has been created

virtual std::unique_ptr<IBinaryPredictor> createBinaryPredictor(const IBinaryPredictorFactory &factory, const CContiguousView<const float32> &featureMatrix, const RuleList &ruleList, const IMarginalProbabilityCalibrationModel &marginalProbabilityCalibrationModel, const IJointProbabilityCalibrationModel &jointProbabilityCalibrationModel, uint32 numLabels) const override

Creates and returns a new instance of the class IBinaryPredictor, based on the type of this information about the label space.

Parameters:
  • factory – A reference to an object of type IBinaryPredictorFactory that should be used to create the instance

  • featureMatrix – A reference to an object of type CContiguousView that provides row-wise access to the features of the query examples

  • model – A reference to an object of type RuleList that should be used to obtain predictions

  • marginalProbabilityCalibrationModel – A reference to an object of type IMarginalProbabilityCalibrationModel that may be used for the calibration of marginal probabilities

  • jointProbabilityCalibrationModel – A reference to an object of type IJointProbabilityCalibrationModel that may be used for the calibration of joint probabilities

  • numLabels – The number of labels to predict for

Returns:

An unique pointer to an object of type IBinaryPredictor that has been created

virtual std::unique_ptr<IBinaryPredictor> createBinaryPredictor(const IBinaryPredictorFactory &factory, const CsrView<const float32> &featureMatrix, const RuleList &ruleList, const IMarginalProbabilityCalibrationModel &marginalProbabilityCalibrationModel, const IJointProbabilityCalibrationModel &jointProbabilityCalibrationModel, uint32 numLabels) const override

Creates and returns a new instance of the class IBinaryPredictor, based on the type of this information about the label space.

Parameters:
  • factory – A reference to an object of type IBinaryPredictorFactory that should be used to create the instance

  • featureMatrix – A reference to an object of type CsrView that provides row-wise access to the features of the query examples

  • model – A reference to an object of type RuleList that should be used to obtain predictions

  • marginalProbabilityCalibrationModel – A reference to an object of type IMarginalProbabilityCalibrationModel that may be used for the calibration of marginal probabilities

  • jointProbabilityCalibrationModel – A reference to an object of type IJointProbabilityCalibrationModel that may be used for the calibration of joint probabilities

  • numLabels – The number of labels to predict for

Returns:

An unique pointer to an object of type IBinaryPredictor that has been created

virtual std::unique_ptr<ISparseBinaryPredictor> createSparseBinaryPredictor(const ISparseBinaryPredictorFactory &factory, const CContiguousView<const float32> &featureMatrix, const RuleList &ruleList, const IMarginalProbabilityCalibrationModel &marginalProbabilityCalibrationModel, const IJointProbabilityCalibrationModel &jointProbabilityCalibrationModel, uint32 numLabels) const override

Creates and returns a new instance of the class ISparseBinaryPredictor, based on the type of this information about the label space.

Parameters:
  • factory – A reference to an object of type ISparseBinaryPredictorFactory that should be used to create the instance

  • featureMatrix – A reference to an object of type CContiguousView that provides row-wise access to the features of the query examples

  • model – A reference to an object of type RuleList that should be used to obtain predictions

  • marginalProbabilityCalibrationModel – A reference to an object of type IMarginalProbabilityCalibrationModel that may be used for the calibration of marginal probabilities

  • jointProbabilityCalibrationModel – A reference to an object of type IJointProbabilityCalibrationModel that may be used for the calibration of joint probabilities

  • numLabels – The number of labels to predict for

Returns:

An unique pointer to an object of type ISparseBinaryPredictor that has been created

virtual std::unique_ptr<ISparseBinaryPredictor> createSparseBinaryPredictor(const ISparseBinaryPredictorFactory &factory, const CsrView<const float32> &featureMatrix, const RuleList &ruleList, const IMarginalProbabilityCalibrationModel &marginalProbabilityCalibrationModel, const IJointProbabilityCalibrationModel &jointProbabilityCalibrationModel, uint32 numLabels) const override

Creates and returns a new instance of the class ISparseBinaryPredictor, based on the type of this information about the label space.

Parameters:
  • factory – A reference to an object of type ISparseBinaryPredictorFactory that should be used to create the instance

  • featureMatrix – A reference to an object of type CsrView that provides row-wise access to the features of the query examples

  • model – A reference to an object of type RuleList that should be used to obtain predictions

  • marginalProbabilityCalibrationModel – A reference to an object of type IMarginalProbabilityCalibrationModel that may be used for the calibration of marginal probabilities

  • jointProbabilityCalibrationModel – A reference to an object of type IJointProbabilityCalibrationModel that may be used for the calibration of joint probabilities

  • numLabels – The number of labels to predict for

Returns:

An unique pointer to an object of type ISparseBinaryPredictor that has been created

virtual std::unique_ptr<IScorePredictor> createScorePredictor(const IScorePredictorFactory &factory, const CContiguousView<const float32> &featureMatrix, const RuleList &ruleList, uint32 numLabels) const override

Creates and returns a new instance of the class IScorePredictor, based on the type of this information about the label space.

Parameters:
  • factory – A reference to an object of type IScorePredictorFactory that should be used to create the instance

  • featureMatrix – A reference to an object of type CContiguousView that provides row-wise access to the features of the query examples

  • model – A reference to an object of type RuleList that should be used to obtain predictions

  • numLabels – The number of labels to predict for

Returns:

An unique pointer to an object of type IScorePredictor that has been created

virtual std::unique_ptr<IScorePredictor> createScorePredictor(const IScorePredictorFactory &factory, const CsrView<const float32> &featureMatrix, const RuleList &ruleList, uint32 numLabels) const override

Creates and returns a new instance of the class IScorePredictor, based on the type of this information about the label space.

Parameters:
  • factory – A reference to an object of type IScorePredictorFactory that should be used to create the instance

  • featureMatrix – A reference to an object of type CsrView that provides row-wise access to the features of the query examples

  • model – A reference to an object of type RuleList that should be used to obtain predictions

  • numLabels – The number of labels to predict for

Returns:

An unique pointer to an object of type IScorePredictor that has been created

virtual std::unique_ptr<IProbabilityPredictor> createProbabilityPredictor(const IProbabilityPredictorFactory &factory, const CContiguousView<const float32> &featureMatrix, const RuleList &ruleList, const IMarginalProbabilityCalibrationModel &marginalProbabilityCalibrationModel, const IJointProbabilityCalibrationModel &jointProbabilityCalibrationModel, uint32 numLabels) const override

Creates and returns a new instance of the class IProbabilityPredictor, based on the type of this information about the label space.

Parameters:
  • factory – A reference to an object of type IProbabilityPredictorFactory that should be used to create the instance

  • featureMatrix – A reference to an object of type CContiguousView that provides row-wise access to the features of the query examples

  • model – A reference to an object of type RuleList that should be used to obtain predictions

  • marginalProbabilityCalibrationModel – A reference to an object of type IMarginalProbabilityCalibrationModel that may be used for the calibration of marginal probabilities

  • jointProbabilityCalibrationModel – A reference to an object of type IJointProbabilityCalibrationModel that may be used for the calibration of joint probabilities

  • numLabels – The number of labels to predict for

Returns:

An unique pointer to an object of type IProbabilityPredictor that has been created

virtual std::unique_ptr<IProbabilityPredictor> createProbabilityPredictor(const IProbabilityPredictorFactory &factory, const CsrView<const float32> &featureMatrix, const RuleList &ruleList, const IMarginalProbabilityCalibrationModel &marginalProbabilityCalibrationModel, const IJointProbabilityCalibrationModel &jointProbabilityCalibrationModel, uint32 numLabels) const override

Creates and returns a new instance of the class IProbabilityPredictor, based on the type of this information about the label space.

Parameters:
  • factory – A reference to an object of type IProbabilityPredictorFactory that should be used to create the instance

  • featureMatrix – A reference to an object of type CsrView that provides row-wise access to the features of the query examples

  • model – A reference to an object of type RuleList that should be used to obtain predictions

  • marginalProbabilityCalibrationModel – A reference to an object of type IMarginalProbabilityCalibrationModel that may be used for the calibration of marginal probabilities

  • jointProbabilityCalibrationModel – A reference to an object of type IJointProbabilityCalibrationModel that may be used for the calibration of joint probabilities

  • numLabels – The number of labels to predict for

Returns:

An unique pointer to an object of type IProbabilityPredictor that has been created

Private Members

std::vector<std::unique_ptr<LabelVector>> labelVectors_
std::vector<uint32> frequencies_