Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename Metadata num_classes to be more clear #5461

Merged
merged 1 commit into from
Sep 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions include/LightGBM/dataset.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ class Metadata {
* \param values Initial score values for this record, one per class
*/
inline void SetInitScoreAt(data_size_t idx, const double* values) {
const auto nclasses = num_classes();
const auto nclasses = num_init_score_classes();
const double* val_ptr = values;
for (int i = idx; i < nclasses * num_data_; i += num_data_, ++val_ptr) {
init_score_[i] = *val_ptr;
Expand Down Expand Up @@ -265,7 +265,7 @@ class Metadata {
/*!
* \brief Get number of classes
*/
inline int32_t num_classes() const {
inline int32_t num_init_score_classes() const {
if (num_data_ && num_init_score_) {
return static_cast<int>(num_init_score_ / num_data_);
}
Expand Down
4 changes: 2 additions & 2 deletions src/io/metadata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ void Metadata::InitByReference(data_size_t num_data, const Metadata* reference)
int has_weights = reference->num_weights_ > 0;
int has_init_scores = reference->num_init_score_ > 0;
int has_queries = reference->num_queries_ > 0;
int nclasses = reference->num_classes();
int nclasses = reference->num_init_score_classes();
Init(num_data, has_weights, has_init_scores, has_queries, nclasses);
}

Expand Down Expand Up @@ -361,7 +361,7 @@ void Metadata::InsertInitScores(const double* init_scores, data_size_t start_ind
}
if (init_score_.empty()) { init_score_.resize(num_init_score_); }

int nclasses = num_classes();
int nclasses = num_init_score_classes();

for (int32_t col = 0; col < nclasses; ++col) {
int32_t dest_offset = num_data_ * col + start_index;
Expand Down