7 #include "spdlog/fmt/fmt.h"
14 m_LabelsBegin(spec.first_label), m_LabelsEnd(spec.first_label + spec.label_count), m_NumLabels(spec.total_labels)
17 throw std::invalid_argument( fmt::format(
"Total number of labels must be positive! Got {}.",
m_NumLabels) );
21 throw std::invalid_argument( fmt::format(
"Invalid label range [{}, {}) specified. Total number of labels"
22 "was declared as {}.",
30 throw std::out_of_range(
31 fmt::format(
"label index {} is invalid. Labels must be in [{}, {})",
43 throw std::invalid_argument(
44 fmt::format(
"target size {} does not match number of features {}.",
53 throw std::invalid_argument(
54 fmt::format(
"weight size {} does not match number of features {}.",
62 if(instances.
rows() != target.rows()) {
63 throw std::logic_error(fmt::format(
"Mismatch in number of rows between instances ({}) and target ({})",
64 instances.
rows(), target.rows()));
69 throw std::logic_error(
70 fmt::format(
"Wrong number of columns in target ({}). Expect one column for each of the {} labels.",
75 throw std::logic_error(
76 fmt::format(
"Wrong number of columns in instances ({}). Expect one column for each of the {} features.",
Strong typedef for an int to signify a label id.
label_id_t labels_end() const noexcept
virtual long num_features() const =0
How many weights are in each weight vector, i.e. how many features should the input have.
Model(PartialModelSpec spec)
long num_labels() const noexcept
How many labels are in the underlying dataset.
virtual void get_weights_for_label_unchecked(label_id_t label, Eigen::Ref< DenseRealVector > target) const =0
Unchecked version of get_weights_for_label().
Eigen::Ref< PredictionMatrix > PredictionMatrixOut
virtual void predict_scores_unchecked(const FeatureMatrixIn &instances, PredictionMatrixOut target) const =0
Unchecked version of predict_scores().
void set_weights_for_label(label_id_t label, const WeightVectorIn &weights)
Sets the weights for a label.
bool is_partial_model() const
returns true if this instance only stores part of the weights of an entire model
long num_weights() const noexcept
How many weights vectors are in this model.
virtual void set_weights_for_label_unchecked(label_id_t label, const WeightVectorIn &weights)=0
Unchecked version of set_weights_for_label().
long m_NumLabels
Total number of labels of the complete model.
void get_weights_for_label(label_id_t label, Eigen::Ref< DenseRealVector > target) const
Gets the weights for the given label as a dense vector.
label_id_t labels_begin() const noexcept
void predict_scores(const FeatureMatrixIn &instances, PredictionMatrixOut target) const
Calculates the scores for all examples and all labels in this model.
label_id_t adjust_label(label_id_t label) const
constexpr T to_index() const
! Explicitly convert to an integer.
Main namespace in which all types, classes, and functions are defined.
Specifies how to interpret a weight matrix for a partial model.