19 m_FeatureMatrix( std::move(X) ),
20 m_X_times_w( m_FeatureMatrix->rows() ),
21 m_LsCache_xTd( m_FeatureMatrix->rows() ),
22 m_LsCache_xTw( m_FeatureMatrix->rows() ),
23 m_Costs( m_FeatureMatrix->rows() ),
24 m_Y( m_FeatureMatrix->rows() )
56 visit([&](
auto&& features) {
64 visit([&](
auto&& features) {
76 for(
int i = 0; i <
m_Costs.size(); ++i) {
77 if(
m_Y.coeff(i) == 1) {
An Eigen vector with versioning information, to implement simple caching of results.
VectorHash hash() const
Gets the unique id of this vector.
const SparseFeatures & sparse_features() const
std::shared_ptr< const GenericFeatureMatrix > m_FeatureMatrix
DenseRealVector m_X_times_w
cache for the last result of x_times_w() corresponding to m_Last_W.
long num_instances() const noexcept
VectorHash m_Last_W
cache for the last argument to x_times_w().
long num_variables() const noexcept override
virtual void invalidate_labels()=0
LinearClassifierBase(std::shared_ptr< const GenericFeatureMatrix > X)
const DenseRealVector & costs() const
const DenseFeatures & dense_features() const
DenseRealVector m_Costs
Label-Dependent costs.
DenseRealVector m_LsCache_xTw
cache for line search implementation: feature times weights
BinaryLabelVector m_Y
Label vector – use a vector of ints here. We encode label present == 1, absent == -1.
void update_costs(real_t positive, real_t negative)
void project_linear_to_line(const HashVector &location, const DenseRealVector &direction)
Prepares the cache variables for line projection.
DenseRealVector m_LsCache_xTd
cache for line search implementation: feature times direction
BinaryLabelVector & get_label_ref()
const BinaryLabelVector & labels() const
const GenericFeatureMatrix & generic_features() const
const DenseRealVector & x_times_w(const HashVector &w)
Calculates the vector of feature matrix times weights w
auto make_timer(stat_id_t id, Args... args)
Creates a new ScopeTimer using stats::record_scope_time.
void declare_stat(stat_id_t index, StatisticMetaData meta)
Declares a new statistics. This function just forwards all its arguments to the internal StatisticsCo...
constexpr const dismec::stats::stat_id_t STAT_PERF_MATMUL
auto visit(F &&f, Variants &&... variants)
Main namespace in which all types, classes, and functions are defined.
types::DenseRowMajor< real_t > DenseFeatures
Dense Feature Matrix in Row Major format.
types::DenseVector< std::int8_t > BinaryLabelVector
Dense vector for storing binary labels.
types::DenseVector< real_t > DenseRealVector
Any dense, real values vector.
types::SparseRowMajor< real_t > SparseFeatures
Sparse Feature Matrix in Row Major format.
float real_t
The default type for floating point values.