<commit_before>{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "TWrdW148R9kP"
   },
   "source": [
    "# Cloud AI Platform + What-if Tool: end-to-end XGBoost example\n",
    "\n",
    "This notebook shows how to: \n",
    "* Build a binary classification model with XGBoost trained on a [mortgage dataset](https://www.ffiec.gov/hmda/hmdaflat.htm)\n",
    "* Deploy the model to [Cloud AI Platform](https://cloud.google.com/ai-platform/)\n",
    "* Use the [What-if Tool](https://pair-code.github.io/what-if-tool/) on your deployed model\n",
    "\n",
    "You will need a Google Cloud Platform account and project to run this notebook. Instructions for creating a project can be found [here](https://cloud.google.com/resource-manager/docs/creating-managing-projects)."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "python_version = !python --version\n",
    "python_version = python_version[0].split(' ')[1][0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "colab": {},
    "colab_type": "code",
    "id": "hSFHu19Rtvbt"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "/bin/sh: pip: command not found\r\n"
     ]
    }
   ],
   "source": [
    "# If you're running on Colab, you'll need to install the What-if Tool package and authenticate\n",
    "# If you're on Cloud AI Platform Notebooks, you'll need to install XGBoost on the TF instance\n",
    "def pip_install(module):\n",
    "    if python_version == '2':\n",
    "        !pip install {module} --quiet\n",
    "    else:\n",
    "        !pip3 install {module} --quiet\n",
    "\n",
    "try:\n",
    "    import google.colab\n",
    "    IN_COLAB = True\n",
    "except:\n",
    "    IN_COLAB = False\n",
    "\n",
    "if IN_COLAB:\n",
    "    pip_install('witwidget')\n",
    "\n",
    "    from google.colab import auth\n",
    "    auth.authenticate_user()\n",
    "else:\n",
    "    pip_install('xgboost')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 0,
   "metadata": {
    "colab": {},<commit_msg>Remove cell output<commit_after>{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "TWrdW148R9kP"
   },
   "source": [
    "# Cloud AI Platform + What-if Tool: end-to-end XGBoost example\n",
    "\n",
    "This notebook shows how to: \n",
    "* Build a binary classification model with XGBoost trained on a [mortgage dataset](https://www.ffiec.gov/hmda/hmdaflat.htm)\n",
    "* Deploy the model to [Cloud AI Platform](https://cloud.google.com/ai-platform/)\n",
    "* Use the [What-if Tool](https://pair-code.github.io/what-if-tool/) on your deployed model\n",
    "\n",
    "You will need a Google Cloud Platform account and project to run this notebook. Instructions for creating a project can be found [here](https://cloud.google.com/resource-manager/docs/creating-managing-projects)."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "python_version = !python --version\n",
    "python_version = python_version[0].split(' ')[1][0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "colab": {},
    "colab_type": "code",
    "id": "hSFHu19Rtvbt"
   },
   "outputs": [],
   "source": [
    "# If you're running on Colab, you'll need to install the What-if Tool package and authenticate\n",
    "# If you're on Cloud AI Platform Notebooks, you'll need to install XGBoost on the TF instance\n",
    "def pip_install(module):\n",
    "    if python_version == '2':\n",
    "        !pip install {module} --quiet\n",
    "    else:\n",
    "        !pip3 install {module} --quiet\n",
    "\n",
    "try:\n",
    "    import google.colab\n",
    "    IN_COLAB = True\n",
    "except:\n",
    "    IN_COLAB = False\n",
    "\n",
    "if IN_COLAB:\n",
    "    pip_install('witwidget')\n",
    "\n",
    "    from google.colab import auth\n",
    "    auth.authenticate_user()\n",
    "else:\n",
    "    pip_install('xgboost')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 0,
   "metadata": {
    "colab": {},
{'fraction_non_alphanumeric': 0.18570427470217238, 'fraction_numerical': 0.006306937631394534, 'mean_word_length': 2.607413647851727, 'pattern_counts': {'":': 49, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 8, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5864307', 'n_tokens_mistral': 1587, 'n_tokens_neox': 1541, 'n_words': 358}