"...msvc/git@developer.sourcefind.cn:yangql/googletest.git" did not exist on "88269cd365fa5da9d2d6bd04a283ded660c1a0c3"
Commit 64db9578 authored by Guolin Ke's avatar Guolin Ke
Browse files

fix #130

parent db128c8d
...@@ -113,6 +113,17 @@ public: ...@@ -113,6 +113,17 @@ public:
*/ */
inline unsigned int ValueToBin(double value) const; inline unsigned int ValueToBin(double value) const;
/*!
* \brief Get the default bin when value is 0 or is firt categorical
* \return default bin
*/
inline uint32_t GetDefaultBin() const {
if (bin_type_ == BinType::NumericalBin) {
return ValueToBin(0);
} else {
return 0;
}
}
/*! /*!
* \brief Construct feature value to bin mapper according feature values * \brief Construct feature value to bin mapper according feature values
* \param values (Sampled) values of this feature * \param values (Sampled) values of this feature
......
...@@ -27,7 +27,7 @@ public: ...@@ -27,7 +27,7 @@ public:
:bin_mapper_(bin_mapper) { :bin_mapper_(bin_mapper) {
feature_index_ = feature_idx; feature_index_ = feature_idx;
bin_data_.reset(Bin::CreateBin(num_data, bin_mapper_->num_bin(), bin_data_.reset(Bin::CreateBin(num_data, bin_mapper_->num_bin(),
bin_mapper_->sparse_rate(), is_enable_sparse, &is_sparse_, bin_mapper_->ValueToBin(0), bin_mapper_->bin_type())); bin_mapper_->sparse_rate(), is_enable_sparse, &is_sparse_, bin_mapper_->GetDefaultBin(), bin_mapper_->bin_type()));
} }
/*! /*!
* \brief Constructor from memory * \brief Constructor from memory
...@@ -52,9 +52,9 @@ public: ...@@ -52,9 +52,9 @@ public:
num_data = static_cast<data_size_t>(local_used_indices.size()); num_data = static_cast<data_size_t>(local_used_indices.size());
} }
if (is_sparse_) { if (is_sparse_) {
bin_data_.reset(Bin::CreateSparseBin(num_data, bin_mapper_->num_bin(), bin_mapper_->ValueToBin(0), bin_mapper_->bin_type())); bin_data_.reset(Bin::CreateSparseBin(num_data, bin_mapper_->num_bin(), bin_mapper_->GetDefaultBin(), bin_mapper_->bin_type()));
} else { } else {
bin_data_.reset(Bin::CreateDenseBin(num_data, bin_mapper_->num_bin(), bin_mapper_->ValueToBin(0), bin_mapper_->bin_type())); bin_data_.reset(Bin::CreateDenseBin(num_data, bin_mapper_->num_bin(), bin_mapper_->GetDefaultBin(), bin_mapper_->bin_type()));
} }
// get bin data // get bin data
bin_data_->LoadFromMemory(memory_ptr, local_used_indices); bin_data_->LoadFromMemory(memory_ptr, local_used_indices);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment