<commit_before>{
  "nbformat": 4,
  "nbformat_minor": 0,
  "metadata": {
    "colab": {
      "name": "ImageClassifier.ipynb",
      "provenance": [],
      "collapsed_sections": []
    },
    "kernelspec": {
      "display_name": "Python 3",
      "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.7.3"
    }
  },
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "LowS0sjVAsIh",
        "colab_type": "text"
      },
      "source": [
        "[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/keras-team/autokeras/blob/master/docs/templates/tutorial/image_classification.ipynb)"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "colab_type": "code",
        "id": "gWFzURyih3Bz",
        "colab": {}
      },
      "source": [
        "pip install autokeras"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "colab_type": "code",
        "id": "4Atqdhcqh7nT",
        "colab": {}
      },
      "source": [
        "pip install tensorflow"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "7HwXoew2D2vT",
        "colab_type": "text"
      },
      "source": [
        "## A Simple Example"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "colab_type": "text",
        "id": "0D7scqBWkg5t"
      },
      "source": [
        "The first step is to prepare your data. Here we use the MNIST dataset as an example"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "colab_type": "code",
        "id": "YACSvJ81h_Ry",
        "colab": {}
      },
      "source": [
        "from tensorflow.keras.datasets import mnist\n",
        "(x_train, y_train), (x_test, y_test) = mnist.load_data()\n",
        "print(x_train.shape) # (60000, 28, 28)\n",
        "print(y_train.shape) # (60000,)\n",
        "print(y_train[:3]) # array([7, 2, 1], dtype=uint8)"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "colab_type": "text",
        "id": "N5xlStkakqJn"
      },
      "source": [
        "The second step is to run the ImageClassifier."
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "colab_type": "code",
        "id": "QfnaDrkPiTTg",
        "colab": {}
      },
      "source": [
        "import autokeras as ak\n",
        "\n",
        "# Initialize the image classifier.\n",
        "clf = ak.ImageClassifier(max_trials=1) # It tries 10 different models.\n",
        "# Feed the image classifier with training data.\n",
        "clf.fit(x_train, y_train,epochs=3)\n"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "colab_type": "code",
        "id": "jPSNnpP6TDAP",
        "colab": {}
      },
      "source": [
        "# Predict with the best model.\n",
        "predicted_y = clf.predict(x_test)\n",
        "print(predicted_y)\n"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "colab_type": "code",
        "id": "ENEc_5kaTJzn",
        "colab": {}
      },
      "source": [
        "# Evaluate the best model with testing data.\n",<commit_msg>Update parameter in Image Classification tutorial (#1040)<commit_after>{
  "nbformat": 4,
  "nbformat_minor": 0,
  "metadata": {
    "colab": {
      "name": "ImageClassifier.ipynb",
      "provenance": [],
      "collapsed_sections": []
    },
    "kernelspec": {
      "display_name": "Python 3",
      "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.7.3"
    }
  },
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "LowS0sjVAsIh",
        "colab_type": "text"
      },
      "source": [
        "[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/keras-team/autokeras/blob/master/docs/templates/tutorial/image_classification.ipynb)"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "colab_type": "code",
        "id": "gWFzURyih3Bz",
        "colab": {}
      },
      "source": [
        "pip install autokeras"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "colab_type": "code",
        "id": "4Atqdhcqh7nT",
        "colab": {}
      },
      "source": [
        "pip install tensorflow"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "7HwXoew2D2vT",
        "colab_type": "text"
      },
      "source": [
        "## A Simple Example"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "colab_type": "text",
        "id": "0D7scqBWkg5t"
      },
      "source": [
        "The first step is to prepare your data. Here we use the MNIST dataset as an example"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "colab_type": "code",
        "id": "YACSvJ81h_Ry",
        "colab": {}
      },
      "source": [
        "from tensorflow.keras.datasets import mnist\n",
        "(x_train, y_train), (x_test, y_test) = mnist.load_data()\n",
        "print(x_train.shape) # (60000, 28, 28)\n",
        "print(y_train.shape) # (60000,)\n",
        "print(y_train[:3]) # array([7, 2, 1], dtype=uint8)"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "colab_type": "text",
        "id": "N5xlStkakqJn"
      },
      "source": [
        "The second step is to run the ImageClassifier."
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "colab_type": "code",
        "id": "QfnaDrkPiTTg",
        "colab": {}
      },
      "source": [
        "import autokeras as ak\n",
        "\n",
        "# Initialize the image classifier.\n",
        "clf = ak.ImageClassifier(max_trials=10) # It tries 10 different models.\n",
        "# Feed the image classifier with training data.\n",
        "clf.fit(x_train, y_train,epochs=3)\n"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "colab_type": "code",
        "id": "jPSNnpP6TDAP",
        "colab": {}
      },
      "source": [
        "# Predict with the best model.\n",
        "predicted_y = clf.predict(x_test)\n",
        "print(predicted_y)\n"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "colab_type": "code",
        "id": "ENEc_5kaTJzn",
        "colab": {}
      },
      "source": [
        "# Evaluate the best model with testing data.\n",
{'fraction_non_alphanumeric': 0.18524395081316938, 'fraction_numerical': 0.0144122702631231, 'mean_word_length': 1.8382739212007504, 'pattern_counts': {'":': 176, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, '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': '2645475', 'n_tokens_mistral': 2819, 'n_tokens_neox': 2720, 'n_words': 477}