From 68b295351c44388c9617fad16e7f1fb4295554d9 Mon Sep 17 00:00:00 2001 From: Satrajit Ghosh Date: Mon, 7 Dec 2020 20:41:07 -0500 Subject: [PATCH] added tests --- README.md | 2 ++ pydra_ml/tests/test_classifier.py | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/README.md b/README.md index 98a1a98..63fc5d3 100644 --- a/README.md +++ b/README.md @@ -182,6 +182,8 @@ Each model contains: trained_model = data[0][1].output.model trained_model.predict(np.random.rand(1, 30)) ``` + Please check the value of `data[N][0]` to ensure that you are not using + a permuted model. - One figure per metric with performance distribution across splits (with or without null distribution trained on permuted labels) - One figure per any metric with the word `score` in it reporting the results of diff --git a/pydra_ml/tests/test_classifier.py b/pydra_ml/tests/test_classifier.py index c9a99d5..abeac28 100644 --- a/pydra_ml/tests/test_classifier.py +++ b/pydra_ml/tests/test_classifier.py @@ -1,5 +1,6 @@ import os from ..classifier import gen_workflow, run_workflow +import numpy as np def test_classifier(tmpdir): @@ -32,6 +33,8 @@ def test_classifier(tmpdir): assert results[0][0]["ml_wf.clf_info"][1] == "MLPClassifier" assert results[0][0]["ml_wf.permute"] assert results[0][1].output.score[0][0] < results[1][1].output.score[0][0] + assert hasattr(results[2][1].output.model, "predict") + assert isinstance(results[2][1].output.model.predict(np.ones((1, 30))), np.ndarray) def test_regressor(tmpdir): @@ -69,3 +72,5 @@ def test_regressor(tmpdir): assert results[0][0]["ml_wf.clf_info"][-1][1] == "MLPRegressor" assert results[0][0]["ml_wf.permute"] assert results[0][1].output.score[0][0] < results[1][1].output.score[0][0] + assert hasattr(results[2][1].output.model, "predict") + assert isinstance(results[2][1].output.model.predict(np.ones((1, 10))), np.ndarray)