MCPcopy Create free account
hub / github.com/dmlc/xgboost / test_evaluation_monitor

Method test_evaluation_monitor

tests/python/test_callback.py:85–104  ·  view source on GitHub ↗
(self, breast_cancer: BreastCancer)

Source from the content-addressed store, hash-verified

83 check_output(output)
84
85 def test_evaluation_monitor(self, breast_cancer: BreastCancer) -> None:
86 D_train = xgb.DMatrix(breast_cancer.tr[0], breast_cancer.tr[1])
87 D_valid = xgb.DMatrix(breast_cancer.va[0], breast_cancer.va[1])
88 evals_result = {}
89 rounds = 10
90 xgb.train(
91 {"objective": "binary:logistic", "eval_metric": "error"},
92 D_train,
93 evals=[(D_train, "Train"), (D_valid, "Valid")],
94 num_boost_round=rounds,
95 evals_result=evals_result,
96 verbose_eval=True,
97 )
98 assert len(evals_result["Train"]["error"]) == rounds
99 assert len(evals_result["Valid"]["error"]) == rounds
100
101 self.run_evaluation_monitor(D_train, D_valid, rounds, True)
102 self.run_evaluation_monitor(D_train, D_valid, rounds, 2)
103 self.run_evaluation_monitor(D_train, D_valid, rounds, 4)
104 self.run_evaluation_monitor(D_train, D_valid, rounds, rounds + 1)
105
106 def test_early_stopping(self, breast_cancer: BreastCancer) -> None:
107 D_train = xgb.DMatrix(breast_cancer.tr[0], breast_cancer.tr[1])

Callers

nothing calls this directly

Calls 3

DMatrixMethod · 0.45
trainMethod · 0.45

Tested by

no test coverage detected