def test_ks(self): y_true = np.array([1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0]) y_predict = np.array( [0.42, 0.73, 0.55, 0.37, 0.57, 0.70, 0.25, 0.23, 0.46, 0.62, 0.76, 0.46, 0.55, 0.56, 0.56, 0.38, 0.37, 0.73, 0.77, 0.21, 0.39]) ground_true_ks = 0.75 eva = Evaluation("binary") ks = eva.ks(y_true, y_predict) ks = round(ks, 2) self.assertFloatEqual(ks, ground_true_ks)
def test_ks(self): y_true = np.array( [1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0]) y_predict = np.array([ 0.42, 0.73, 0.55, 0.37, 0.57, 0.70, 0.25, 0.23, 0.46, 0.62, 0.76, 0.46, 0.55, 0.56, 0.56, 0.38, 0.37, 0.73, 0.77, 0.21, 0.39 ]) ground_true_ks = 0.75 eva = Evaluation() eva._init_model(EvaluateParam(eval_type=consts.BINARY, pos_label=1)) ks, fpr, tpr, score_threshold, cuts = eva.ks(y_true, y_predict) ks = round(ks, 2) self.assertFloatEqual(ks, ground_true_ks)