9 #include "spdlog/spdlog.h"
14 return (
get_labels(
id)->array() == 1.0).count();
23 auto label_vector = std::make_shared<BinaryLabelVector>(
num_examples());
30 throw std::out_of_range(
"Binary problems only have a single class with id `0`");
40 return std::const_pointer_cast<const GenericFeatureMatrix>(
m_Features);
66 target.setConstant(-1);
67 for(
const auto& ex : examples) {
68 target.coeffRef(ex) = 1;
89 std::vector<std::vector<long>> sub_labels;
90 sub_labels.reserve(end-start);
std::shared_ptr< BinaryLabelVector > m_Labels
void get_labels(label_id_t i, Eigen::Ref< BinaryLabelVector > target) const override
long num_labels() const noexcept override
virtual long num_negatives(label_id_t id) const
long num_examples() const noexcept
Get the total number of instances, i.e. the number of rows in the feature matrix.
DatasetBase(const DatasetBase &)=default
std::shared_ptr< const BinaryLabelVector > get_labels(label_id_t id) const
virtual long num_positives(label_id_t id) const
std::shared_ptr< const GenericFeatureMatrix > get_features() const
get a shared pointer to the (immutable) feature data
std::shared_ptr< GenericFeatureMatrix > m_Features
long num_features() const noexcept
Get the total number of features, i.e. the number of columns in the feature matrix.
std::shared_ptr< GenericFeatureMatrix > edit_features()
get a shared pointer to mutable feature data. Use with care.
std::vector< std::vector< long > > m_Labels
long num_positives(label_id_t id) const override
long num_labels() const noexcept override
void get_labels(label_id_t label, Eigen::Ref< BinaryLabelVector > target) const override
const std::vector< long > & get_label_instances(label_id_t label) const
void select_labels(label_id_t start, label_id_t end)
long num_negatives(label_id_t id) const override
Strong typedef for an int to signify a label id.
constexpr T to_index() const
! Explicitly convert to an integer.
Main namespace in which all types, classes, and functions are defined.
types::DenseRowMajor< real_t > DenseFeatures
Dense Feature Matrix in Row Major format.
constexpr auto ssize(const C &c) -> std::common_type_t< std::ptrdiff_t, std::make_signed_t< decltype(c.size())>>
signed size free function. Taken from https://en.cppreference.com/w/cpp/iterator/size
types::SparseRowMajor< real_t > SparseFeatures
Sparse Feature Matrix in Row Major format.