Refactor tests with data generator. (#5439)
This commit is contained in:
@@ -25,15 +25,13 @@ void TestPredictionFromGradientIndex(std::string name, size_t rows, int32_t bins
|
||||
gbm::GBTreeModel model = CreateTestModel(¶m, kClasses);
|
||||
|
||||
{
|
||||
auto pp_ellpack = CreateDMatrix(rows, kCols, 0);
|
||||
auto p_ellpack = *pp_ellpack;
|
||||
auto p_ellpack = RandomDataGenerator(rows, kCols, 0).GenerateDMatix();
|
||||
// Use same number of bins as rows.
|
||||
for (auto const &page DMLC_ATTRIBUTE_UNUSED :
|
||||
p_ellpack->GetBatches<Page>({0, static_cast<int32_t>(bins), 0})) {
|
||||
}
|
||||
|
||||
auto pp_precise = CreateDMatrix(rows, kCols, 0);
|
||||
auto p_precise = *pp_precise;
|
||||
auto p_precise = RandomDataGenerator(rows, kCols, 0).GenerateDMatix();
|
||||
|
||||
PredictionCacheEntry approx_out_predictions;
|
||||
predictor->PredictBatch(p_ellpack.get(), &approx_out_predictions, model, 0);
|
||||
@@ -45,21 +43,16 @@ void TestPredictionFromGradientIndex(std::string name, size_t rows, int32_t bins
|
||||
CHECK_EQ(approx_out_predictions.predictions.HostVector()[i],
|
||||
precise_out_predictions.predictions.HostVector()[i]);
|
||||
}
|
||||
|
||||
delete pp_precise;
|
||||
delete pp_ellpack;
|
||||
}
|
||||
|
||||
{
|
||||
// Predictor should never try to create the histogram index by itself. As only
|
||||
// histogram index from training data is valid and predictor doesn't known which
|
||||
// matrix is used for training.
|
||||
auto pp_dmat = CreateDMatrix(rows, kCols, 0);
|
||||
auto p_dmat = *pp_dmat;
|
||||
auto p_dmat = RandomDataGenerator(rows, kCols, 0).GenerateDMatix();
|
||||
PredictionCacheEntry precise_out_predictions;
|
||||
predictor->PredictBatch(p_dmat.get(), &precise_out_predictions, model, 0);
|
||||
ASSERT_FALSE(p_dmat->PageExists<Page>());
|
||||
delete pp_dmat;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user