22 std::shared_ptr<const GenericFeatureMatrix> local_features,
37 [[nodiscard]] std::unique_ptr<WeightsInitializer>
38 make_initializer(
const std::shared_ptr<const GenericFeatureMatrix>& features)
const override;
45 std::shared_ptr<const GenericFeatureMatrix> local_features,
61 int num_pos =
m_DataSet->num_positives(label_id);
62 visit([&](
const auto& matrix) {
66 target += matrix.row(i) / (real_t)num_pos;
80 temp.modify().setZero();
82 return 100.f * (obj_at_zero - obj_at_new) / obj_at_zero;
91 return std::make_shared<MeanOfFeaturesStrategy>(std::move(data), pos, neg);
An Eigen vector with versioning information, to implement simple caching of results.
void get_initial_weight(label_id_t label_id, Eigen::Ref< DenseRealVector > target, objective::Objective &objective) override
Generate an initial vector for the given label. The result should be placed in target.
static constexpr stats::stat_id_t STAT_LOSS_REDUCTION
static constexpr stats::stat_id_t STAT_ALL_MEAN_FACTOR
static constexpr stats::stat_id_t STAT_NUM_POS
MeanOfFeaturesInitializer(std::shared_ptr< const DatasetBase > data, const DenseRealVector &mean_of_all, std::shared_ptr< const GenericFeatureMatrix > local_features, real_t pos, real_t neg)
static constexpr stats::stat_id_t STAT_POSITIVE_FACTOR
std::unique_ptr< WeightsInitializer > make_initializer(const std::shared_ptr< const GenericFeatureMatrix > &features) const override
Creats a new, thread local WeightsInitializer.
std::shared_ptr< const DatasetBase > m_DataSet
std::shared_ptr< const GenericFeatureMatrix > m_LocalFeatures
DenseRealVector m_MeanOfAll
std::pair< real_t, real_t > calculate_factors(label_id_t label_id, const Eigen::Ref< DenseRealVector > &mean_of_positives)
BinaryLabelVector m_LabelBuffer
static constexpr stats::stat_id_t STAT_DURATION
SubsetFeatureMeanStrategy(std::shared_ptr< const DatasetBase > data, real_t negative_target, real_t positive_target)
std::shared_ptr< const DatasetBase > m_DataSet
DenseRealVector m_MeanOfAllInstances
Strong typedef for an int to signify a label id.
Class that models an optimization objective.
void record(stat_id_t stat, T &&value)
Record statistics. This function just forwards all its arguments to the internal StatisticsCollection...
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...
std::shared_ptr< WeightInitializationStrategy > create_feature_mean_initializer(std::shared_ptr< DatasetBase > data, real_t pos=1, real_t neg=-2)
Creates an initialization strategy based on the mean of positive and negative features.
auto visit(F &&f, Variants &&... variants)
types::DenseVector< real_t > DenseRealVector
Any dense, real values vector.
float real_t
The default type for floating point values.