| 66 | } |
| 67 | |
| 68 | TEST(GrowStatsDenseClassificationTest, Basic) { |
| 69 | TensorForestParams params; |
| 70 | params.set_num_outputs(2); |
| 71 | params.mutable_split_after_samples()->set_constant_value(2); |
| 72 | params.mutable_num_splits_to_consider()->set_constant_value(2); |
| 73 | std::unique_ptr<DenseClassificationGrowStats> stat( |
| 74 | new DenseClassificationGrowStats(params, 1)); |
| 75 | stat->Initialize(); |
| 76 | |
| 77 | std::vector<float> labels = {1, 0, 1}; |
| 78 | std::vector<float> weights = {2.3, 20.3, 1.1}; |
| 79 | std::unique_ptr<TestableInputTarget> target( |
| 80 | new TestableInputTarget(labels, weights, 1)); |
| 81 | |
| 82 | RunBatch(stat.get(), target.get()); |
| 83 | CHECK(stat->IsFinished()); |
| 84 | |
| 85 | FertileSlot slot; |
| 86 | stat->PackToProto(&slot); |
| 87 | |
| 88 | string serialized = slot.DebugString(); |
| 89 | |
| 90 | std::unique_ptr<DenseClassificationGrowStats> new_stat( |
| 91 | new DenseClassificationGrowStats(params, 1)); |
| 92 | new_stat->ExtractFromProto(slot); |
| 93 | FertileSlot second_one; |
| 94 | new_stat->PackToProto(&second_one); |
| 95 | string serialized_again = second_one.DebugString(); |
| 96 | ASSERT_EQ(serialized_again, serialized); |
| 97 | } |
| 98 | |
| 99 | class TestableRunningStats : public DenseClassificationGrowStats { |
| 100 | public: |
nothing calls this directly
no test coverage detected