{ "cells": [ { "cell_type": "markdown", "id": "895a5bb2", "metadata": {}, "source": [ "![brainome logo](./images/brainome_logo.png)\n", "# 303 Predictor Validation Measurements in JSON\n", "The predictor can output validation measurements in json rather than human-readable text.\n", "\n", "* Validation measurements in json format." ] }, { "cell_type": "markdown", "id": "431b880e", "metadata": {}, "source": [ "## Prerequisites\n", "This notebook assumes brainome is installed as per notebook [brainome_101_Quick_Start](brainome_101_Quick_Start.ipynb)\n", "\n", "The data sets are:\n", "* [titanic_train.csv](https://download.brainome.ai/data/public/titanic_train.csv) for training data\n", "* [titanic_validate.csv](https://download.brainome.ai/data/public/titanic_validate.csv) for validation\n" ] }, { "cell_type": "code", "execution_count": null, "outputs": [], "source": [ "!python3 -m pip install brainome --quiet\n", "!brainome --version\n", "\n", "import urllib.request as request\n", "response2 = request.urlretrieve('https://download.brainome.ai/data/public/titanic_validate.csv', 'titanic_validate.csv')\n", "%ls -lh titanic_validate.csv" ], "metadata": { "collapsed": false, "pycharm": { "name": "#%%\n" } } }, { "cell_type": "markdown", "id": "540b27d9", "metadata": {}, "source": [ "## Generate a predictor\n", "The predictor filename is `predictor_303.py`" ] }, { "cell_type": "code", "execution_count": null, "id": "57882e55", "metadata": { "tags": [ "output_scroll" ] }, "outputs": [], "source": [ "!brainome https://download.brainome.ai/data/public/titanic_train.csv -y -o predictor_303.py -modelonly -q\n", "print('\\nCreated predictor_303.py')\n", "!ls -lh predictor_303.py" ] }, { "cell_type": "markdown", "id": "c65d5739", "metadata": {}, "source": [ "## Validation measurements in json format.\n", "The same measurements as all previous exercises can be generated in JSON format for further system integration\n", "Use `-validate -json` to trigger the predictor to output json validation measurements." ] }, { "cell_type": "code", "execution_count": null, "id": "781a9407", "metadata": {}, "outputs": [], "source": [ "!python3 predictor_303.py -validate titanic_validate.csv -json > validation_measurements_303.json\n", "import json\n", "with open('validation_measurements_303.json', 'r') as measurement_file:\n", " validation_measurements = json.load(measurement_file)\n", " print(json.dumps(validation_measurements, indent=4))\n" ] }, { "cell_type": "markdown", "id": "83c337d6", "metadata": {}, "source": [ "## Next Steps\n", "- Check out [300 Put your model to work](./brainome_300_Integrating_Predictors.ipynb)\n", "> TODO next..." ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.9.6" } }, "nbformat": 4, "nbformat_minor": 5 }