def test_binary_classification_predict_on_predictor_instance(): np.random.seed(0) df_titanic_train, df_titanic_test = utils.get_titanic_binary_classification_dataset() ml_predictor = utils.train_basic_binary_classifier(df_titanic_train) predictions = ml_predictor.predict(df_titanic_test) test_score = accuracy_score(predictions, df_titanic_test.survived) # Make sure our score is good, but not unreasonably good print(test_score) assert .77 < test_score < .805
def test_binary_classification_predict_proba_on_predictor_instance(): np.random.seed(0) df_titanic_train, df_titanic_test = utils.get_titanic_binary_classification_dataset() ml_predictor = utils.train_basic_binary_classifier(df_titanic_train) # predictions = ml_predictor.predict_proba(df_titanic_test) predictions = [pred[1] for pred in predictions] test_score = utils.calculate_brier_score_loss(df_titanic_test.survived, predictions) # Make sure our score is good, but not unreasonably good print(test_score) assert -0.16 < test_score < -0.135