diff --git a/GAMA_AutoML_Tutorial.ipynb b/GAMA_AutoML_Tutorial.ipynb new file mode 100644 index 0000000000000000000000000000000000000000..f166b3e4dd2a9fe02bece933218d98b03fd6e597 --- /dev/null +++ b/GAMA_AutoML_Tutorial.ipynb @@ -0,0 +1,286 @@ +{ + "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": "25258b82", + "metadata": {}, + "source": [ + "## Software Setup and Install" + ] + }, + { + "cell_type": "markdown", + "id": "debdea63", + "metadata": {}, + "source": [ + "Run the following command to install the GAMA library with Pip:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "bded45a9", + "metadata": {}, + "outputs": [], + "source": [ + "# pip install gama" + ] + }, + { + "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", + "if __name__ == \"__main__\":\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": "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", + "if __name__ == \"__main__\":\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": [ + "GAMA generates optimized pipelines given specific input data and resource constraints. A machine learning pipeline contains data preprocessing (e.g. PCA, normalization) as well as a machine learning algorithm (e.g. Logistic Regression, Random Forests), with fine-tuned hyperparameter settings (e.g. number of trees in a Random Forest).\n", + "\n", + "GAMA can also combine multiple tuned machine learning pipelines together into an ensemble, which should help model performance. GAMA is currently restricted to classification and regression." + ] + }, + { + "cell_type": "markdown", + "id": "ffdabb07", + "metadata": {}, + "source": [ + "## References" + ] + }, + { + "cell_type": "markdown", + "id": "500eb430", + "metadata": {}, + "source": [ + "* 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": "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.0" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +}