File predictor_probability_common.hpp

namespace boosting
template<typename FeatureMatrix, typename Model>
class ProbabilityPredictor : public IProbabilityPredictor
#include <predictor_probability_common.hpp>

An implementation of the type IProbabilityPredictor that allows to predict label-wise probability estimates for given query examples, estimating the chance of individual labels to be relevant, by summing up the scores that are predicted by individual rules in a rule-based model and transforming the aggregated scores into probabilities in [0, 1] according to an IProbabilityTransformation.

Template Parameters:
  • FeatureMatrix – The type of the feature matrix that provides row-wise access to the feature values of the query examples

  • Model – The type of the rule-based model that is used to obtain predictions

Public Functions

inline ProbabilityPredictor(const FeatureMatrix &featureMatrix, const Model &model, uint32 numLabels, uint32 numThreads, std::unique_ptr<IProbabilityTransformation> probabilityTransformationPtr)
Parameters:
  • featureMatrix – A reference to an object of template type FeatureMatrix that provides row-wise access to the feature values of the query examples

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

  • numLabels – The number of labels to predict for

  • numThreads – The number of CPU threads to be used to make predictions for different query examples in parallel. Must be at least 1

  • probabilityTransformationPtr – An unique pointer to an object of type IProbabilityTransformation that should be used to transform aggregated scores into probability estimates or a null pointer, if all probabilities should be set to zero

inline std::unique_ptr<DensePredictionMatrix<float64>> predict(uint32 maxRules) const override

See also

IPredictor::predict

inline bool canPredictIncrementally() const override

See also

IPredictor::canPredictIncrementally

inline std::unique_ptr<IIncrementalPredictor<DensePredictionMatrix<float64>>> createIncrementalPredictor(uint32 maxRules) const override

See also

IPredictor::createIncrementalPredictor

Private Members

const FeatureMatrix &featureMatrix_
const Model &model_
const uint32 numLabels_
const uint32 numThreads_
const std::shared_ptr<IProbabilityTransformation> probabilityTransformationPtr_
class IncrementalPredictor : public AbstractIncrementalPredictor<FeatureMatrix, Model, DensePredictionMatrix<float64>>

Public Functions

inline IncrementalPredictor(const ProbabilityPredictor &predictor, uint32 maxRules, std::shared_ptr<IProbabilityTransformation> probabilityTransformationPtr)

Protected Functions

inline DensePredictionMatrix<float64> &applyNext(const FeatureMatrix &featureMatrix, uint32 numThreads, typename Model::const_iterator rulesBegin, typename Model::const_iterator rulesEnd) override

Private Members

const std::shared_ptr<IProbabilityTransformation> probabilityTransformationPtr_
DensePredictionMatrix<float64> scoreMatrix_
DensePredictionMatrix<float64> predictionMatrix_
class PredictionDelegate : public PredictionDispatcher::IPredictionDelegate

Public Functions

inline PredictionDelegate(CContiguousView<float64> &scoreMatrix, CContiguousView<float64> &predictionMatrix, const IProbabilityTransformation &probabilityTransformation)
inline void predictForExample(const FeatureMatrix &featureMatrix, typename Model::const_iterator rulesBegin, typename Model::const_iterator rulesEnd, uint32 threadIndex, uint32 exampleIndex, uint32 predictionIndex) const override

Private Members

CContiguousView<float64> &scoreMatrix_
CContiguousView<float64> &predictionMatrix_
const IProbabilityTransformation &probabilityTransformation_