{ "cells": [ { "cell_type": "markdown", "id": "01d9c180", "metadata": {}, "source": [ "# GAMA AutoML Tutorial" ] }, { "cell_type": "markdown", "id": "bf57cd23", "metadata": {}, "source": [ "**Team Boeing - Abirami Varatharajan, Brandon Hang, Deepak Ghimirey, Emily Lang, Jack Haas**" ] }, { "cell_type": "markdown", "id": "14c7d7c0", "metadata": {}, "source": [ "<img src=\"https://github.com/openml-labs/gama/raw/master/images/logos/Logo-With-Grey-Name-Transparent.png\" alt=\"W3Schools.com\" width=\"800\">\n", "\n", "Image source: https://github.com/openml-labs/gama/raw/master/images/logos/Logo-With-Grey-Name-Transparent.png" ] }, { "cell_type": "markdown", "id": "481fae1c", "metadata": {}, "source": [ "## View Documentation At:\n", "* https://openml-labs.github.io/gama/master/\n", "* https://github.com/openml-labs/gama\n", "* https://openml-labs.github.io/gama/master/index.html\n", "* https://openml-labs.github.io/gama/master/user_guide/index.html#dashboard\n", "* https://openml-labs.github.io/gama/master/api/index.html" ] }, { "cell_type": "markdown", "id": "25258b82", "metadata": {}, "source": [ "## Software Setup and Install" ] }, { "cell_type": "markdown", "id": "debdea63", "metadata": {}, "source": [ "Run the following command from inside an activated Conda Env to install the GAMA library with Pip:" ] }, { "cell_type": "code", "execution_count": null, "id": "bded45a9", "metadata": {}, "outputs": [], "source": [ "# pip install gama\n", "# *or*\n", "# pip3 install gama " ] }, { "cell_type": "markdown", "id": "32af5ac3", "metadata": {}, "source": [ "TODO: I think GAMA requires python=3.9? I cant get it to work. -- Dirk" ] }, { "cell_type": "markdown", "id": "192cbbad", "metadata": {}, "source": [ "Alternatively, the source code can be downloaded from the following Github repository:\n", "\n", "https://github.com/openml-labs/gama" ] }, { "cell_type": "markdown", "id": "ce52d2cf", "metadata": {}, "source": [ "## Accessing the Software" ] }, { "cell_type": "markdown", "id": "ebfccd27", "metadata": {}, "source": [ "To access the GAMA library after it is installed, run the following Python import command:" ] }, { "cell_type": "code", "execution_count": null, "id": "00a14ad0", "metadata": {}, "outputs": [], "source": [ "import gama" ] }, { "cell_type": "markdown", "id": "ad7f01c2", "metadata": {}, "source": [ "## Overview" ] }, { "cell_type": "markdown", "id": "bedce649", "metadata": {}, "source": [ "GAMA is an AutoML package that generates optimized machine learning pipelines, given specific input data and resource constraints. To simplify intensive labor work of selecting the correct algorithm, all the user needs to do is supply the data, and GAMA will automatically try to find a good machine learning pipeline by considering data preprocessing steps, machine learning algorithm, and hyperparameter configurations. GAMA can also combine multiple tuned machine learning pipelines together into an ensemble, which can help model performance. GAMA is currently restricted to classification and regression problems on tabular data. <br><br>\n", "\n", "For more information about GAMA, see the link below:\n", "\n", "https://openml-labs.github.io/gama/master/index.html" ] }, { "cell_type": "markdown", "id": "c65233ea", "metadata": {}, "source": [ "## Visualization" ] }, { "cell_type": "markdown", "id": "8a157003", "metadata": {}, "source": [ "In addition to its general use AutoML functionality, GAMA aims to serve AutoML researchers as well. During the optimization process, GAMA keeps an extensive log of progress made. Using this log, insight can be obtained on the behaviour of the search procedure. For example, it can produce a graph that shows pipeline fitness over time: graph of fitness over time" ] }, { "cell_type": "markdown", "id": "5b3d0114", "metadata": {}, "source": [ "## Code Examples" ] }, { "cell_type": "markdown", "id": "6c9141bd", "metadata": {}, "source": [ "For detailed API documentation see the following link:\n", "\n", "https://openml-labs.github.io/gama/master/api/index.html" ] }, { "cell_type": "markdown", "id": "3427585f", "metadata": {}, "source": [ "### Classification\n", "\n", "Example sourced from: https://openml-labs.github.io/gama/master/user_guide/index.html#dashboard" ] }, { "cell_type": "code", "execution_count": null, "id": "a43e62f3", "metadata": {}, "outputs": [], "source": [ "from sklearn.datasets import load_breast_cancer\n", "from sklearn.model_selection import train_test_split\n", "from sklearn.metrics import log_loss, accuracy_score\n", "from gama import GamaClassifier\n", "\n", "X, y = load_breast_cancer(return_X_y=True)\n", "X_train, X_test, y_train, y_test = train_test_split(\n", " X, y, stratify=y, random_state=0\n", ")\n", "\n", "automl = GamaClassifier(max_total_time=180, store=\"nothing\", n_jobs=-1)\n", "print(\"Starting `fit` which will take roughly 3 minutes...\")\n", "automl.fit(X_train, y_train)\n", "\n", "label_predictions = automl.predict(X_test)\n", "probability_predictions = automl.predict_proba(X_test)\n", "\n", "print(\"accuracy:\", accuracy_score(y_test, label_predictions))\n", "print(\"log loss:\", log_loss(y_test, probability_predictions))" ] }, { "cell_type": "markdown", "id": "1bfbb41b", "metadata": {}, "source": [ "Some issues with the classifier receiving \"ValueError: population must be at least of size 3 for a pair to be selected\"" ] }, { "cell_type": "markdown", "id": "de9afff2", "metadata": {}, "source": [ "### Regression\n", "\n", "Example sourced from: https://openml-labs.github.io/gama/master/user_guide/index.html#dashboard" ] }, { "cell_type": "code", "execution_count": null, "id": "35f68b4c", "metadata": {}, "outputs": [], "source": [ "from sklearn.datasets import load_boston\n", "from sklearn.model_selection import train_test_split\n", "from sklearn.metrics import mean_squared_error\n", "from gama import GamaRegressor\n", "\n", "X, y = load_boston(return_X_y=True)\n", "X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=0)\n", "\n", "automl = GamaRegressor(max_total_time=180, store=\"nothing\", n_jobs=-1)\n", "print(\"Starting `fit` which will take roughly 3 minutes...\")\n", "automl.fit(X_train, y_train)\n", "\n", "predictions = automl.predict(X_test)\n", "\n", "print(\"MSE:\", mean_squared_error(y_test, predictions))" ] }, { "cell_type": "markdown", "id": "a8051ac9", "metadata": {}, "source": [ "## Applications" ] }, { "cell_type": "markdown", "id": "cc6caab0", "metadata": {}, "source": [ "This tool could be helpful when we are in the preprocessing stage and when we are comparing various models, this would be a great tool to understand which kinds of models would be best for the given data set and a create a foundation for your model. GAMA can also combine multiple tuned machine learning pipelines together into an ensemble, which should help model performance. Due to the current version of GAMA this tool currently restricted to classification and regression datasets.\n", "\n" ] }, { "cell_type": "markdown", "id": "e0a28b97", "metadata": {}, "source": [ "---" ] } ], "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.15" } }, "nbformat": 4, "nbformat_minor": 5 }