#include #include using namespace xgboost; template inline void test(void) { Sketch sketch; size_t n; double wsum = 0.0; float eps, x, w; utils::Check(scanf("%lu%f", &n, &eps) == 2, "needs to start with n eps"); sketch.Init(n, eps); printf("nlevel = %lu, limit_size=%lu\n", sketch.nlevel, sketch.limit_size); while (scanf("%f%f", &x, &w) == 2) { sketch.Push(x, static_cast(w)); wsum += w; } sketch.CheckValid(static_cast(0.1)); typename Sketch::SummaryContainer out; sketch.GetSummary(&out); double maxerr = static_cast(out.MaxError()); printf("MaxError=%g/%g = %g\n", maxerr, wsum, maxerr / wsum); out.Print(); } int main(int argc, char *argv[]) { const char *method = "wq"; if (argc > 1) method = argv[1]; if (!strcmp(method, "wq")) { test, float>(); } if (!strcmp(method, "gk")) { test, unsigned>(); } return 0; }