Skip to content

Commit

Permalink
fix trival typo (#1915)
Browse files Browse the repository at this point in the history
  • Loading branch information
lingxz authored and guolinke committed Dec 20, 2018
1 parent c9bcba4 commit 92e95e6
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 20 deletions.
8 changes: 4 additions & 4 deletions include/LightGBM/bin.h
Expand Up @@ -92,8 +92,8 @@ class BinMapper {
inline int num_bin() const { return num_bin_; }
/*! \brief Missing Type */
inline MissingType missing_type() const { return missing_type_; }
/*! \brief True if bin is trival (contains only one bin) */
inline bool is_trival() const { return is_trival_; }
/*! \brief True if bin is trivial (contains only one bin) */
inline bool is_trivial() const { return is_trivial_; }
/*! \brief Sparsity of this bin ( num_zero_bins / num_data ) */
inline double sparse_rate() const { return sparse_rate_; }
/*!
Expand Down Expand Up @@ -190,8 +190,8 @@ class BinMapper {
MissingType missing_type_;
/*! \brief Store upper bound for each bin */
std::vector<double> bin_upper_bound_;
/*! \brief True if this feature is trival */
bool is_trival_;
/*! \brief True if this feature is trivial */
bool is_trivial_;
/*! \brief Sparse rate of this bins( num_bin0/num_data ) */
double sparse_rate_;
/*! \brief Type of this bin */
Expand Down
28 changes: 14 additions & 14 deletions src/io/bin.cpp
Expand Up @@ -25,7 +25,7 @@ namespace LightGBM {
BinMapper::BinMapper(const BinMapper& other) {
num_bin_ = other.num_bin_;
missing_type_ = other.missing_type_;
is_trival_ = other.is_trival_;
is_trivial_ = other.is_trivial_;
sparse_rate_ = other.sparse_rate_;
bin_type_ = other.bin_type_;
if (bin_type_ == BinType::NumericalBin) {
Expand Down Expand Up @@ -376,24 +376,24 @@ namespace LightGBM {
}
}

// check trival(num_bin_ == 1) feature
// check trivial(num_bin_ == 1) feature
if (num_bin_ <= 1) {
is_trival_ = true;
is_trivial_ = true;
} else {
is_trival_ = false;
is_trivial_ = false;
}
// check useless bin
if (!is_trival_ && NeedFilter(cnt_in_bin, static_cast<int>(total_sample_cnt), min_split_data, bin_type_)) {
is_trival_ = true;
if (!is_trivial_ && NeedFilter(cnt_in_bin, static_cast<int>(total_sample_cnt), min_split_data, bin_type_)) {
is_trivial_ = true;
}

if (!is_trival_) {
if (!is_trivial_) {
default_bin_ = ValueToBin(0);
if (bin_type_ == BinType::CategoricalBin) {
CHECK(default_bin_ > 0);
}
}
if (!is_trival_) {
if (!is_trivial_) {
// calculate sparse rate
sparse_rate_ = static_cast<double>(cnt_in_bin[default_bin_]) / static_cast<double>(total_sample_cnt);
} else {
Expand All @@ -420,8 +420,8 @@ namespace LightGBM {
buffer += sizeof(num_bin_);
std::memcpy(buffer, &missing_type_, sizeof(missing_type_));
buffer += sizeof(missing_type_);
std::memcpy(buffer, &is_trival_, sizeof(is_trival_));
buffer += sizeof(is_trival_);
std::memcpy(buffer, &is_trivial_, sizeof(is_trivial_));
buffer += sizeof(is_trivial_);
std::memcpy(buffer, &sparse_rate_, sizeof(sparse_rate_));
buffer += sizeof(sparse_rate_);
std::memcpy(buffer, &bin_type_, sizeof(bin_type_));
Expand All @@ -444,8 +444,8 @@ namespace LightGBM {
buffer += sizeof(num_bin_);
std::memcpy(&missing_type_, buffer, sizeof(missing_type_));
buffer += sizeof(missing_type_);
std::memcpy(&is_trival_, buffer, sizeof(is_trival_));
buffer += sizeof(is_trival_);
std::memcpy(&is_trivial_, buffer, sizeof(is_trivial_));
buffer += sizeof(is_trivial_);
std::memcpy(&sparse_rate_, buffer, sizeof(sparse_rate_));
buffer += sizeof(sparse_rate_);
std::memcpy(&bin_type_, buffer, sizeof(bin_type_));
Expand All @@ -472,7 +472,7 @@ namespace LightGBM {
void BinMapper::SaveBinaryToFile(const VirtualFileWriter* writer) const {
writer->Write(&num_bin_, sizeof(num_bin_));
writer->Write(&missing_type_, sizeof(missing_type_));
writer->Write(&is_trival_, sizeof(is_trival_));
writer->Write(&is_trivial_, sizeof(is_trivial_));
writer->Write(&sparse_rate_, sizeof(sparse_rate_));
writer->Write(&bin_type_, sizeof(bin_type_));
writer->Write(&min_val_, sizeof(min_val_));
Expand All @@ -486,7 +486,7 @@ namespace LightGBM {
}

size_t BinMapper::SizesInByte() const {
size_t ret = sizeof(num_bin_) + sizeof(missing_type_) + sizeof(is_trival_) + sizeof(sparse_rate_)
size_t ret = sizeof(num_bin_) + sizeof(missing_type_) + sizeof(is_trivial_) + sizeof(sparse_rate_)
+ sizeof(bin_type_) + sizeof(min_val_) + sizeof(max_val_) + sizeof(default_bin_);
if (bin_type_ == BinType::NumericalBin) {
ret += sizeof(double) * num_bin_;
Expand Down
2 changes: 1 addition & 1 deletion src/io/dataset.cpp
Expand Up @@ -221,7 +221,7 @@ void Dataset::Construct(
// get num_features
std::vector<int> used_features;
for (int i = 0; i < static_cast<int>(bin_mappers.size()); ++i) {
if (bin_mappers[i] != nullptr && !bin_mappers[i]->is_trival()) {
if (bin_mappers[i] != nullptr && !bin_mappers[i]->is_trivial()) {
used_features.emplace_back(i);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/treelearner/gpu_tree_learner.cpp
Expand Up @@ -249,7 +249,7 @@ void GPUTreeLearner::AllocateGPUMemory() {
sparse_feature_group_map_.clear();
// do nothing if no features can be processed on GPU
if (!num_dense_feature_groups_) {
Log::Warning("GPU acceleration is disabled because no non-trival dense features can be found");
Log::Warning("GPU acceleration is disabled because no non-trivial dense features can be found");
return;
}
// allocate memory for all features (FIXME: 4 GB barrier on some devices, need to split to multiple buffers)
Expand Down

0 comments on commit 92e95e6

Please sign in to comment.