8 #include "spdlog/fmt/fmt.h"
27 throw std::invalid_argument(error_msg);
38 Model(partial), m_Weights(std::move(weights))
41 throw std::invalid_argument(fmt::format(
"Declared {} weights, but got matrix with {} columns",
53 check_positive(num_features,
"Number of features must be positive!"),
54 check_positive(partial.label_count,
"Number of weight must be positive!")),
71 visit([
this, label](
auto&& v){
77 visit([&,
this](
const auto& features) {
78 target.noalias() = features * (*
m_Weights);
Strong typedef for an int to signify a label id.
Implementation of the Model class that stores the weights as a single, dense matrix.
types::DenseColMajor< real_t > WeightMatrix
weight_matrix_ptr m_Weights
The matrix of weights.
void set_weights_for_label_unchecked(label_id_t label, const WeightVectorIn &weights) override
Unchecked version of set_weights_for_label().
long num_features() const override
How many weights are in each weight vector, i.e. how many features should the input have.
void predict_scores_unchecked(const FeatureMatrixIn &instances, PredictionMatrixOut target) const override
Unchecked version of predict_scores().
void get_weights_for_label_unchecked(label_id_t label, Eigen::Ref< DenseRealVector > target) const override
Unchecked version of get_weights_for_label().
std::shared_ptr< WeightMatrix > weight_matrix_ptr
DenseModel(const weight_matrix_ptr &weights)
Creates a (complete) dense model with the given weight matrix.
A model combines a set of weight with some meta-information about these weights.
Eigen::Ref< PredictionMatrix > PredictionMatrixOut
constexpr T to_index() const
! Explicitly convert to an integer.
long check_positive(long v, const char *error_msg)
Checks that v is positive and returns v.
auto visit(F &&f, Variants &&... variants)
Main namespace in which all types, classes, and functions are defined.
Specifies how to interpret a weight matrix for a partial model.
long label_count
Number of labels in the partial model.