From 203d29aced3aca4c6497637c011543100881ef82 Mon Sep 17 00:00:00 2001 From: Caceresenzo Date: Thu, 11 May 2023 18:25:56 +0200 Subject: [PATCH] feat(tester)!: swap `infer` parameters Closes #8 --- crunch/__version__.py | 2 +- crunch/tester.py | 4 ++-- examples/test.ipynb | 31 +++---------------------------- 3 files changed, 6 insertions(+), 31 deletions(-) diff --git a/crunch/__version__.py b/crunch/__version__.py index 84389bf..c5d4557 100644 --- a/crunch/__version__.py +++ b/crunch/__version__.py @@ -1,6 +1,6 @@ __title__ = 'crunch-cli' __description__ = 'crunch-cli - CLI of the CrunchDAO Platform' -__version__ = '1.1.3' +__version__ = '1.2.0' __author__ = 'Enzo CACERES' __author_email__ = 'enzo.caceres@crunchdao.com' __url__ = 'https://github.com/crunchdao/crunch-cli' diff --git a/crunch/tester.py b/crunch/tester.py index b576b08..ef1635c 100644 --- a/crunch/tester.py +++ b/crunch/tester.py @@ -83,9 +83,9 @@ def run( y_train_loop = y_train[y_train.index < moon - embargo].reset_index() train_handler(x_train_loop, y_train_loop, model_directory_path) - logging.warn('handler: infer(%s, %s)', model_directory_path, x_test_path) + logging.warn('handler: infer(%s, %s)', x_test_path, model_directory_path) x_test_loop = x_test[x_test.index == moon].reset_index() - prediction = infer_handler(model_directory_path, x_test_loop) + prediction = infer_handler(x_test_loop, model_directory_path) prediction = ensure.return_infer(prediction) predictions.append(prediction) diff --git a/examples/test.ipynb b/examples/test.ipynb index e6b1c26..34d0060 100644 --- a/examples/test.ipynb +++ b/examples/test.ipynb @@ -40,30 +40,6 @@ "crunch = crunch_cli.load_notebook(__name__)" ] }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "def data_process(\n", - " x_train: pandas.DataFrame,\n", - " y_train: pandas.DataFrame,\n", - " x_test: pandas.DataFrame\n", - ") -> typing.Tuple[pandas.DataFrame, pandas.DataFrame, pandas.DataFrame]:\n", - " \"\"\"\n", - " Do your data processing here.\n", - " This function will always be executed.\n", - " \"\"\"\n", - " \n", - " print(\"data_process\")\n", - " print(\"x_train\", len(x_train))\n", - " print(\"y_train\", len(y_train))\n", - " print(\"x_test\", len(x_test))\n", - "\n", - " return x_train, y_train, x_test" - ] - }, { "cell_type": "code", "execution_count": null, @@ -71,7 +47,6 @@ "outputs": [], "source": [ "x_train, y_train, x_test = crunch.load_data()\n", - "x_train, y_train, x_test = data_process(x_train, y_train, x_test)\n", "len(x_train), len(y_train), len(x_test)" ] }, @@ -117,8 +92,8 @@ "outputs": [], "source": [ "def infer(\n", - " model_directory: pandas.DataFrame,\n", - " x_test: pandas.DataFrame\n", + " x_test: pandas.DataFrame,\n", + " model_directory: str,\n", ") -> pandas.DataFrame:\n", " \"\"\"\n", " Do your inference here.\n", @@ -139,7 +114,7 @@ "metadata": {}, "outputs": [], "source": [ - "prediction = infer(crunch.model_directory, x_test)\n", + "prediction = infer(x_test, crunch.model_directory)\n", "len(prediction)" ] },