{ "cells": [ { "cell_type": "markdown", "id": "cfebebd9", "metadata": {}, "source": [ "![brainome logo](./images/brainome_logo.png)\n", "# 103 Model Type Selection\n", "Brainomeā„¢ creates predictors using these three model types:\n", "1. Random Forest\n", "2. Neural Network\n", "3. Decision Tree" ] }, { "cell_type": "markdown", "id": "1474a59d", "metadata": {}, "source": [ "## Prerequisites\n", "This notebook requires brainome as installed per notebook [brainome_101_Quick_Start](brainome_101_Quick_Start.ipynb)\n", "\n", "The training data set used is [titanic_train.csv](https://download.brainome.ai/data/public/titanic_train.csv)." ] }, { "cell_type": "code", "execution_count": null, "id": "5fb40c20", "metadata": {}, "outputs": [], "source": [ "!python3 -m pip install brainome --quiet\n", "!brainome --version" ] }, { "cell_type": "code", "execution_count": null, "id": "f75440f2", "metadata": {}, "outputs": [], "source": [ "import urllib.request as request\n", "print('Downloading titanic_train.csv')\n", "request.urlretrieve('https://download.brainome.ai/data/public/titanic_train.csv', 'titanic_train.csv')\n", "%ls -lh titanic_train.csv" ] }, { "cell_type": "markdown", "id": "33177319", "metadata": {}, "source": [ "## 1. Automatic Model Selection\n", "Brainome can automatically select the most appropriate model type for your data's measurements.\n", "In titanic's case, brainome selects Random Forest." ] }, { "cell_type": "code", "execution_count": null, "id": "f4dc7f42", "metadata": { "tags": [ "output_scroll" ] }, "outputs": [], "source": [ "!brainome titanic_train.csv -y -o predictor_103_automatic.py" ] }, { "cell_type": "markdown", "id": "1c74ca07", "metadata": {}, "source": [ "The predictor filename is `predictor_103_automatic.py`. The source code is approximately 39K bytes." ] }, { "cell_type": "code", "execution_count": null, "id": "7b66cd4c", "metadata": { "scrolled": true }, "outputs": [], "source": [ "%ls -lh predictor_103_automatic.py\n", "%pycat predictor_103_automatic.py" ] }, { "cell_type": "markdown", "id": "8f889a13", "metadata": {}, "source": [ "## 2. Random Forest\n", "You can select the *Random Forest* model type by using the `-f RF` parameter.\n", "\n", "> Note: The `-modelonly` parameter bypasses the measurements phase which do not change from the previous runs." ] }, { "cell_type": "code", "execution_count": null, "id": "de2aa21d", "metadata": { "tags": [ "output_scroll" ] }, "outputs": [], "source": [ "!brainome titanic_train.csv -f RF -y -o predictor_103_RF.py -modelonly" ] }, { "cell_type": "markdown", "id": "84a2691f", "metadata": {}, "source": [ "Open `predictor_103_RF.py` to view the Random Forest Predictor" ] }, { "cell_type": "code", "execution_count": null, "id": "e55e9f69", "metadata": {}, "outputs": [], "source": [ "%ls -lh predictor_103_RF.py\n", "%pycat predictor_103_RF.py" ] }, { "cell_type": "markdown", "id": "72975533", "metadata": {}, "source": [ "## 3. Neural Network\n", "You can select the *Neural Network* model type by using the `-f NN` parameter." ] }, { "cell_type": "code", "execution_count": null, "id": "53f7c9b4", "metadata": { "tags": [ "output_scroll" ] }, "outputs": [], "source": [ "!brainome titanic_train.csv -f NN -y -o predictor_103_NN.py -modelonly" ] }, { "cell_type": "markdown", "id": "116ce265", "metadata": {}, "source": [ "Open `predictor_103_NN.py` to view the Neural Network Predictor. The source code is approximately 57K bytes. " ] }, { "cell_type": "code", "execution_count": null, "id": "7495f8e7", "metadata": {}, "outputs": [], "source": [ "%ls -lh predictor_103_NN.py\n", "%pycat predictor_103_NN.py" ] }, { "cell_type": "markdown", "id": "715fee81", "metadata": {}, "source": [ "## 4. Decision Tree\n", "You can select the *Decision Tree* model type by using the `-f DT` parameter" ] }, { "cell_type": "code", "execution_count": null, "id": "3a727df3", "metadata": { "tags": [ "output_scroll" ] }, "outputs": [], "source": [ "!brainome titanic_train.csv -f DT -y -o predictor_103_DT.py -modelonly" ] }, { "cell_type": "markdown", "id": "81455f1d", "metadata": {}, "source": [ "Open `predictor_103_DT.py` to view the Decision Tree Predictor. The source code is approximately 33K bytes" ] }, { "cell_type": "code", "execution_count": null, "id": "10318f6e", "metadata": {}, "outputs": [], "source": [ "%ls -lh predictor_103_DT.py\n", "%pycat predictor_103_DT.py" ] }, { "cell_type": "markdown", "id": "9e36fb88", "metadata": {}, "source": [ "## Next Steps\n", "- Check out [104_Using_Predictor](./brainome_104_Using_Predictor.ipynb)\n", "- Check out [Using Measurement to Create Better Models](./brainome_200_Using_Measurement.ipynb)" ] } ], "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 }