Remove unnecessary DMatrix methods (#5324)
This commit is contained in:
@@ -16,21 +16,6 @@ MetaInfo& SimpleDMatrix::Info() { return info; }
|
||||
|
||||
const MetaInfo& SimpleDMatrix::Info() const { return info; }
|
||||
|
||||
float SimpleDMatrix::GetColDensity(size_t cidx) {
|
||||
size_t column_size = 0;
|
||||
// Use whatever version of column batches already exists
|
||||
if (sorted_column_page_) {
|
||||
auto batch = this->GetBatches<SortedCSCPage>();
|
||||
column_size = (*batch.begin())[cidx].size();
|
||||
} else {
|
||||
auto batch = this->GetBatches<CSCPage>();
|
||||
column_size = (*batch.begin())[cidx].size();
|
||||
}
|
||||
|
||||
size_t nmiss = this->Info().num_row_ - column_size;
|
||||
return 1.0f - (static_cast<float>(nmiss)) / this->Info().num_row_;
|
||||
}
|
||||
|
||||
BatchSet<SparsePage> SimpleDMatrix::GetRowBatches() {
|
||||
// since csr is the default data structure so `source_` is always available.
|
||||
auto begin_iter = BatchIterator<SparsePage>(
|
||||
@@ -76,8 +61,6 @@ BatchSet<EllpackPage> SimpleDMatrix::GetEllpackBatches(const BatchParam& param)
|
||||
return BatchSet<EllpackPage>(begin_iter);
|
||||
}
|
||||
|
||||
bool SimpleDMatrix::SingleColBlock() const { return true; }
|
||||
|
||||
template <typename AdapterT>
|
||||
SimpleDMatrix::SimpleDMatrix(AdapterT* adapter, float missing, int nthread) {
|
||||
// Set number of threads but keep old value so we can reset it after
|
||||
|
||||
@@ -30,9 +30,7 @@ class SimpleDMatrix : public DMatrix {
|
||||
|
||||
const MetaInfo& Info() const override;
|
||||
|
||||
float GetColDensity(size_t cidx) override;
|
||||
|
||||
bool SingleColBlock() const override;
|
||||
bool SingleColBlock() const override { return true; }
|
||||
|
||||
/*! \brief magic number used to identify SimpleDMatrix binary files */
|
||||
static const int kMagic = 0xffffab01;
|
||||
|
||||
@@ -58,28 +58,6 @@ BatchSet<EllpackPage> SparsePageDMatrix::GetEllpackBatches(const BatchParam& par
|
||||
return BatchSet<EllpackPage>(begin_iter);
|
||||
}
|
||||
|
||||
float SparsePageDMatrix::GetColDensity(size_t cidx) {
|
||||
// Finds densities if we don't already have them
|
||||
if (col_density_.empty()) {
|
||||
std::vector<size_t> column_size(this->Info().num_col_);
|
||||
for (const auto &batch : this->GetBatches<CSCPage>()) {
|
||||
for (auto i = 0u; i < batch.Size(); i++) {
|
||||
column_size[i] += batch[i].size();
|
||||
}
|
||||
}
|
||||
col_density_.resize(column_size.size());
|
||||
for (auto i = 0u; i < col_density_.size(); i++) {
|
||||
size_t nmiss = this->Info().num_row_ - column_size[i];
|
||||
col_density_[i] =
|
||||
1.0f - (static_cast<float>(nmiss)) / this->Info().num_row_;
|
||||
}
|
||||
}
|
||||
return col_density_.at(cidx);
|
||||
}
|
||||
|
||||
bool SparsePageDMatrix::SingleColBlock() const {
|
||||
return false;
|
||||
}
|
||||
} // namespace data
|
||||
} // namespace xgboost
|
||||
#endif // DMLC_ENABLE_STD_THREAD
|
||||
|
||||
@@ -37,9 +37,7 @@ class SparsePageDMatrix : public DMatrix {
|
||||
|
||||
const MetaInfo& Info() const override;
|
||||
|
||||
float GetColDensity(size_t cidx) override;
|
||||
|
||||
bool SingleColBlock() const override;
|
||||
bool SingleColBlock() const override { return false; }
|
||||
|
||||
private:
|
||||
BatchSet<SparsePage> GetRowBatches() override;
|
||||
|
||||
Reference in New Issue
Block a user