examples

Форк
0
/
00_movie_recommender.ipynb 
2291 строка · 107.7 Кб
1
{
2
  "cells": [
3
    {
4
      "attachments": {},
5
      "cell_type": "markdown",
6
      "metadata": {},
7
      "source": [
8
        "[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/pinecone-io/examples/blob/master/learn/recommendation/movie-recommender/00_movie_recommender.ipynb) [![Open nbviewer](https://raw.githubusercontent.com/pinecone-io/examples/master/assets/nbviewer-shield.svg)](https://nbviewer.org/github/pinecone-io/examples/blob/master/learn/recommendation/movie-recommender/00_movie_recommender.ipynb)"
9
      ]
10
    },
11
    {
12
      "cell_type": "markdown",
13
      "metadata": {
14
        "id": "2MvIbzqhyOHm"
15
      },
16
      "source": [
17
        "# Movie Recommender System"
18
      ]
19
    },
20
    {
21
      "cell_type": "markdown",
22
      "metadata": {
23
        "id": "yvMS7LuCDyee"
24
      },
25
      "source": [
26
        "This notebook demonstrates how Pinecone's similarity search as a service helps you build a simple Movie Recommender System. There are three parts to this recommender system:\n",
27
        "\n",
28
        "- A dataset containing movie ratings\n",
29
        "- Two deep learning models for embedding movies and users\n",
30
        "- A vector index to perform similarity search on those embeddings\n",
31
        "\n",
32
        "The architecture of our recommender system is shown below. We have two models, a user model and a movie model, which generate embedding for users and movies. The two models are trained such that the proximity between a user and a movie in the multi-dimensional vector space depends on the rating given by the user for that movie. This means if a user gives a high rating to a movie, the movie will be closer to the user in the multi-dimensional vector space and vice versa. This ultimately brings users with similar movie preferences and the movies they rated higher closer in the vector space. A similarity search in this vector space for a user would give new recommendations based on the shared movie preference with other users.\n",
33
        "\n",
34
        "\n",
35
        "<center><div> <img src=\"https://raw.githubusercontent.com/pinecone-io/examples/master/movie_recommender/assets/movie-recommender.png\" alt=\"Drawing\" style=\"width:300px;\"/></div> </center> "
36
      ]
37
    },
38
    {
39
      "cell_type": "markdown",
40
      "metadata": {
41
        "id": "7IEi5W4ApbMR"
42
      },
43
      "source": [
44
        "## Install Dependencies"
45
      ]
46
    },
47
    {
48
      "cell_type": "code",
49
      "execution_count": 1,
50
      "metadata": {
51
        "colab": {
52
          "base_uri": "https://localhost:8080/"
53
        },
54
        "collapsed": true,
55
        "id": "xkanbZJUhY34",
56
        "outputId": "18b536e1-12dd-4a40-8942-88fbc1667844"
57
      },
58
      "outputs": [
59
        {
60
          "name": "stdout",
61
          "output_type": "stream",
62
          "text": [
63
            "Looking in indexes: https://pypi.org/simple, https://us-python.pkg.dev/colab-wheels/public/simple/\n",
64
            "Collecting datasets\n",
65
            "  Downloading datasets-2.4.0-py3-none-any.whl (365 kB)\n",
66
            "\u001b[K     |████████████████████████████████| 365 kB 16.1 MB/s \n",
67
            "\u001b[?25hCollecting transformers\n",
68
            "  Downloading transformers-4.21.2-py3-none-any.whl (4.7 MB)\n",
69
            "\u001b[K     |████████████████████████████████| 4.7 MB 53.9 MB/s \n",
70
            "\u001b[?25hCollecting pinecone-client\n",
71
            "  Downloading pinecone_client-2.0.13-py3-none-any.whl (175 kB)\n",
72
            "\u001b[K     |████████████████████████████████| 175 kB 61.7 MB/s \n",
73
            "\u001b[?25hRequirement already satisfied: tensorflow in /usr/local/lib/python3.7/dist-packages (2.8.2+zzzcolab20220719082949)\n",
74
            "Requirement already satisfied: pyarrow>=6.0.0 in /usr/local/lib/python3.7/dist-packages (from datasets) (6.0.1)\n",
75
            "Requirement already satisfied: pandas in /usr/local/lib/python3.7/dist-packages (from datasets) (1.3.5)\n",
76
            "Requirement already satisfied: requests>=2.19.0 in /usr/local/lib/python3.7/dist-packages (from datasets) (2.23.0)\n",
77
            "Collecting multiprocess\n",
78
            "  Downloading multiprocess-0.70.13-py37-none-any.whl (115 kB)\n",
79
            "\u001b[K     |████████████████████████████████| 115 kB 59.0 MB/s \n",
80
            "\u001b[?25hRequirement already satisfied: numpy>=1.17 in /usr/local/lib/python3.7/dist-packages (from datasets) (1.21.6)\n",
81
            "Collecting huggingface-hub<1.0.0,>=0.1.0\n",
82
            "  Downloading huggingface_hub-0.9.1-py3-none-any.whl (120 kB)\n",
83
            "\u001b[K     |████████████████████████████████| 120 kB 49.5 MB/s \n",
84
            "\u001b[?25hRequirement already satisfied: tqdm>=4.62.1 in /usr/local/lib/python3.7/dist-packages (from datasets) (4.64.0)\n",
85
            "Requirement already satisfied: importlib-metadata in /usr/local/lib/python3.7/dist-packages (from datasets) (4.12.0)\n",
86
            "Collecting xxhash\n",
87
            "  Downloading xxhash-3.0.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (212 kB)\n",
88
            "\u001b[K     |████████████████████████████████| 212 kB 58.9 MB/s \n",
89
            "\u001b[?25hRequirement already satisfied: aiohttp in /usr/local/lib/python3.7/dist-packages (from datasets) (3.8.1)\n",
90
            "Collecting responses<0.19\n",
91
            "  Downloading responses-0.18.0-py3-none-any.whl (38 kB)\n",
92
            "Requirement already satisfied: fsspec[http]>=2021.11.1 in /usr/local/lib/python3.7/dist-packages (from datasets) (2022.7.1)\n",
93
            "Requirement already satisfied: dill<0.3.6 in /usr/local/lib/python3.7/dist-packages (from datasets) (0.3.5.1)\n",
94
            "Requirement already satisfied: packaging in /usr/local/lib/python3.7/dist-packages (from datasets) (21.3)\n",
95
            "Requirement already satisfied: pyyaml>=5.1 in /usr/local/lib/python3.7/dist-packages (from huggingface-hub<1.0.0,>=0.1.0->datasets) (6.0)\n",
96
            "Requirement already satisfied: typing-extensions>=3.7.4.3 in /usr/local/lib/python3.7/dist-packages (from huggingface-hub<1.0.0,>=0.1.0->datasets) (4.1.1)\n",
97
            "Requirement already satisfied: filelock in /usr/local/lib/python3.7/dist-packages (from huggingface-hub<1.0.0,>=0.1.0->datasets) (3.8.0)\n",
98
            "Requirement already satisfied: pyparsing!=3.0.5,>=2.0.2 in /usr/local/lib/python3.7/dist-packages (from packaging->datasets) (3.0.9)\n",
99
            "Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.7/dist-packages (from requests>=2.19.0->datasets) (2022.6.15)\n",
100
            "Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /usr/local/lib/python3.7/dist-packages (from requests>=2.19.0->datasets) (1.24.3)\n",
101
            "Requirement already satisfied: idna<3,>=2.5 in /usr/local/lib/python3.7/dist-packages (from requests>=2.19.0->datasets) (2.10)\n",
102
            "Requirement already satisfied: chardet<4,>=3.0.2 in /usr/local/lib/python3.7/dist-packages (from requests>=2.19.0->datasets) (3.0.4)\n",
103
            "Collecting urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1\n",
104
            "  Downloading urllib3-1.25.11-py2.py3-none-any.whl (127 kB)\n",
105
            "\u001b[K     |████████████████████████████████| 127 kB 59.8 MB/s \n",
106
            "\u001b[?25hRequirement already satisfied: regex!=2019.12.17 in /usr/local/lib/python3.7/dist-packages (from transformers) (2022.6.2)\n",
107
            "Collecting tokenizers!=0.11.3,<0.13,>=0.11.1\n",
108
            "  Downloading tokenizers-0.12.1-cp37-cp37m-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (6.6 MB)\n",
109
            "\u001b[K     |████████████████████████████████| 6.6 MB 42.9 MB/s \n",
110
            "\u001b[?25hCollecting loguru>=0.5.0\n",
111
            "  Downloading loguru-0.6.0-py3-none-any.whl (58 kB)\n",
112
            "\u001b[K     |████████████████████████████████| 58 kB 5.8 MB/s \n",
113
            "\u001b[?25hRequirement already satisfied: python-dateutil>=2.5.3 in /usr/local/lib/python3.7/dist-packages (from pinecone-client) (2.8.2)\n",
114
            "Collecting dnspython>=2.0.0\n",
115
            "  Downloading dnspython-2.2.1-py3-none-any.whl (269 kB)\n",
116
            "\u001b[K     |████████████████████████████████| 269 kB 50.7 MB/s \n",
117
            "\u001b[?25hRequirement already satisfied: six>=1.5 in /usr/local/lib/python3.7/dist-packages (from python-dateutil>=2.5.3->pinecone-client) (1.15.0)\n",
118
            "Requirement already satisfied: keras<2.9,>=2.8.0rc0 in /usr/local/lib/python3.7/dist-packages (from tensorflow) (2.8.0)\n",
119
            "Requirement already satisfied: protobuf<3.20,>=3.9.2 in /usr/local/lib/python3.7/dist-packages (from tensorflow) (3.17.3)\n",
120
            "Requirement already satisfied: wrapt>=1.11.0 in /usr/local/lib/python3.7/dist-packages (from tensorflow) (1.14.1)\n",
121
            "Requirement already satisfied: gast>=0.2.1 in /usr/local/lib/python3.7/dist-packages (from tensorflow) (0.5.3)\n",
122
            "Requirement already satisfied: opt-einsum>=2.3.2 in /usr/local/lib/python3.7/dist-packages (from tensorflow) (3.3.0)\n",
123
            "Requirement already satisfied: tensorboard<2.9,>=2.8 in /usr/local/lib/python3.7/dist-packages (from tensorflow) (2.8.0)\n",
124
            "Requirement already satisfied: setuptools in /usr/local/lib/python3.7/dist-packages (from tensorflow) (57.4.0)\n",
125
            "Requirement already satisfied: google-pasta>=0.1.1 in /usr/local/lib/python3.7/dist-packages (from tensorflow) (0.2.0)\n",
126
            "Requirement already satisfied: keras-preprocessing>=1.1.1 in /usr/local/lib/python3.7/dist-packages (from tensorflow) (1.1.2)\n",
127
            "Requirement already satisfied: grpcio<2.0,>=1.24.3 in /usr/local/lib/python3.7/dist-packages (from tensorflow) (1.47.0)\n",
128
            "Requirement already satisfied: tensorflow-io-gcs-filesystem>=0.23.1 in /usr/local/lib/python3.7/dist-packages (from tensorflow) (0.26.0)\n",
129
            "Requirement already satisfied: tensorflow-estimator<2.9,>=2.8 in /usr/local/lib/python3.7/dist-packages (from tensorflow) (2.8.0)\n",
130
            "Requirement already satisfied: h5py>=2.9.0 in /usr/local/lib/python3.7/dist-packages (from tensorflow) (3.1.0)\n",
131
            "Requirement already satisfied: libclang>=9.0.1 in /usr/local/lib/python3.7/dist-packages (from tensorflow) (14.0.6)\n",
132
            "Requirement already satisfied: flatbuffers>=1.12 in /usr/local/lib/python3.7/dist-packages (from tensorflow) (2.0)\n",
133
            "Requirement already satisfied: absl-py>=0.4.0 in /usr/local/lib/python3.7/dist-packages (from tensorflow) (1.2.0)\n",
134
            "Requirement already satisfied: termcolor>=1.1.0 in /usr/local/lib/python3.7/dist-packages (from tensorflow) (1.1.0)\n",
135
            "Requirement already satisfied: astunparse>=1.6.0 in /usr/local/lib/python3.7/dist-packages (from tensorflow) (1.6.3)\n",
136
            "Requirement already satisfied: wheel<1.0,>=0.23.0 in /usr/local/lib/python3.7/dist-packages (from astunparse>=1.6.0->tensorflow) (0.37.1)\n",
137
            "Requirement already satisfied: cached-property in /usr/local/lib/python3.7/dist-packages (from h5py>=2.9.0->tensorflow) (1.5.2)\n",
138
            "Requirement already satisfied: tensorboard-plugin-wit>=1.6.0 in /usr/local/lib/python3.7/dist-packages (from tensorboard<2.9,>=2.8->tensorflow) (1.8.1)\n",
139
            "Requirement already satisfied: google-auth<3,>=1.6.3 in /usr/local/lib/python3.7/dist-packages (from tensorboard<2.9,>=2.8->tensorflow) (1.35.0)\n",
140
            "Requirement already satisfied: tensorboard-data-server<0.7.0,>=0.6.0 in /usr/local/lib/python3.7/dist-packages (from tensorboard<2.9,>=2.8->tensorflow) (0.6.1)\n",
141
            "Requirement already satisfied: markdown>=2.6.8 in /usr/local/lib/python3.7/dist-packages (from tensorboard<2.9,>=2.8->tensorflow) (3.4.1)\n",
142
            "Requirement already satisfied: werkzeug>=0.11.15 in /usr/local/lib/python3.7/dist-packages (from tensorboard<2.9,>=2.8->tensorflow) (1.0.1)\n",
143
            "Requirement already satisfied: google-auth-oauthlib<0.5,>=0.4.1 in /usr/local/lib/python3.7/dist-packages (from tensorboard<2.9,>=2.8->tensorflow) (0.4.6)\n",
144
            "Requirement already satisfied: pyasn1-modules>=0.2.1 in /usr/local/lib/python3.7/dist-packages (from google-auth<3,>=1.6.3->tensorboard<2.9,>=2.8->tensorflow) (0.2.8)\n",
145
            "Requirement already satisfied: cachetools<5.0,>=2.0.0 in /usr/local/lib/python3.7/dist-packages (from google-auth<3,>=1.6.3->tensorboard<2.9,>=2.8->tensorflow) (4.2.4)\n",
146
            "Requirement already satisfied: rsa<5,>=3.1.4 in /usr/local/lib/python3.7/dist-packages (from google-auth<3,>=1.6.3->tensorboard<2.9,>=2.8->tensorflow) (4.9)\n",
147
            "Requirement already satisfied: requests-oauthlib>=0.7.0 in /usr/local/lib/python3.7/dist-packages (from google-auth-oauthlib<0.5,>=0.4.1->tensorboard<2.9,>=2.8->tensorflow) (1.3.1)\n",
148
            "Requirement already satisfied: zipp>=0.5 in /usr/local/lib/python3.7/dist-packages (from importlib-metadata->datasets) (3.8.1)\n",
149
            "Requirement already satisfied: pyasn1<0.5.0,>=0.4.6 in /usr/local/lib/python3.7/dist-packages (from pyasn1-modules>=0.2.1->google-auth<3,>=1.6.3->tensorboard<2.9,>=2.8->tensorflow) (0.4.8)\n",
150
            "Requirement already satisfied: oauthlib>=3.0.0 in /usr/local/lib/python3.7/dist-packages (from requests-oauthlib>=0.7.0->google-auth-oauthlib<0.5,>=0.4.1->tensorboard<2.9,>=2.8->tensorflow) (3.2.0)\n",
151
            "Requirement already satisfied: multidict<7.0,>=4.5 in /usr/local/lib/python3.7/dist-packages (from aiohttp->datasets) (6.0.2)\n",
152
            "Requirement already satisfied: attrs>=17.3.0 in /usr/local/lib/python3.7/dist-packages (from aiohttp->datasets) (22.1.0)\n",
153
            "Requirement already satisfied: frozenlist>=1.1.1 in /usr/local/lib/python3.7/dist-packages (from aiohttp->datasets) (1.3.1)\n",
154
            "Requirement already satisfied: async-timeout<5.0,>=4.0.0a3 in /usr/local/lib/python3.7/dist-packages (from aiohttp->datasets) (4.0.2)\n",
155
            "Requirement already satisfied: yarl<2.0,>=1.0 in /usr/local/lib/python3.7/dist-packages (from aiohttp->datasets) (1.8.1)\n",
156
            "Requirement already satisfied: asynctest==0.13.0 in /usr/local/lib/python3.7/dist-packages (from aiohttp->datasets) (0.13.0)\n",
157
            "Requirement already satisfied: charset-normalizer<3.0,>=2.0 in /usr/local/lib/python3.7/dist-packages (from aiohttp->datasets) (2.1.0)\n",
158
            "Requirement already satisfied: aiosignal>=1.1.2 in /usr/local/lib/python3.7/dist-packages (from aiohttp->datasets) (1.2.0)\n",
159
            "Requirement already satisfied: pytz>=2017.3 in /usr/local/lib/python3.7/dist-packages (from pandas->datasets) (2022.2.1)\n",
160
            "Installing collected packages: urllib3, xxhash, tokenizers, responses, multiprocess, loguru, huggingface-hub, dnspython, transformers, pinecone-client, datasets\n",
161
            "  Attempting uninstall: urllib3\n",
162
            "    Found existing installation: urllib3 1.24.3\n",
163
            "    Uninstalling urllib3-1.24.3:\n",
164
            "      Successfully uninstalled urllib3-1.24.3\n",
165
            "Successfully installed datasets-2.4.0 dnspython-2.2.1 huggingface-hub-0.9.1 loguru-0.6.0 multiprocess-0.70.13 pinecone-client-2.0.13 responses-0.18.0 tokenizers-0.12.1 transformers-4.21.2 urllib3-1.25.11 xxhash-3.0.0\n"
166
          ]
167
        }
168
      ],
169
      "source": [
170
        "!pip install datasets transformers pinecone-client tensorflow"
171
      ]
172
    },
173
    {
174
      "cell_type": "markdown",
175
      "metadata": {
176
        "id": "31yHx1YypSTg"
177
      },
178
      "source": [
179
        "## Load the Dataset"
180
      ]
181
    },
182
    {
183
      "cell_type": "markdown",
184
      "metadata": {
185
        "id": "6J81Bqi0Dyeh"
186
      },
187
      "source": [
188
        "We will use a subset of the [MovieLens 25M Dataset](\"https://grouplens.org/datasets/movielens/25m/\") in this project. This dataset contains ~1M user ratings provided by over 30k unique users for the most recent ~10k movies from the [MovieLens 25M Dataset](\"https://grouplens.org/datasets/movielens/25m/\"). The subset is available [here](\"https://huggingface.co/datasets/pinecone/movielens-recent-ratings\") on HuggingFace datasets."
189
      ]
190
    },
191
    {
192
      "cell_type": "code",
193
      "execution_count": 1,
194
      "metadata": {
195
        "colab": {
196
          "base_uri": "https://localhost:8080/"
197
        },
198
        "id": "dVLLa2VihzCz",
199
        "outputId": "3ec19239-dd49-4d25-e793-c6a58962266a"
200
      },
201
      "outputs": [
202
        {
203
          "name": "stderr",
204
          "output_type": "stream",
205
          "text": [
206
            "Using custom data configuration default\n",
207
            "Reusing dataset movie_lens (/Users/jamesbriggs/.cache/huggingface/datasets/pinecone___movie_lens/default/0.0.0/0b5cf78c3c23d9db1c33d17d7d490a06b45c6d9f00a6691aa005c6fcad1c8b82)\n"
208
          ]
209
        }
210
      ],
211
      "source": [
212
        "from datasets import load_dataset\n",
213
        "\n",
214
        "# load the dataset into a pandas datafame\n",
215
        "movies = load_dataset(\"pinecone/movielens-recent-ratings\", split=\"train\").to_pandas()"
216
      ]
217
    },
218
    {
219
      "cell_type": "code",
220
      "execution_count": 2,
221
      "metadata": {
222
        "colab": {
223
          "base_uri": "https://localhost:8080/",
224
          "height": 468
225
        },
226
        "id": "JAMCB9P0PqEu",
227
        "outputId": "6f91258f-5234-4214-8363-556e638fd5a2"
228
      },
229
      "outputs": [
230
        {
231
          "data": {
232
            "text/html": [
233
              "<div>\n",
234
              "<style scoped>\n",
235
              "    .dataframe tbody tr th:only-of-type {\n",
236
              "        vertical-align: middle;\n",
237
              "    }\n",
238
              "\n",
239
              "    .dataframe tbody tr th {\n",
240
              "        vertical-align: top;\n",
241
              "    }\n",
242
              "\n",
243
              "    .dataframe thead th {\n",
244
              "        text-align: right;\n",
245
              "    }\n",
246
              "</style>\n",
247
              "<table border=\"1\" class=\"dataframe\">\n",
248
              "  <thead>\n",
249
              "    <tr style=\"text-align: right;\">\n",
250
              "      <th></th>\n",
251
              "      <th>imdb_id</th>\n",
252
              "      <th>movie_id</th>\n",
253
              "      <th>user_id</th>\n",
254
              "      <th>rating</th>\n",
255
              "      <th>title</th>\n",
256
              "      <th>poster</th>\n",
257
              "    </tr>\n",
258
              "  </thead>\n",
259
              "  <tbody>\n",
260
              "    <tr>\n",
261
              "      <th>0</th>\n",
262
              "      <td>tt5027774</td>\n",
263
              "      <td>6705</td>\n",
264
              "      <td>4556</td>\n",
265
              "      <td>4.0</td>\n",
266
              "      <td>Three Billboards Outside Ebbing, Missouri (2017)</td>\n",
267
              "      <td>https://m.media-amazon.com/images/M/MV5BMjI0OD...</td>\n",
268
              "    </tr>\n",
269
              "    <tr>\n",
270
              "      <th>1</th>\n",
271
              "      <td>tt5463162</td>\n",
272
              "      <td>7966</td>\n",
273
              "      <td>20798</td>\n",
274
              "      <td>3.5</td>\n",
275
              "      <td>Deadpool 2 (2018)</td>\n",
276
              "      <td>https://m.media-amazon.com/images/M/MV5BMDkzNm...</td>\n",
277
              "    </tr>\n",
278
              "    <tr>\n",
279
              "      <th>2</th>\n",
280
              "      <td>tt4007502</td>\n",
281
              "      <td>1614</td>\n",
282
              "      <td>26543</td>\n",
283
              "      <td>4.5</td>\n",
284
              "      <td>Frozen Fever (2015)</td>\n",
285
              "      <td>https://m.media-amazon.com/images/M/MV5BMjY3YT...</td>\n",
286
              "    </tr>\n",
287
              "    <tr>\n",
288
              "      <th>3</th>\n",
289
              "      <td>tt4209788</td>\n",
290
              "      <td>7022</td>\n",
291
              "      <td>4106</td>\n",
292
              "      <td>4.0</td>\n",
293
              "      <td>Molly's Game (2017)</td>\n",
294
              "      <td>https://m.media-amazon.com/images/M/MV5BNTkzMz...</td>\n",
295
              "    </tr>\n",
296
              "    <tr>\n",
297
              "      <th>4</th>\n",
298
              "      <td>tt2948356</td>\n",
299
              "      <td>3571</td>\n",
300
              "      <td>15259</td>\n",
301
              "      <td>4.0</td>\n",
302
              "      <td>Zootopia (2016)</td>\n",
303
              "      <td>https://m.media-amazon.com/images/M/MV5BOTMyMj...</td>\n",
304
              "    </tr>\n",
305
              "  </tbody>\n",
306
              "</table>\n",
307
              "</div>"
308
            ],
309
            "text/plain": [
310
              "     imdb_id  movie_id  user_id  rating  \\\n",
311
              "0  tt5027774      6705     4556     4.0   \n",
312
              "1  tt5463162      7966    20798     3.5   \n",
313
              "2  tt4007502      1614    26543     4.5   \n",
314
              "3  tt4209788      7022     4106     4.0   \n",
315
              "4  tt2948356      3571    15259     4.0   \n",
316
              "\n",
317
              "                                              title  \\\n",
318
              "0  Three Billboards Outside Ebbing, Missouri (2017)   \n",
319
              "1                                 Deadpool 2 (2018)   \n",
320
              "2                               Frozen Fever (2015)   \n",
321
              "3                               Molly's Game (2017)   \n",
322
              "4                                   Zootopia (2016)   \n",
323
              "\n",
324
              "                                              poster  \n",
325
              "0  https://m.media-amazon.com/images/M/MV5BMjI0OD...  \n",
326
              "1  https://m.media-amazon.com/images/M/MV5BMDkzNm...  \n",
327
              "2  https://m.media-amazon.com/images/M/MV5BMjY3YT...  \n",
328
              "3  https://m.media-amazon.com/images/M/MV5BNTkzMz...  \n",
329
              "4  https://m.media-amazon.com/images/M/MV5BOTMyMj...  "
330
            ]
331
          },
332
          "execution_count": 2,
333
          "metadata": {},
334
          "output_type": "execute_result"
335
        }
336
      ],
337
      "source": [
338
        "# drop duplicates to return only unique movies\n",
339
        "unique_movies = movies.drop_duplicates(subset=\"imdb_id\")\n",
340
        "unique_movies.head()"
341
      ]
342
    },
343
    {
344
      "cell_type": "markdown",
345
      "metadata": {
346
        "id": "UPuPhbwdo8U_"
347
      },
348
      "source": [
349
        "## Initialize Embedding Models"
350
      ]
351
    },
352
    {
353
      "cell_type": "markdown",
354
      "metadata": {
355
        "id": "_6hGsCfQDyek"
356
      },
357
      "source": [
358
        "The `user_model` and `movie_model` are trained using Tensorflow Keras. The `user_model` transforms a given `user_id` into a 32-dimensional embedding in the same vector space as the movies, representing the user’s movie preference. The movie recommendations are then fetched based on proximity to the user’s location in the multi-dimensional space.\n",
359
        "\n",
360
        "Similarly, the `movie_model` transforms a given `movie_id` into a 32-dimensional embedding in the same vector space as other similar movies — making it possible to find movies similar to a given movie."
361
      ]
362
    },
363
    {
364
      "cell_type": "code",
365
      "execution_count": 3,
366
      "metadata": {
367
        "colab": {
368
          "base_uri": "https://localhost:8080/"
369
        },
370
        "id": "j5e1W6y-iDaB",
371
        "outputId": "e8c5fe14-1c6e-49b9-d620-efb64231e024"
372
      },
373
      "outputs": [
374
        {
375
          "name": "stderr",
376
          "output_type": "stream",
377
          "text": [
378
            "config.json not found in HuggingFace Hub\n",
379
            "WARNING:huggingface_hub.hub_mixin:config.json not found in HuggingFace Hub\n",
380
            "WARNING:tensorflow:No training configuration found in save file, so the model was *not* compiled. Compile it manually.\n",
381
            "config.json not found in HuggingFace Hub\n",
382
            "WARNING:huggingface_hub.hub_mixin:config.json not found in HuggingFace Hub\n",
383
            "WARNING:tensorflow:No training configuration found in save file, so the model was *not* compiled. Compile it manually.\n"
384
          ]
385
        }
386
      ],
387
      "source": [
388
        "from huggingface_hub import from_pretrained_keras\n",
389
        "\n",
390
        "# load the user model and movie model from huggingface\n",
391
        "user_model = from_pretrained_keras(\"pinecone/movie-recommender-user-model\")\n",
392
        "movie_model = from_pretrained_keras(\"pinecone/movie-recommender-movie-model\")"
393
      ]
394
    },
395
    {
396
      "cell_type": "markdown",
397
      "metadata": {
398
        "id": "o-wajDikpt3H"
399
      },
400
      "source": [
401
        "## Create Pinecone Index\n",
402
        "\n",
403
        "To create our vector index, we first need to initialize our connection to Pinecone. For this we need a [free API key](https://app.pinecone.io/), and then we initialize the connection like so:"
404
      ]
405
    },
406
    {
407
      "cell_type": "code",
408
      "execution_count": 4,
409
      "metadata": {
410
        "id": "PrqMTs9K-02u"
411
      },
412
      "outputs": [],
413
      "source": [
414
        "from pinecone import Pinecone\n",
415
        "\n",
416
        "# connect to pinecone environment\n",
417
        "pinecone.init(\n",
418
        "    api_key=\"YOUR_API_KEY\",\n",
419
        "    environment=\"YOUR_ENV\"  # find next to API key in console\n",
420
        ")"
421
      ]
422
    },
423
    {
424
      "cell_type": "markdown",
425
      "metadata": {
426
        "id": "cCZRz6Z_-02v"
427
      },
428
      "source": [
429
        "Now we create a new index called `\"movie-emb\"`, what we name this isn't important."
430
      ]
431
    },
432
    {
433
      "cell_type": "code",
434
      "execution_count": 5,
435
      "metadata": {
436
        "id": "gFaRlM9jj4Gm"
437
      },
438
      "outputs": [],
439
      "source": [
440
        "index_name = 'movie-emb'\n",
441
        "\n",
442
        "# check if the movie-emb index exists\n",
443
        "if index_name not in pinecone.list_indexes().names():\n",
444
        "    # create the index if it does not exist\n",
445
        "    pinecone.create_index(\n",
446
        "        index_name,\n",
447
        "        dimension=32,\n",
448
        "        metric=\"cosine\"\n",
449
        "    )\n",
450
        "\n",
451
        "# connect to movie-emb index we created\n",
452
        "index = pinecone.Index(index_name)"
453
      ]
454
    },
455
    {
456
      "cell_type": "markdown",
457
      "metadata": {
458
        "id": "6cyoscY0qFUx"
459
      },
460
      "source": [
461
        "## Create Movie Embeddings\n",
462
        "\n",
463
        "We will be creating movie embeddings using the pretrained `movie_model`. All of the movie embeddings will be upserted to the new `\"movie-emb\"` index in Pinecone."
464
      ]
465
    },
466
    {
467
      "cell_type": "code",
468
      "execution_count": 6,
469
      "metadata": {
470
        "colab": {
471
          "base_uri": "https://localhost:8080/",
472
          "height": 120,
473
          "referenced_widgets": [
474
            "803e5ce5e1474d2cbd5cb5cb32597476",
475
            "9cf021d7e1ce41fa8d3e669fd036dacc",
476
            "15e64e605cff4e87b90d95dd7dd68b3c",
477
            "becf8f08940241a8afef20544f813180",
478
            "3a3474a650984ac0a87334f2e7614adb",
479
            "5d6e71aed5644c3781c3c63c306c549e",
480
            "6ebae25f1b544f86839aa30e039b1c4c",
481
            "e63c019f736a4b45801060fe141c6b3a",
482
            "fd05a1870afc4b01b1ca8176908cc80b",
483
            "85c28595f31d45abae924197010930d4",
484
            "519aa0cccee14aa49498e072aac368ac"
485
          ]
486
        },
487
        "id": "uew_qC8Gksrf",
488
        "outputId": "098c95e5-b9b5-494a-8cc3-23f24290b0c8"
489
      },
490
      "outputs": [
491
        {
492
          "data": {
493
            "application/vnd.jupyter.widget-view+json": {
494
              "model_id": "803e5ce5e1474d2cbd5cb5cb32597476",
495
              "version_major": 2,
496
              "version_minor": 0
497
            },
498
            "text/plain": [
499
              "  0%|          | 0/161 [00:00<?, ?it/s]"
500
            ]
501
          },
502
          "metadata": {},
503
          "output_type": "display_data"
504
        },
505
        {
506
          "data": {
507
            "text/plain": [
508
              "{'dimension': 32,\n",
509
              " 'index_fullness': 0.0,\n",
510
              " 'namespaces': {'': {'vector_count': 10269}},\n",
511
              " 'total_vector_count': 10269}"
512
            ]
513
          },
514
          "execution_count": 6,
515
          "metadata": {},
516
          "output_type": "execute_result"
517
        }
518
      ],
519
      "source": [
520
        "from tqdm.auto import tqdm\n",
521
        "\n",
522
        "# we will use batches of 64\n",
523
        "batch_size = 64\n",
524
        "\n",
525
        "for i in tqdm(range(0, len(unique_movies), batch_size)):\n",
526
        "    # find end of batch\n",
527
        "    i_end = min(i+batch_size, len(unique_movies))\n",
528
        "    # extract batch\n",
529
        "    batch = unique_movies.iloc[i:i_end]\n",
530
        "    # generate embeddings for batch\n",
531
        "    emb = movie_model.predict(batch['movie_id']).tolist()\n",
532
        "    # get metadata\n",
533
        "    meta = batch.to_dict(orient='records')\n",
534
        "    # create IDs\n",
535
        "    ids = batch[\"imdb_id\"].values.tolist()\n",
536
        "    # add all to upsert list\n",
537
        "    to_upsert = list(zip(ids, emb, meta))\n",
538
        "    # upsert/insert these records to pinecone\n",
539
        "    _ = index.upsert(vectors=to_upsert)\n",
540
        "\n",
541
        "# check that we have all vectors in index\n",
542
        "index.describe_index_stats()"
543
      ]
544
    },
545
    {
546
      "cell_type": "markdown",
547
      "metadata": {
548
        "id": "yk5lwfwXqKw8"
549
      },
550
      "source": [
551
        "## Get Recommendations\n",
552
        "\n",
553
        "We now have movie embeddings stored in Pinecone. To get recommendations we can do two things:\n",
554
        "\n",
555
        "1. Get a user embedding via a user embedding model and our `user_id`s, and retrieve movie embeddings (from Pinecone) that are most similar.\n",
556
        "2. Use an existing movie embedding to retrieve other similar movies.\n",
557
        "\n",
558
        "Both of these use the same approach, the only difference is the source of data (user vs. movie) and the embedding model (user vs. movie).\n",
559
        "\n",
560
        "We will start with task **1**."
561
      ]
562
    },
563
    {
564
      "cell_type": "code",
565
      "execution_count": 7,
566
      "metadata": {
567
        "id": "oipl9zAwYOxd"
568
      },
569
      "outputs": [],
570
      "source": [
571
        "# we do this to display movie posters in this notebook\n",
572
        "from IPython.core.display import HTML"
573
      ]
574
    },
575
    {
576
      "cell_type": "markdown",
577
      "metadata": {
578
        "id": "NfzGKILl-02w"
579
      },
580
      "source": [
581
        "We will start by looking at a users top rated movies, we can find this information inside the `movies` dataframe by filtering for movie ratings by a specific user (as per their `user_id`), and ordering these by the rating score."
582
      ]
583
    },
584
    {
585
      "cell_type": "code",
586
      "execution_count": 8,
587
      "metadata": {
588
        "id": "wZIXAqCz-02w"
589
      },
590
      "outputs": [],
591
      "source": [
592
        "def top_movies_user_rated(user):\n",
593
        "    # get list of movies that the user has rated\n",
594
        "    user_movies = movies[movies[\"user_id\"] == user]\n",
595
        "    # order by their top rated movies\n",
596
        "    top_rated = user_movies.sort_values(by=['rating'], ascending=False)\n",
597
        "    # return the top 14 movies\n",
598
        "    return top_rated['poster'].tolist()[:14], top_rated['rating'].tolist()[:14]"
599
      ]
600
    },
601
    {
602
      "cell_type": "markdown",
603
      "metadata": {
604
        "id": "DYC8a9HH-02w"
605
      },
606
      "source": [
607
        "After this, we can define a function called `display_posters` that will take a list of movie posters (like those returned by `top_movies_user_rated`) and display them in the notebook."
608
      ]
609
    },
610
    {
611
      "cell_type": "code",
612
      "execution_count": 9,
613
      "metadata": {
614
        "id": "pFbl3NIPW7ZJ"
615
      },
616
      "outputs": [],
617
      "source": [
618
        "def display_posters(posters):\n",
619
        "    figures = []\n",
620
        "    for poster in posters:\n",
621
        "        figures.append(f'''\n",
622
        "            <figure style=\"margin: 5px !important;\">\n",
623
        "              <img src=\"{poster}\" style=\"width: 120px; height: 150px\" >\n",
624
        "            </figure>\n",
625
        "        ''')\n",
626
        "    return HTML(data=f'''\n",
627
        "        <div style=\"display: flex; flex-flow: row wrap; text-align: center;\">\n",
628
        "        {''.join(figures)}\n",
629
        "        </div>\n",
630
        "    ''')"
631
      ]
632
    },
633
    {
634
      "cell_type": "markdown",
635
      "metadata": {
636
        "id": "kAYhNHs0-02x"
637
      },
638
      "source": [
639
        "Let's take a look at user `3`s top rated movies:"
640
      ]
641
    },
642
    {
643
      "cell_type": "code",
644
      "execution_count": 10,
645
      "metadata": {
646
        "colab": {
647
          "base_uri": "https://localhost:8080/",
648
          "height": 181
649
        },
650
        "id": "6bYLYdsWsCdq",
651
        "outputId": "b54754a9-7ff5-4d9c-adbf-cf0b86ee2d51"
652
      },
653
      "outputs": [
654
        {
655
          "data": {
656
            "text/html": [
657
              "\n",
658
              "        <div style=\"display: flex; flex-flow: row wrap; text-align: center;\">\n",
659
              "        \n",
660
              "            <figure style=\"margin: 5px !important;\">\n",
661
              "              <img src=\"https://m.media-amazon.com/images/M/MV5BMDliOTIzNmUtOTllOC00NDU3LWFiNjYtMGM0NDc1YTMxNjYxXkEyXkFqcGdeQXVyNTM3NzExMDQ@._V1_SX300.jpg\" style=\"width: 120px; height: 150px\" >\n",
662
              "            </figure>\n",
663
              "        \n",
664
              "            <figure style=\"margin: 5px !important;\">\n",
665
              "              <img src=\"https://m.media-amazon.com/images/M/MV5BMjQ0MTgyNjAxMV5BMl5BanBnXkFtZTgwNjUzMDkyODE@._V1_SX300.jpg\" style=\"width: 120px; height: 150px\" >\n",
666
              "            </figure>\n",
667
              "        \n",
668
              "            <figure style=\"margin: 5px !important;\">\n",
669
              "              <img src=\"https://m.media-amazon.com/images/M/MV5BMTM4OGJmNWMtOTM4Ni00NTE3LTg3MDItZmQxYjc4N2JhNmUxXkEyXkFqcGdeQXVyNTgzMDMzMTg@._V1_SX300.jpg\" style=\"width: 120px; height: 150px\" >\n",
670
              "            </figure>\n",
671
              "        \n",
672
              "            <figure style=\"margin: 5px !important;\">\n",
673
              "              <img src=\"https://m.media-amazon.com/images/M/MV5BMTExMzU0ODcxNDheQTJeQWpwZ15BbWU4MDE1OTI4MzAy._V1_SX300.jpg\" style=\"width: 120px; height: 150px\" >\n",
674
              "            </figure>\n",
675
              "        \n",
676
              "            <figure style=\"margin: 5px !important;\">\n",
677
              "              <img src=\"https://m.media-amazon.com/images/M/MV5BMTc2MTQ3MDA1Nl5BMl5BanBnXkFtZTgwODA3OTI4NjE@._V1_SX300.jpg\" style=\"width: 120px; height: 150px\" >\n",
678
              "            </figure>\n",
679
              "        \n",
680
              "        </div>\n",
681
              "    "
682
            ],
683
            "text/plain": [
684
              "<IPython.core.display.HTML object>"
685
            ]
686
          },
687
          "execution_count": 10,
688
          "metadata": {},
689
          "output_type": "execute_result"
690
        }
691
      ],
692
      "source": [
693
        "user = 3\n",
694
        "top_rated, scores = top_movies_user_rated(user)\n",
695
        "display_posters(top_rated)"
696
      ]
697
    },
698
    {
699
      "cell_type": "code",
700
      "execution_count": 11,
701
      "metadata": {
702
        "colab": {
703
          "base_uri": "https://localhost:8080/"
704
        },
705
        "id": "9qm0wdthAlrF",
706
        "outputId": "402aa89b-253d-4e19-9a45-e459fa6d012a"
707
      },
708
      "outputs": [
709
        {
710
          "name": "stdout",
711
          "output_type": "stream",
712
          "text": [
713
            "[4.5, 4.0, 4.0, 2.5, 2.5]\n"
714
          ]
715
        }
716
      ],
717
      "source": [
718
        "print(scores)"
719
      ]
720
    },
721
    {
722
      "cell_type": "markdown",
723
      "metadata": {
724
        "id": "Y4px7ch7-02x"
725
      },
726
      "source": [
727
        "User `3` has rated these five movies, with *Big Hero 6*, *Civil War*, and *Avengers* being given good scores. They seem less enthusiastic about more sci-fi films like *Arrival* and *The Martian*.\n",
728
        "\n",
729
        "Now let's see how to make some movie recommendations for this user.\n",
730
        "\n",
731
        "Start by defining the `get_recommendations` function. Given a specific `user_id`, this uses the `user_model` to create a user embedding (`xq`). It then retrieves the most similar movie vectors from Pinecone (`xc`), and extracts the relevant movie posters so we can display them later."
732
      ]
733
    },
734
    {
735
      "cell_type": "code",
736
      "execution_count": 12,
737
      "metadata": {
738
        "id": "gtH6QeOKW35C"
739
      },
740
      "outputs": [],
741
      "source": [
742
        "def get_recommendations(user):\n",
743
        "    # generate embeddings for the user\n",
744
        "    xq = user_model([user]).numpy().tolist()\n",
745
        "    # compute cosine similarity between user and movie vectors and return top k movies\n",
746
        "    xc = index.query(vector=xq, top_k=14,\n",
747
        "                    include_metadata=True)\n",
748
        "    result = []\n",
749
        "    # iterate through results and extract movie posters\n",
750
        "    for match in xc['matches']:\n",
751
        "        poster = match['metadata']['poster']\n",
752
        "        result.append(poster)\n",
753
        "    return result"
754
      ]
755
    },
756
    {
757
      "cell_type": "markdown",
758
      "metadata": {
759
        "id": "Df_e5-rirUVw"
760
      },
761
      "source": [
762
        "## Recommendations for User"
763
      ]
764
    },
765
    {
766
      "cell_type": "code",
767
      "execution_count": 13,
768
      "metadata": {
769
        "colab": {
770
          "base_uri": "https://localhost:8080/",
771
          "height": 345
772
        },
773
        "id": "vqoOS9i8sE7G",
774
        "outputId": "267e60da-9cf2-4bdb-9d18-cdb1ae3e1e6c"
775
      },
776
      "outputs": [
777
        {
778
          "data": {
779
            "text/html": [
780
              "\n",
781
              "        <div style=\"display: flex; flex-flow: row wrap; text-align: center;\">\n",
782
              "        \n",
783
              "            <figure style=\"margin: 5px !important;\">\n",
784
              "              <img src=\"https://m.media-amazon.com/images/M/MV5BMDliOTIzNmUtOTllOC00NDU3LWFiNjYtMGM0NDc1YTMxNjYxXkEyXkFqcGdeQXVyNTM3NzExMDQ@._V1_SX300.jpg\" style=\"width: 120px; height: 150px\" >\n",
785
              "            </figure>\n",
786
              "        \n",
787
              "            <figure style=\"margin: 5px !important;\">\n",
788
              "              <img src=\"https://m.media-amazon.com/images/M/MV5BMjQ0MTgyNjAxMV5BMl5BanBnXkFtZTgwNjUzMDkyODE@._V1_SX300.jpg\" style=\"width: 120px; height: 150px\" >\n",
789
              "            </figure>\n",
790
              "        \n",
791
              "            <figure style=\"margin: 5px !important;\">\n",
792
              "              <img src=\"https://m.media-amazon.com/images/M/MV5BMTM4OGJmNWMtOTM4Ni00NTE3LTg3MDItZmQxYjc4N2JhNmUxXkEyXkFqcGdeQXVyNTgzMDMzMTg@._V1_SX300.jpg\" style=\"width: 120px; height: 150px\" >\n",
793
              "            </figure>\n",
794
              "        \n",
795
              "            <figure style=\"margin: 5px !important;\">\n",
796
              "              <img src=\"https://m.media-amazon.com/images/M/MV5BMGQzN2Y0NDYtOGNlOS00OTVjLTkzMGUtZjYzNzdlMjQxMzgzXkEyXkFqcGdeQXVyNTY4NTYzMDM@._V1_SX300.jpg\" style=\"width: 120px; height: 150px\" >\n",
797
              "            </figure>\n",
798
              "        \n",
799
              "            <figure style=\"margin: 5px !important;\">\n",
800
              "              <img src=\"https://m.media-amazon.com/images/M/MV5BMjMxNjY2MDU1OV5BMl5BanBnXkFtZTgwNzY1MTUwNTM@._V1_SX300.jpg\" style=\"width: 120px; height: 150px\" >\n",
801
              "            </figure>\n",
802
              "        \n",
803
              "            <figure style=\"margin: 5px !important;\">\n",
804
              "              <img src=\"https://m.media-amazon.com/images/M/MV5BNTk4ODQ1MzgzNl5BMl5BanBnXkFtZTgwMTMyMzM4MTI@._V1_SX300.jpg\" style=\"width: 120px; height: 150px\" >\n",
805
              "            </figure>\n",
806
              "        \n",
807
              "            <figure style=\"margin: 5px !important;\">\n",
808
              "              <img src=\"https://m.media-amazon.com/images/M/MV5BMjE0ODYxMzI2M15BMl5BanBnXkFtZTgwMDczODA2MDE@._V1_SX300.jpg\" style=\"width: 120px; height: 150px\" >\n",
809
              "            </figure>\n",
810
              "        \n",
811
              "            <figure style=\"margin: 5px !important;\">\n",
812
              "              <img src=\"https://m.media-amazon.com/images/M/MV5BNjM0NTc0NzItM2FlYS00YzEwLWE0YmUtNTA2ZWIzODc2OTgxXkEyXkFqcGdeQXVyNTgwNzIyNzg@._V1_SX300.jpg\" style=\"width: 120px; height: 150px\" >\n",
813
              "            </figure>\n",
814
              "        \n",
815
              "            <figure style=\"margin: 5px !important;\">\n",
816
              "              <img src=\"https://m.media-amazon.com/images/M/MV5BMTU0NDE0Nzk1NF5BMl5BanBnXkFtZTgwMTY1NTAxMzE@._V1_SX300.jpg\" style=\"width: 120px; height: 150px\" >\n",
817
              "            </figure>\n",
818
              "        \n",
819
              "            <figure style=\"margin: 5px !important;\">\n",
820
              "              <img src=\"https://m.media-amazon.com/images/M/MV5BMGZlNTY1ZWUtYTMzNC00ZjUyLWE0MjQtMTMxN2E3ODYxMWVmXkEyXkFqcGdeQXVyMDM2NDM2MQ@@._V1_SX300.jpg\" style=\"width: 120px; height: 150px\" >\n",
821
              "            </figure>\n",
822
              "        \n",
823
              "            <figure style=\"margin: 5px !important;\">\n",
824
              "              <img src=\"https://m.media-amazon.com/images/M/MV5BMTAwMjU5OTgxNjZeQTJeQWpwZ15BbWU4MDUxNDYxODEx._V1_SX300.jpg\" style=\"width: 120px; height: 150px\" >\n",
825
              "            </figure>\n",
826
              "        \n",
827
              "            <figure style=\"margin: 5px !important;\">\n",
828
              "              <img src=\"https://m.media-amazon.com/images/M/MV5BMjMyNDkzMzI1OF5BMl5BanBnXkFtZTgwODcxODg5MjI@._V1_SX300.jpg\" style=\"width: 120px; height: 150px\" >\n",
829
              "            </figure>\n",
830
              "        \n",
831
              "            <figure style=\"margin: 5px !important;\">\n",
832
              "              <img src=\"https://m.media-amazon.com/images/M/MV5BMTc5MDE2ODcwNV5BMl5BanBnXkFtZTgwMzI2NzQ2NzM@._V1_SX300.jpg\" style=\"width: 120px; height: 150px\" >\n",
833
              "            </figure>\n",
834
              "        \n",
835
              "            <figure style=\"margin: 5px !important;\">\n",
836
              "              <img src=\"https://m.media-amazon.com/images/M/MV5BYjhlNDljNTgtZjc4My00NmZmLTk2YzAtYWE5MDYwYjM4MTkzXkEyXkFqcGdeQXVyODE5NzE3OTE@._V1_SX300.jpg\" style=\"width: 120px; height: 150px\" >\n",
837
              "            </figure>\n",
838
              "        \n",
839
              "        </div>\n",
840
              "    "
841
            ],
842
            "text/plain": [
843
              "<IPython.core.display.HTML object>"
844
            ]
845
          },
846
          "execution_count": 13,
847
          "metadata": {},
848
          "output_type": "execute_result"
849
        }
850
      ],
851
      "source": [
852
        "urls = get_recommendations(user)\n",
853
        "display_posters(urls)"
854
      ]
855
    },
856
    {
857
      "cell_type": "markdown",
858
      "metadata": {
859
        "id": "uBZLlKNLBmPA"
860
      },
861
      "source": [
862
        "That looks good, the top results actually match the users three favorite results. Following this we see a lot of Marvel superhero films, which user `3` is probably going to enjoy judging from their current ratings.\n",
863
        "\n",
864
        "Let's see another user, this time we choose `128`."
865
      ]
866
    },
867
    {
868
      "cell_type": "code",
869
      "execution_count": 14,
870
      "metadata": {
871
        "colab": {
872
          "base_uri": "https://localhost:8080/",
873
          "height": 345
874
        },
875
        "id": "QUoCq5nLZfNs",
876
        "outputId": "010d36c2-181f-42c6-f707-59f8315914b3"
877
      },
878
      "outputs": [
879
        {
880
          "data": {
881
            "text/html": [
882
              "\n",
883
              "        <div style=\"display: flex; flex-flow: row wrap; text-align: center;\">\n",
884
              "        \n",
885
              "            <figure style=\"margin: 5px !important;\">\n",
886
              "              <img src=\"https://m.media-amazon.com/images/M/MV5BMTAwMjU5OTgxNjZeQTJeQWpwZ15BbWU4MDUxNDYxODEx._V1_SX300.jpg\" style=\"width: 120px; height: 150px\" >\n",
887
              "            </figure>\n",
888
              "        \n",
889
              "            <figure style=\"margin: 5px !important;\">\n",
890
              "              <img src=\"https://m.media-amazon.com/images/M/MV5BOTgwMzFiMWYtZDhlNS00ODNkLWJiODAtZDVhNzgyNzJhYjQ4L2ltYWdlXkEyXkFqcGdeQXVyNzEzOTYxNTQ@._V1_SX300.jpg\" style=\"width: 120px; height: 150px\" >\n",
891
              "            </figure>\n",
892
              "        \n",
893
              "            <figure style=\"margin: 5px !important;\">\n",
894
              "              <img src=\"https://m.media-amazon.com/images/M/MV5BMjQ0MTgyNjAxMV5BMl5BanBnXkFtZTgwNjUzMDkyODE@._V1_SX300.jpg\" style=\"width: 120px; height: 150px\" >\n",
895
              "            </figure>\n",
896
              "        \n",
897
              "            <figure style=\"margin: 5px !important;\">\n",
898
              "              <img src=\"https://m.media-amazon.com/images/M/MV5BMTk0MDQ3MzAzOV5BMl5BanBnXkFtZTgwNzU1NzE3MjE@._V1_SX300.jpg\" style=\"width: 120px; height: 150px\" >\n",
899
              "            </figure>\n",
900
              "        \n",
901
              "            <figure style=\"margin: 5px !important;\">\n",
902
              "              <img src=\"https://m.media-amazon.com/images/M/MV5BYmI5ZGIxOGMtMjcwMS00Yzk3LWE0YWUtMzc5YTFhNGQ4OWZmXkEyXkFqcGdeQXVyNTIzOTk5ODM@._V1_SX300.jpg\" style=\"width: 120px; height: 150px\" >\n",
903
              "            </figure>\n",
904
              "        \n",
905
              "            <figure style=\"margin: 5px !important;\">\n",
906
              "              <img src=\"https://m.media-amazon.com/images/M/MV5BOTc2OTA1MDM4M15BMl5BanBnXkFtZTgwNjczMDk5MjE@._V1_SX300.jpg\" style=\"width: 120px; height: 150px\" >\n",
907
              "            </figure>\n",
908
              "        \n",
909
              "            <figure style=\"margin: 5px !important;\">\n",
910
              "              <img src=\"https://m.media-amazon.com/images/M/MV5BMTQ1MjQwMTE5OF5BMl5BanBnXkFtZTgwNjk3MTcyMDE@._V1_SX300.jpg\" style=\"width: 120px; height: 150px\" >\n",
911
              "            </figure>\n",
912
              "        \n",
913
              "            <figure style=\"margin: 5px !important;\">\n",
914
              "              <img src=\"https://m.media-amazon.com/images/M/MV5BOTgxMDQwMDk0OF5BMl5BanBnXkFtZTgwNjU5OTg2NDE@._V1_SX300.jpg\" style=\"width: 120px; height: 150px\" >\n",
915
              "            </figure>\n",
916
              "        \n",
917
              "            <figure style=\"margin: 5px !important;\">\n",
918
              "              <img src=\"https://m.media-amazon.com/images/M/MV5BOTAzODEzNDAzMl5BMl5BanBnXkFtZTgwMDU1MTgzNzE@._V1_SX300.jpg\" style=\"width: 120px; height: 150px\" >\n",
919
              "            </figure>\n",
920
              "        \n",
921
              "            <figure style=\"margin: 5px !important;\">\n",
922
              "              <img src=\"https://m.media-amazon.com/images/M/MV5BMTUxMjQ2NjI4OV5BMl5BanBnXkFtZTgwODc2NjUwNDE@._V1_SX300.jpg\" style=\"width: 120px; height: 150px\" >\n",
923
              "            </figure>\n",
924
              "        \n",
925
              "            <figure style=\"margin: 5px !important;\">\n",
926
              "              <img src=\"https://m.media-amazon.com/images/M/MV5BOTMyMjEyNzIzMV5BMl5BanBnXkFtZTgwNzIyNjU0NzE@._V1_SX300.jpg\" style=\"width: 120px; height: 150px\" >\n",
927
              "            </figure>\n",
928
              "        \n",
929
              "            <figure style=\"margin: 5px !important;\">\n",
930
              "              <img src=\"https://m.media-amazon.com/images/M/MV5BMTM4OGJmNWMtOTM4Ni00NTE3LTg3MDItZmQxYjc4N2JhNmUxXkEyXkFqcGdeQXVyNTgzMDMzMTg@._V1_SX300.jpg\" style=\"width: 120px; height: 150px\" >\n",
931
              "            </figure>\n",
932
              "        \n",
933
              "            <figure style=\"margin: 5px !important;\">\n",
934
              "              <img src=\"https://m.media-amazon.com/images/M/MV5BNzQ1MjQzMzM3OF5BMl5BanBnXkFtZTcwMzg3NzQ3OQ@@._V1_SX300.jpg\" style=\"width: 120px; height: 150px\" >\n",
935
              "            </figure>\n",
936
              "        \n",
937
              "            <figure style=\"margin: 5px !important;\">\n",
938
              "              <img src=\"https://m.media-amazon.com/images/M/MV5BMTc2MTQ3MDA1Nl5BMl5BanBnXkFtZTgwODA3OTI4NjE@._V1_SX300.jpg\" style=\"width: 120px; height: 150px\" >\n",
939
              "            </figure>\n",
940
              "        \n",
941
              "        </div>\n",
942
              "    "
943
            ],
944
            "text/plain": [
945
              "<IPython.core.display.HTML object>"
946
            ]
947
          },
948
          "execution_count": 14,
949
          "metadata": {},
950
          "output_type": "execute_result"
951
        }
952
      ],
953
      "source": [
954
        "user = 128\n",
955
        "top_rated, scores = top_movies_user_rated(user)\n",
956
        "display_posters(top_rated)"
957
      ]
958
    },
959
    {
960
      "cell_type": "code",
961
      "execution_count": 15,
962
      "metadata": {
963
        "colab": {
964
          "base_uri": "https://localhost:8080/"
965
        },
966
        "id": "00bc7fo-CBBo",
967
        "outputId": "a285948e-588a-4b0a-9bba-13373037ff62"
968
      },
969
      "outputs": [
970
        {
971
          "name": "stdout",
972
          "output_type": "stream",
973
          "text": [
974
            "[4.5, 4.5, 4.5, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0]\n"
975
          ]
976
        }
977
      ],
978
      "source": [
979
        "print(scores)"
980
      ]
981
    },
982
    {
983
      "cell_type": "markdown",
984
      "metadata": {
985
        "id": "amOQpXIUOu6c"
986
      },
987
      "source": [
988
        "Because this user seems to like everything, they also get recommended a mix of different things..."
989
      ]
990
    },
991
    {
992
      "cell_type": "code",
993
      "execution_count": 16,
994
      "metadata": {
995
        "colab": {
996
          "base_uri": "https://localhost:8080/",
997
          "height": 345
998
        },
999
        "id": "jD7ifvPIZry6",
1000
        "outputId": "d67fa480-298e-4733-b01d-3f50e2964150"
1001
      },
1002
      "outputs": [
1003
        {
1004
          "data": {
1005
            "text/html": [
1006
              "\n",
1007
              "        <div style=\"display: flex; flex-flow: row wrap; text-align: center;\">\n",
1008
              "        \n",
1009
              "            <figure style=\"margin: 5px !important;\">\n",
1010
              "              <img src=\"https://m.media-amazon.com/images/M/MV5BYjFhOWY0OTgtNDkzMC00YWJkLTk1NGEtYWUxNjhmMmQ5ZjYyXkEyXkFqcGdeQXVyMjMxOTE0ODA@._V1_SX300.jpg\" style=\"width: 120px; height: 150px\" >\n",
1011
              "            </figure>\n",
1012
              "        \n",
1013
              "            <figure style=\"margin: 5px !important;\">\n",
1014
              "              <img src=\"https://m.media-amazon.com/images/M/MV5BNjIwYjg1ZTEtOWRjYy00MTY3LWIyYTktMTI1Zjk2YzZkNDhiL2ltYWdlL2ltYWdlXkEyXkFqcGdeQXVyMjExNjgyMTc@._V1_SX300.jpg\" style=\"width: 120px; height: 150px\" >\n",
1015
              "            </figure>\n",
1016
              "        \n",
1017
              "            <figure style=\"margin: 5px !important;\">\n",
1018
              "              <img src=\"https://m.media-amazon.com/images/M/MV5BNDEwZjU4ZmYtNjk0Ny00ZjVjLWE4OGUtNWE5NzFhNDI0MjgyXkEyXkFqcGdeQXVyNjU2NTIyOTE@._V1_SX300.jpg\" style=\"width: 120px; height: 150px\" >\n",
1019
              "            </figure>\n",
1020
              "        \n",
1021
              "            <figure style=\"margin: 5px !important;\">\n",
1022
              "              <img src=\"https://m.media-amazon.com/images/M/MV5BMTUzMjAxMzg5M15BMl5BanBnXkFtZTgwNjIxNjk5NzE@._V1_SX300.jpg\" style=\"width: 120px; height: 150px\" >\n",
1023
              "            </figure>\n",
1024
              "        \n",
1025
              "            <figure style=\"margin: 5px !important;\">\n",
1026
              "              <img src=\"https://m.media-amazon.com/images/M/MV5BMTQ4NzI2OTg5NV5BMl5BanBnXkFtZTgwNjQ3MDgyMjE@._V1_SX300.jpg\" style=\"width: 120px; height: 150px\" >\n",
1027
              "            </figure>\n",
1028
              "        \n",
1029
              "            <figure style=\"margin: 5px !important;\">\n",
1030
              "              <img src=\"https://m.media-amazon.com/images/M/MV5BNDQ4YTAyNDktMDhhYi00MzgyLWI0ZTktMjNiMGQ4MGU0NDQyXkEyXkFqcGdeQXVyNDY5MTUyNjU@._V1_SX300.jpg\" style=\"width: 120px; height: 150px\" >\n",
1031
              "            </figure>\n",
1032
              "        \n",
1033
              "            <figure style=\"margin: 5px !important;\">\n",
1034
              "              <img src=\"https://m.media-amazon.com/images/M/MV5BMjk4NGZiMzAtODU1NS00MmQ4LWJiNmQtNWU5ZWU4Y2VmNWI0XkEyXkFqcGdeQXVyODE5NzE3OTE@._V1_SX300.jpg\" style=\"width: 120px; height: 150px\" >\n",
1035
              "            </figure>\n",
1036
              "        \n",
1037
              "            <figure style=\"margin: 5px !important;\">\n",
1038
              "              <img src=\"https://m.media-amazon.com/images/M/MV5BYWE1NWFhZWEtOTYxZS00NTZmLWE5OWItMGQ2MTYzODNiNjQxXkEyXkFqcGdeQXVyNDM1ODc2NzE@._V1_SX300.jpg\" style=\"width: 120px; height: 150px\" >\n",
1039
              "            </figure>\n",
1040
              "        \n",
1041
              "            <figure style=\"margin: 5px !important;\">\n",
1042
              "              <img src=\"https://m.media-amazon.com/images/M/MV5BZWVlZmQ5N2EtZTQ2My00ZDUzLThkMmQtMDgyYTgwZWZlMjA0XkEyXkFqcGdeQXVyMjQ5NjMxNDA@._V1_SX300.jpg\" style=\"width: 120px; height: 150px\" >\n",
1043
              "            </figure>\n",
1044
              "        \n",
1045
              "            <figure style=\"margin: 5px !important;\">\n",
1046
              "              <img src=\"https://m.media-amazon.com/images/M/MV5BYjkzZWIyZTctN2U3Ny00MDZlLTkzZTYtMTI2MWI5YTFiZWZkXkEyXkFqcGdeQXVyNTM2NTg3Nzg@._V1_SX300.jpg\" style=\"width: 120px; height: 150px\" >\n",
1047
              "            </figure>\n",
1048
              "        \n",
1049
              "            <figure style=\"margin: 5px !important;\">\n",
1050
              "              <img src=\"https://m.media-amazon.com/images/M/MV5BYmJhZmJlYTItZmZlNy00MGY0LTg0ZGMtNWFkYWU5NTA1YTNhXkEyXkFqcGdeQXVyODE5NzE3OTE@._V1_SX300.jpg\" style=\"width: 120px; height: 150px\" >\n",
1051
              "            </figure>\n",
1052
              "        \n",
1053
              "            <figure style=\"margin: 5px !important;\">\n",
1054
              "              <img src=\"https://m.media-amazon.com/images/M/MV5BMDNjZjkyNjQtNWMyMC00ODA5LTgyODctOGRiOWUwYTAzOWVjXkEyXkFqcGdeQXVyODE5NzE3OTE@._V1_SX300.jpg\" style=\"width: 120px; height: 150px\" >\n",
1055
              "            </figure>\n",
1056
              "        \n",
1057
              "            <figure style=\"margin: 5px !important;\">\n",
1058
              "              <img src=\"https://m.media-amazon.com/images/M/MV5BMTQzMjE5NDQwMl5BMl5BanBnXkFtZTgwMjI2NzA2MDE@._V1_SX300.jpg\" style=\"width: 120px; height: 150px\" >\n",
1059
              "            </figure>\n",
1060
              "        \n",
1061
              "            <figure style=\"margin: 5px !important;\">\n",
1062
              "              <img src=\"https://m.media-amazon.com/images/M/MV5BY2ViYjZiYTktZmJmMS00MGU5LTkxYjgtZWNkYzIyMGFjNWU4XkEyXkFqcGdeQXVyNTMzOTU3NzA@._V1_SX300.jpg\" style=\"width: 120px; height: 150px\" >\n",
1063
              "            </figure>\n",
1064
              "        \n",
1065
              "        </div>\n",
1066
              "    "
1067
            ],
1068
            "text/plain": [
1069
              "<IPython.core.display.HTML object>"
1070
            ]
1071
          },
1072
          "execution_count": 16,
1073
          "metadata": {},
1074
          "output_type": "execute_result"
1075
        }
1076
      ],
1077
      "source": [
1078
        "urls = get_recommendations(user)\n",
1079
        "display_posters(urls)"
1080
      ]
1081
    },
1082
    {
1083
      "cell_type": "code",
1084
      "execution_count": 17,
1085
      "metadata": {
1086
        "colab": {
1087
          "base_uri": "https://localhost:8080/",
1088
          "height": 181
1089
        },
1090
        "id": "74Zc96cZdiPA",
1091
        "outputId": "d978c0ad-6965-4d6b-92ab-ad5db2f7b0f8"
1092
      },
1093
      "outputs": [
1094
        {
1095
          "data": {
1096
            "text/html": [
1097
              "\n",
1098
              "        <div style=\"display: flex; flex-flow: row wrap; text-align: center;\">\n",
1099
              "        \n",
1100
              "            <figure style=\"margin: 5px !important;\">\n",
1101
              "              <img src=\"https://m.media-amazon.com/images/M/MV5BMTU2NjA1ODgzMF5BMl5BanBnXkFtZTgwMTM2MTI4MjE@._V1_SX300.jpg\" style=\"width: 120px; height: 150px\" >\n",
1102
              "            </figure>\n",
1103
              "        \n",
1104
              "            <figure style=\"margin: 5px !important;\">\n",
1105
              "              <img src=\"https://m.media-amazon.com/images/M/MV5BN2U1YzdhYWMtZWUzMi00OWI1LWFkM2ItNWVjM2YxMGQ2MmNhXkEyXkFqcGdeQXVyNjU0OTQ0OTY@._V1_SX300.jpg\" style=\"width: 120px; height: 150px\" >\n",
1106
              "            </figure>\n",
1107
              "        \n",
1108
              "            <figure style=\"margin: 5px !important;\">\n",
1109
              "              <img src=\"https://m.media-amazon.com/images/M/MV5BMzM5NjUxOTEyMl5BMl5BanBnXkFtZTgwNjEyMDM0MDE@._V1_SX300.jpg\" style=\"width: 120px; height: 150px\" >\n",
1110
              "            </figure>\n",
1111
              "        \n",
1112
              "            <figure style=\"margin: 5px !important;\">\n",
1113
              "              <img src=\"https://m.media-amazon.com/images/M/MV5BMTc2MTQ3MDA1Nl5BMl5BanBnXkFtZTgwODA3OTI4NjE@._V1_SX300.jpg\" style=\"width: 120px; height: 150px\" >\n",
1114
              "            </figure>\n",
1115
              "        \n",
1116
              "            <figure style=\"margin: 5px !important;\">\n",
1117
              "              <img src=\"https://m.media-amazon.com/images/M/MV5BMDliOTIzNmUtOTllOC00NDU3LWFiNjYtMGM0NDc1YTMxNjYxXkEyXkFqcGdeQXVyNTM3NzExMDQ@._V1_SX300.jpg\" style=\"width: 120px; height: 150px\" >\n",
1118
              "            </figure>\n",
1119
              "        \n",
1120
              "            <figure style=\"margin: 5px !important;\">\n",
1121
              "              <img src=\"https://m.media-amazon.com/images/M/MV5BOTgwMzFiMWYtZDhlNS00ODNkLWJiODAtZDVhNzgyNzJhYjQ4L2ltYWdlXkEyXkFqcGdeQXVyNzEzOTYxNTQ@._V1_SX300.jpg\" style=\"width: 120px; height: 150px\" >\n",
1122
              "            </figure>\n",
1123
              "        \n",
1124
              "            <figure style=\"margin: 5px !important;\">\n",
1125
              "              <img src=\"https://m.media-amazon.com/images/M/MV5BOTMyMjEyNzIzMV5BMl5BanBnXkFtZTgwNzIyNjU0NzE@._V1_SX300.jpg\" style=\"width: 120px; height: 150px\" >\n",
1126
              "            </figure>\n",
1127
              "        \n",
1128
              "        </div>\n",
1129
              "    "
1130
            ],
1131
            "text/plain": [
1132
              "<IPython.core.display.HTML object>"
1133
            ]
1134
          },
1135
          "execution_count": 17,
1136
          "metadata": {},
1137
          "output_type": "execute_result"
1138
        }
1139
      ],
1140
      "source": [
1141
        "user = 20000\n",
1142
        "top_rated, scores = top_movies_user_rated(user)\n",
1143
        "display_posters(top_rated)"
1144
      ]
1145
    },
1146
    {
1147
      "cell_type": "code",
1148
      "execution_count": 18,
1149
      "metadata": {
1150
        "colab": {
1151
          "base_uri": "https://localhost:8080/"
1152
        },
1153
        "id": "ux9hI8GoOrZ_",
1154
        "outputId": "b092ed50-8dc2-44b9-bcbb-d85285e098dc"
1155
      },
1156
      "outputs": [
1157
        {
1158
          "name": "stdout",
1159
          "output_type": "stream",
1160
          "text": [
1161
            "[5.0, 4.0, 3.5, 3.5, 3.5, 3.0, 1.0]\n"
1162
          ]
1163
        }
1164
      ],
1165
      "source": [
1166
        "print(scores)"
1167
      ]
1168
    },
1169
    {
1170
      "cell_type": "markdown",
1171
      "metadata": {
1172
        "id": "echEpgOFO3KU"
1173
      },
1174
      "source": [
1175
        "We can see more of a trend towards action films with this user, so we can expect the see similar action focused recommendations."
1176
      ]
1177
    },
1178
    {
1179
      "cell_type": "code",
1180
      "execution_count": 19,
1181
      "metadata": {
1182
        "colab": {
1183
          "base_uri": "https://localhost:8080/",
1184
          "height": 345
1185
        },
1186
        "id": "BcWNWs1osLnJ",
1187
        "outputId": "c47a263b-ea95-445b-a0f6-2201e868cba3"
1188
      },
1189
      "outputs": [
1190
        {
1191
          "data": {
1192
            "text/html": [
1193
              "\n",
1194
              "        <div style=\"display: flex; flex-flow: row wrap; text-align: center;\">\n",
1195
              "        \n",
1196
              "            <figure style=\"margin: 5px !important;\">\n",
1197
              "              <img src=\"https://m.media-amazon.com/images/M/MV5BMjE2NDkxNTY2M15BMl5BanBnXkFtZTgwMDc2NzE0MTI@._V1_SX300.jpg\" style=\"width: 120px; height: 150px\" >\n",
1198
              "            </figure>\n",
1199
              "        \n",
1200
              "            <figure style=\"margin: 5px !important;\">\n",
1201
              "              <img src=\"https://m.media-amazon.com/images/M/MV5BMTU2NjA1ODgzMF5BMl5BanBnXkFtZTgwMTM2MTI4MjE@._V1_SX300.jpg\" style=\"width: 120px; height: 150px\" >\n",
1202
              "            </figure>\n",
1203
              "        \n",
1204
              "            <figure style=\"margin: 5px !important;\">\n",
1205
              "              <img src=\"https://m.media-amazon.com/images/M/MV5BMTUyODU0ODU1Ml5BMl5BanBnXkFtZTgwNzM1MjIyMDE@._V1_SX300.jpg\" style=\"width: 120px; height: 150px\" >\n",
1206
              "            </figure>\n",
1207
              "        \n",
1208
              "            <figure style=\"margin: 5px !important;\">\n",
1209
              "              <img src=\"https://m.media-amazon.com/images/M/MV5BMjIzMzA5NDk0NF5BMl5BanBnXkFtZTgwMDY2OTE2OTE@._V1_SX300.jpg\" style=\"width: 120px; height: 150px\" >\n",
1210
              "            </figure>\n",
1211
              "        \n",
1212
              "            <figure style=\"margin: 5px !important;\">\n",
1213
              "              <img src=\"https://m.media-amazon.com/images/M/MV5BMTg5MTE2NjA4OV5BMl5BanBnXkFtZTgwMTUyMjczMTE@._V1_SX300.jpg\" style=\"width: 120px; height: 150px\" >\n",
1214
              "            </figure>\n",
1215
              "        \n",
1216
              "            <figure style=\"margin: 5px !important;\">\n",
1217
              "              <img src=\"https://m.media-amazon.com/images/M/MV5BOGQyYTZjMDktMWQwNS00Y2NiLTg5MDctMjE3NjU5MjhmZDdiXkEyXkFqcGdeQXVyNTE0MDY4Mjk@._V1_SX300.jpg\" style=\"width: 120px; height: 150px\" >\n",
1218
              "            </figure>\n",
1219
              "        \n",
1220
              "            <figure style=\"margin: 5px !important;\">\n",
1221
              "              <img src=\"https://m.media-amazon.com/images/M/MV5BNDA0MTlkYWQtNzNiMS00ZWE3LTg2ODUtZTQwNmVkN2E3M2NhXkEyXkFqcGdeQXVyNjUzNjY0NTE@._V1_SX300.jpg\" style=\"width: 120px; height: 150px\" >\n",
1222
              "            </figure>\n",
1223
              "        \n",
1224
              "            <figure style=\"margin: 5px !important;\">\n",
1225
              "              <img src=\"https://m.media-amazon.com/images/M/MV5BMTk1MjUzNzM0OF5BMl5BanBnXkFtZTgwMTg2MzIxMTI@._V1_SX300.jpg\" style=\"width: 120px; height: 150px\" >\n",
1226
              "            </figure>\n",
1227
              "        \n",
1228
              "            <figure style=\"margin: 5px !important;\">\n",
1229
              "              <img src=\"https://m.media-amazon.com/images/M/MV5BYzc5MTU4N2EtYTkyMi00NjdhLTg3NWEtMTY4OTEyMzJhZTAzXkEyXkFqcGdeQXVyNjc1NTYyMjg@._V1_SX300.jpg\" style=\"width: 120px; height: 150px\" >\n",
1230
              "            </figure>\n",
1231
              "        \n",
1232
              "            <figure style=\"margin: 5px !important;\">\n",
1233
              "              <img src=\"https://m.media-amazon.com/images/M/MV5BMjMyNDkzMzI1OF5BMl5BanBnXkFtZTgwODcxODg5MjI@._V1_SX300.jpg\" style=\"width: 120px; height: 150px\" >\n",
1234
              "            </figure>\n",
1235
              "        \n",
1236
              "            <figure style=\"margin: 5px !important;\">\n",
1237
              "              <img src=\"https://m.media-amazon.com/images/M/MV5BODg2OTVhZGQtYTU3Yi00NDg3LTljNzQtMjZhNDBhZjNlOGEyXkEyXkFqcGdeQXVyNjU1OTg4OTM@._V1_SX300.jpg\" style=\"width: 120px; height: 150px\" >\n",
1238
              "            </figure>\n",
1239
              "        \n",
1240
              "            <figure style=\"margin: 5px !important;\">\n",
1241
              "              <img src=\"https://m.media-amazon.com/images/M/MV5BOTQyODc5MTAwM15BMl5BanBnXkFtZTgwNjMwMjA1MjE@._V1_SX300.jpg\" style=\"width: 120px; height: 150px\" >\n",
1242
              "            </figure>\n",
1243
              "        \n",
1244
              "            <figure style=\"margin: 5px !important;\">\n",
1245
              "              <img src=\"https://m.media-amazon.com/images/M/MV5BYmY0NGNiNzQtYmQ2Yi00OWEyLThmMWMtZjUzM2UwNDg1YjUxXkEyXkFqcGdeQXVyNTg4MTExMTg@._V1_SX300.jpg\" style=\"width: 120px; height: 150px\" >\n",
1246
              "            </figure>\n",
1247
              "        \n",
1248
              "            <figure style=\"margin: 5px !important;\">\n",
1249
              "              <img src=\"https://m.media-amazon.com/images/M/MV5BM2Y3ZGM1OGItMTNjZS00MzI3LThkOGEtMDA2MmFlOTVlMTVhXkEyXkFqcGdeQXVyMTMxODk2OTU@._V1_SX300.jpg\" style=\"width: 120px; height: 150px\" >\n",
1250
              "            </figure>\n",
1251
              "        \n",
1252
              "        </div>\n",
1253
              "    "
1254
            ],
1255
            "text/plain": [
1256
              "<IPython.core.display.HTML object>"
1257
            ]
1258
          },
1259
          "execution_count": 19,
1260
          "metadata": {},
1261
          "output_type": "execute_result"
1262
        }
1263
      ],
1264
      "source": [
1265
        "urls = get_recommendations(user)\n",
1266
        "display_posters(urls)"
1267
      ]
1268
    },
1269
    {
1270
      "cell_type": "markdown",
1271
      "metadata": {
1272
        "id": "Siq05mZ9seVQ"
1273
      },
1274
      "source": [
1275
        "## Find Similar Movies"
1276
      ]
1277
    },
1278
    {
1279
      "cell_type": "markdown",
1280
      "metadata": {
1281
        "id": "IlRHMrhsDyeq"
1282
      },
1283
      "source": [
1284
        "Now let's see how to find some similar movies.\n",
1285
        "\n",
1286
        "Start by defining the `get_similar_movies` function. Given a specific `imdb_id`, we query directly using the pre-existing embedding for that ID stored in Pinecone."
1287
      ]
1288
    },
1289
    {
1290
      "cell_type": "code",
1291
      "execution_count": 20,
1292
      "metadata": {
1293
        "id": "amRMGIDTvcXZ"
1294
      },
1295
      "outputs": [],
1296
      "source": [
1297
        "# search for similar movies in pinecone index\n",
1298
        "def get_similar_movies(imdb_id):\n",
1299
        "    # compute cosine similarity between movie and embedding vectors and return top k movies\n",
1300
        "    xc = index.query(id=imdb_id, top_k=14, include_metadata=True)\n",
1301
        "    result = []\n",
1302
        "    # iterate through results and extract movie posters\n",
1303
        "    for match in xc['matches']:\n",
1304
        "        poster = match['metadata']['poster']\n",
1305
        "        result.append(poster)\n",
1306
        "    return result"
1307
      ]
1308
    },
1309
    {
1310
      "cell_type": "code",
1311
      "execution_count": 21,
1312
      "metadata": {
1313
        "colab": {
1314
          "base_uri": "https://localhost:8080/",
1315
          "height": 81
1316
        },
1317
        "id": "nvkhbfYdsbmR",
1318
        "outputId": "e18a6c47-a676-4bf5-da3f-45d425029a68"
1319
      },
1320
      "outputs": [
1321
        {
1322
          "data": {
1323
            "text/html": [
1324
              "\n",
1325
              "  <div id=\"df-ab0e361d-f5c4-46bb-a2b9-b79d18186f20\">\n",
1326
              "    <div class=\"colab-df-container\">\n",
1327
              "      <div>\n",
1328
              "<style scoped>\n",
1329
              "    .dataframe tbody tr th:only-of-type {\n",
1330
              "        vertical-align: middle;\n",
1331
              "    }\n",
1332
              "\n",
1333
              "    .dataframe tbody tr th {\n",
1334
              "        vertical-align: top;\n",
1335
              "    }\n",
1336
              "\n",
1337
              "    .dataframe thead th {\n",
1338
              "        text-align: right;\n",
1339
              "    }\n",
1340
              "</style>\n",
1341
              "<table border=\"1\" class=\"dataframe\">\n",
1342
              "  <thead>\n",
1343
              "    <tr style=\"text-align: right;\">\n",
1344
              "      <th></th>\n",
1345
              "      <th>imdb_id</th>\n",
1346
              "      <th>movie_id</th>\n",
1347
              "      <th>user_id</th>\n",
1348
              "      <th>rating</th>\n",
1349
              "      <th>title</th>\n",
1350
              "      <th>poster</th>\n",
1351
              "    </tr>\n",
1352
              "  </thead>\n",
1353
              "  <tbody>\n",
1354
              "    <tr>\n",
1355
              "      <th>11</th>\n",
1356
              "      <td>tt4154756</td>\n",
1357
              "      <td>1263</td>\n",
1358
              "      <td>153</td>\n",
1359
              "      <td>4.0</td>\n",
1360
              "      <td>Avengers: Infinity War - Part I (2018)</td>\n",
1361
              "      <td>https://m.media-amazon.com/images/M/MV5BMjMxNj...</td>\n",
1362
              "    </tr>\n",
1363
              "  </tbody>\n",
1364
              "</table>\n",
1365
              "</div>\n",
1366
              "      <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-ab0e361d-f5c4-46bb-a2b9-b79d18186f20')\"\n",
1367
              "              title=\"Convert this dataframe to an interactive table.\"\n",
1368
              "              style=\"display:none;\">\n",
1369
              "        \n",
1370
              "  <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\"viewBox=\"0 0 24 24\"\n",
1371
              "       width=\"24px\">\n",
1372
              "    <path d=\"M0 0h24v24H0V0z\" fill=\"none\"/>\n",
1373
              "    <path d=\"M18.56 5.44l.94 2.06.94-2.06 2.06-.94-2.06-.94-.94-2.06-.94 2.06-2.06.94zm-11 1L8.5 8.5l.94-2.06 2.06-.94-2.06-.94L8.5 2.5l-.94 2.06-2.06.94zm10 10l.94 2.06.94-2.06 2.06-.94-2.06-.94-.94-2.06-.94 2.06-2.06.94z\"/><path d=\"M17.41 7.96l-1.37-1.37c-.4-.4-.92-.59-1.43-.59-.52 0-1.04.2-1.43.59L10.3 9.45l-7.72 7.72c-.78.78-.78 2.05 0 2.83L4 21.41c.39.39.9.59 1.41.59.51 0 1.02-.2 1.41-.59l7.78-7.78 2.81-2.81c.8-.78.8-2.07 0-2.86zM5.41 20L4 18.59l7.72-7.72 1.47 1.35L5.41 20z\"/>\n",
1374
              "  </svg>\n",
1375
              "      </button>\n",
1376
              "      \n",
1377
              "  <style>\n",
1378
              "    .colab-df-container {\n",
1379
              "      display:flex;\n",
1380
              "      flex-wrap:wrap;\n",
1381
              "      gap: 12px;\n",
1382
              "    }\n",
1383
              "\n",
1384
              "    .colab-df-convert {\n",
1385
              "      background-color: #E8F0FE;\n",
1386
              "      border: none;\n",
1387
              "      border-radius: 50%;\n",
1388
              "      cursor: pointer;\n",
1389
              "      display: none;\n",
1390
              "      fill: #1967D2;\n",
1391
              "      height: 32px;\n",
1392
              "      padding: 0 0 0 0;\n",
1393
              "      width: 32px;\n",
1394
              "    }\n",
1395
              "\n",
1396
              "    .colab-df-convert:hover {\n",
1397
              "      background-color: #E2EBFA;\n",
1398
              "      box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
1399
              "      fill: #174EA6;\n",
1400
              "    }\n",
1401
              "\n",
1402
              "    [theme=dark] .colab-df-convert {\n",
1403
              "      background-color: #3B4455;\n",
1404
              "      fill: #D2E3FC;\n",
1405
              "    }\n",
1406
              "\n",
1407
              "    [theme=dark] .colab-df-convert:hover {\n",
1408
              "      background-color: #434B5C;\n",
1409
              "      box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n",
1410
              "      filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n",
1411
              "      fill: #FFFFFF;\n",
1412
              "    }\n",
1413
              "  </style>\n",
1414
              "\n",
1415
              "      <script>\n",
1416
              "        const buttonEl =\n",
1417
              "          document.querySelector('#df-ab0e361d-f5c4-46bb-a2b9-b79d18186f20 button.colab-df-convert');\n",
1418
              "        buttonEl.style.display =\n",
1419
              "          google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
1420
              "\n",
1421
              "        async function convertToInteractive(key) {\n",
1422
              "          const element = document.querySelector('#df-ab0e361d-f5c4-46bb-a2b9-b79d18186f20');\n",
1423
              "          const dataTable =\n",
1424
              "            await google.colab.kernel.invokeFunction('convertToInteractive',\n",
1425
              "                                                     [key], {});\n",
1426
              "          if (!dataTable) return;\n",
1427
              "\n",
1428
              "          const docLinkHtml = 'Like what you see? Visit the ' +\n",
1429
              "            '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n",
1430
              "            + ' to learn more about interactive tables.';\n",
1431
              "          element.innerHTML = '';\n",
1432
              "          dataTable['output_type'] = 'display_data';\n",
1433
              "          await google.colab.output.renderOutput(dataTable, element);\n",
1434
              "          const docLink = document.createElement('div');\n",
1435
              "          docLink.innerHTML = docLinkHtml;\n",
1436
              "          element.appendChild(docLink);\n",
1437
              "        }\n",
1438
              "      </script>\n",
1439
              "    </div>\n",
1440
              "  </div>\n",
1441
              "  "
1442
            ],
1443
            "text/plain": [
1444
              "      imdb_id  movie_id  user_id  rating  \\\n",
1445
              "11  tt4154756      1263      153     4.0   \n",
1446
              "\n",
1447
              "                                     title  \\\n",
1448
              "11  Avengers: Infinity War - Part I (2018)   \n",
1449
              "\n",
1450
              "                                               poster  \n",
1451
              "11  https://m.media-amazon.com/images/M/MV5BMjMxNj...  "
1452
            ]
1453
          },
1454
          "execution_count": 21,
1455
          "metadata": {},
1456
          "output_type": "execute_result"
1457
        }
1458
      ],
1459
      "source": [
1460
        "# imdbid of Avengers Infinity War\n",
1461
        "imdb_id = \"tt4154756\"\n",
1462
        "# filter the imdbid from the unique_movies\n",
1463
        "movie = unique_movies[unique_movies[\"imdb_id\"] == imdb_id]\n",
1464
        "movie"
1465
      ]
1466
    },
1467
    {
1468
      "cell_type": "code",
1469
      "execution_count": 22,
1470
      "metadata": {
1471
        "colab": {
1472
          "base_uri": "https://localhost:8080/",
1473
          "height": 181
1474
        },
1475
        "id": "IP6lNQYQ-02z",
1476
        "outputId": "bc613e28-83e4-4748-93d9-f31c1bc758c2"
1477
      },
1478
      "outputs": [
1479
        {
1480
          "data": {
1481
            "text/html": [
1482
              "\n",
1483
              "        <div style=\"display: flex; flex-flow: row wrap; text-align: center;\">\n",
1484
              "        \n",
1485
              "            <figure style=\"margin: 5px !important;\">\n",
1486
              "              <img src=\"https://m.media-amazon.com/images/M/MV5BMjMxNjY2MDU1OV5BMl5BanBnXkFtZTgwNzY1MTUwNTM@._V1_SX300.jpg\" style=\"width: 120px; height: 150px\" >\n",
1487
              "            </figure>\n",
1488
              "        \n",
1489
              "        </div>\n",
1490
              "    "
1491
            ],
1492
            "text/plain": [
1493
              "<IPython.core.display.HTML object>"
1494
            ]
1495
          },
1496
          "execution_count": 22,
1497
          "metadata": {},
1498
          "output_type": "execute_result"
1499
        }
1500
      ],
1501
      "source": [
1502
        "# display the poster of the movie\n",
1503
        "display_posters(movie[\"poster\"])"
1504
      ]
1505
    },
1506
    {
1507
      "cell_type": "markdown",
1508
      "metadata": {
1509
        "id": "jimg28XzDyeq"
1510
      },
1511
      "source": [
1512
        "Now we have *Avengers: Infinity War*. Let's find movies that are similar to this movie."
1513
      ]
1514
    },
1515
    {
1516
      "cell_type": "code",
1517
      "execution_count": 23,
1518
      "metadata": {
1519
        "colab": {
1520
          "base_uri": "https://localhost:8080/",
1521
          "height": 345
1522
        },
1523
        "id": "Ugd76hSItZNT",
1524
        "outputId": "4e08f3e0-ec47-463f-d1e0-44226927346b"
1525
      },
1526
      "outputs": [
1527
        {
1528
          "data": {
1529
            "text/html": [
1530
              "\n",
1531
              "        <div style=\"display: flex; flex-flow: row wrap; text-align: center;\">\n",
1532
              "        \n",
1533
              "            <figure style=\"margin: 5px !important;\">\n",
1534
              "              <img src=\"https://m.media-amazon.com/images/M/MV5BMjMxNjY2MDU1OV5BMl5BanBnXkFtZTgwNzY1MTUwNTM@._V1_SX300.jpg\" style=\"width: 120px; height: 150px\" >\n",
1535
              "            </figure>\n",
1536
              "        \n",
1537
              "            <figure style=\"margin: 5px !important;\">\n",
1538
              "              <img src=\"https://m.media-amazon.com/images/M/MV5BMTc5MDE2ODcwNV5BMl5BanBnXkFtZTgwMzI2NzQ2NzM@._V1_SX300.jpg\" style=\"width: 120px; height: 150px\" >\n",
1539
              "            </figure>\n",
1540
              "        \n",
1541
              "            <figure style=\"margin: 5px !important;\">\n",
1542
              "              <img src=\"https://m.media-amazon.com/images/M/MV5BMjMyNDkzMzI1OF5BMl5BanBnXkFtZTgwODcxODg5MjI@._V1_SX300.jpg\" style=\"width: 120px; height: 150px\" >\n",
1543
              "            </figure>\n",
1544
              "        \n",
1545
              "            <figure style=\"margin: 5px !important;\">\n",
1546
              "              <img src=\"https://m.media-amazon.com/images/M/MV5BMjQ0MTgyNjAxMV5BMl5BanBnXkFtZTgwNjUzMDkyODE@._V1_SX300.jpg\" style=\"width: 120px; height: 150px\" >\n",
1547
              "            </figure>\n",
1548
              "        \n",
1549
              "            <figure style=\"margin: 5px !important;\">\n",
1550
              "              <img src=\"https://m.media-amazon.com/images/M/MV5BMTAwMjU5OTgxNjZeQTJeQWpwZ15BbWU4MDUxNDYxODEx._V1_SX300.jpg\" style=\"width: 120px; height: 150px\" >\n",
1551
              "            </figure>\n",
1552
              "        \n",
1553
              "            <figure style=\"margin: 5px !important;\">\n",
1554
              "              <img src=\"https://m.media-amazon.com/images/M/MV5BNjM0NTc0NzItM2FlYS00YzEwLWE0YmUtNTA2ZWIzODc2OTgxXkEyXkFqcGdeQXVyNTgwNzIyNzg@._V1_SX300.jpg\" style=\"width: 120px; height: 150px\" >\n",
1555
              "            </figure>\n",
1556
              "        \n",
1557
              "            <figure style=\"margin: 5px !important;\">\n",
1558
              "              <img src=\"https://m.media-amazon.com/images/M/MV5BMTM4OGJmNWMtOTM4Ni00NTE3LTg3MDItZmQxYjc4N2JhNmUxXkEyXkFqcGdeQXVyNTgzMDMzMTg@._V1_SX300.jpg\" style=\"width: 120px; height: 150px\" >\n",
1559
              "            </figure>\n",
1560
              "        \n",
1561
              "            <figure style=\"margin: 5px !important;\">\n",
1562
              "              <img src=\"https://m.media-amazon.com/images/M/MV5BNTk4ODQ1MzgzNl5BMl5BanBnXkFtZTgwMTMyMzM4MTI@._V1_SX300.jpg\" style=\"width: 120px; height: 150px\" >\n",
1563
              "            </figure>\n",
1564
              "        \n",
1565
              "            <figure style=\"margin: 5px !important;\">\n",
1566
              "              <img src=\"https://m.media-amazon.com/images/M/MV5BYzc5MTU4N2EtYTkyMi00NjdhLTg3NWEtMTY4OTEyMzJhZTAzXkEyXkFqcGdeQXVyNjc1NTYyMjg@._V1_SX300.jpg\" style=\"width: 120px; height: 150px\" >\n",
1567
              "            </figure>\n",
1568
              "        \n",
1569
              "            <figure style=\"margin: 5px !important;\">\n",
1570
              "              <img src=\"https://m.media-amazon.com/images/M/MV5BYzFhMGM5ZTMtOGEyMC00ZTY5LWE1ZDUtNjQzM2NjZDdiMjg3XkEyXkFqcGdeQXVyNzIzMzE0NDY@._V1_SX300.jpg\" style=\"width: 120px; height: 150px\" >\n",
1571
              "            </figure>\n",
1572
              "        \n",
1573
              "            <figure style=\"margin: 5px !important;\">\n",
1574
              "              <img src=\"https://m.media-amazon.com/images/M/MV5BNmUyMzU3YjgtZTliNS00NWM2LWI5ODgtYWE3ZjAzODgyNjNhXkEyXkFqcGdeQXVyNjY1MTg4Mzc@._V1_SX300.jpg\" style=\"width: 120px; height: 150px\" >\n",
1575
              "            </figure>\n",
1576
              "        \n",
1577
              "            <figure style=\"margin: 5px !important;\">\n",
1578
              "              <img src=\"https://m.media-amazon.com/images/M/MV5BMjMwNDkxMTgzOF5BMl5BanBnXkFtZTgwNTkwNTQ3NjM@._V1_SX300.jpg\" style=\"width: 120px; height: 150px\" >\n",
1579
              "            </figure>\n",
1580
              "        \n",
1581
              "            <figure style=\"margin: 5px !important;\">\n",
1582
              "              <img src=\"https://m.media-amazon.com/images/M/MV5BMDkzNmRhNTMtZDI4NC00Zjg1LTgxM2QtMjYxZDQ3OWJlMDRlXkEyXkFqcGdeQXVyNTU5MjkzMTU@._V1_SX300.jpg\" style=\"width: 120px; height: 150px\" >\n",
1583
              "            </figure>\n",
1584
              "        \n",
1585
              "            <figure style=\"margin: 5px !important;\">\n",
1586
              "              <img src=\"https://m.media-amazon.com/images/M/MV5BMTc2MTQ3MDA1Nl5BMl5BanBnXkFtZTgwODA3OTI4NjE@._V1_SX300.jpg\" style=\"width: 120px; height: 150px\" >\n",
1587
              "            </figure>\n",
1588
              "        \n",
1589
              "        </div>\n",
1590
              "    "
1591
            ],
1592
            "text/plain": [
1593
              "<IPython.core.display.HTML object>"
1594
            ]
1595
          },
1596
          "execution_count": 23,
1597
          "metadata": {},
1598
          "output_type": "execute_result"
1599
        }
1600
      ],
1601
      "source": [
1602
        "similar_movies = get_similar_movies(imdb_id)\n",
1603
        "display_posters(similar_movies)"
1604
      ]
1605
    },
1606
    {
1607
      "cell_type": "markdown",
1608
      "metadata": {
1609
        "id": "UIi4jdurDyer"
1610
      },
1611
      "source": [
1612
        "The top results closely match *Avengers: Infinity War*, the top most similar movie being the movie itself. Following this we see a lot of other Marvel superhero films.\n",
1613
        "\n",
1614
        "\n",
1615
        "Let's see another movie. This time a cartoon."
1616
      ]
1617
    },
1618
    {
1619
      "cell_type": "code",
1620
      "execution_count": 24,
1621
      "metadata": {
1622
        "colab": {
1623
          "base_uri": "https://localhost:8080/",
1624
          "height": 81
1625
        },
1626
        "id": "LnDTo02Ht8ZO",
1627
        "outputId": "88852461-526c-47f9-8caf-894bfe0ffc3a"
1628
      },
1629
      "outputs": [
1630
        {
1631
          "data": {
1632
            "text/html": [
1633
              "\n",
1634
              "  <div id=\"df-8d5ad3ee-589c-4ab9-8835-80dd6049362e\">\n",
1635
              "    <div class=\"colab-df-container\">\n",
1636
              "      <div>\n",
1637
              "<style scoped>\n",
1638
              "    .dataframe tbody tr th:only-of-type {\n",
1639
              "        vertical-align: middle;\n",
1640
              "    }\n",
1641
              "\n",
1642
              "    .dataframe tbody tr th {\n",
1643
              "        vertical-align: top;\n",
1644
              "    }\n",
1645
              "\n",
1646
              "    .dataframe thead th {\n",
1647
              "        text-align: right;\n",
1648
              "    }\n",
1649
              "</style>\n",
1650
              "<table border=\"1\" class=\"dataframe\">\n",
1651
              "  <thead>\n",
1652
              "    <tr style=\"text-align: right;\">\n",
1653
              "      <th></th>\n",
1654
              "      <th>imdb_id</th>\n",
1655
              "      <th>movie_id</th>\n",
1656
              "      <th>user_id</th>\n",
1657
              "      <th>rating</th>\n",
1658
              "      <th>title</th>\n",
1659
              "      <th>poster</th>\n",
1660
              "    </tr>\n",
1661
              "  </thead>\n",
1662
              "  <tbody>\n",
1663
              "    <tr>\n",
1664
              "      <th>97</th>\n",
1665
              "      <td>tt3521164</td>\n",
1666
              "      <td>5138</td>\n",
1667
              "      <td>24875</td>\n",
1668
              "      <td>5.0</td>\n",
1669
              "      <td>Moana (2016)</td>\n",
1670
              "      <td>https://m.media-amazon.com/images/M/MV5BMjI4Mz...</td>\n",
1671
              "    </tr>\n",
1672
              "  </tbody>\n",
1673
              "</table>\n",
1674
              "</div>\n",
1675
              "      <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-8d5ad3ee-589c-4ab9-8835-80dd6049362e')\"\n",
1676
              "              title=\"Convert this dataframe to an interactive table.\"\n",
1677
              "              style=\"display:none;\">\n",
1678
              "        \n",
1679
              "  <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\"viewBox=\"0 0 24 24\"\n",
1680
              "       width=\"24px\">\n",
1681
              "    <path d=\"M0 0h24v24H0V0z\" fill=\"none\"/>\n",
1682
              "    <path d=\"M18.56 5.44l.94 2.06.94-2.06 2.06-.94-2.06-.94-.94-2.06-.94 2.06-2.06.94zm-11 1L8.5 8.5l.94-2.06 2.06-.94-2.06-.94L8.5 2.5l-.94 2.06-2.06.94zm10 10l.94 2.06.94-2.06 2.06-.94-2.06-.94-.94-2.06-.94 2.06-2.06.94z\"/><path d=\"M17.41 7.96l-1.37-1.37c-.4-.4-.92-.59-1.43-.59-.52 0-1.04.2-1.43.59L10.3 9.45l-7.72 7.72c-.78.78-.78 2.05 0 2.83L4 21.41c.39.39.9.59 1.41.59.51 0 1.02-.2 1.41-.59l7.78-7.78 2.81-2.81c.8-.78.8-2.07 0-2.86zM5.41 20L4 18.59l7.72-7.72 1.47 1.35L5.41 20z\"/>\n",
1683
              "  </svg>\n",
1684
              "      </button>\n",
1685
              "      \n",
1686
              "  <style>\n",
1687
              "    .colab-df-container {\n",
1688
              "      display:flex;\n",
1689
              "      flex-wrap:wrap;\n",
1690
              "      gap: 12px;\n",
1691
              "    }\n",
1692
              "\n",
1693
              "    .colab-df-convert {\n",
1694
              "      background-color: #E8F0FE;\n",
1695
              "      border: none;\n",
1696
              "      border-radius: 50%;\n",
1697
              "      cursor: pointer;\n",
1698
              "      display: none;\n",
1699
              "      fill: #1967D2;\n",
1700
              "      height: 32px;\n",
1701
              "      padding: 0 0 0 0;\n",
1702
              "      width: 32px;\n",
1703
              "    }\n",
1704
              "\n",
1705
              "    .colab-df-convert:hover {\n",
1706
              "      background-color: #E2EBFA;\n",
1707
              "      box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
1708
              "      fill: #174EA6;\n",
1709
              "    }\n",
1710
              "\n",
1711
              "    [theme=dark] .colab-df-convert {\n",
1712
              "      background-color: #3B4455;\n",
1713
              "      fill: #D2E3FC;\n",
1714
              "    }\n",
1715
              "\n",
1716
              "    [theme=dark] .colab-df-convert:hover {\n",
1717
              "      background-color: #434B5C;\n",
1718
              "      box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n",
1719
              "      filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n",
1720
              "      fill: #FFFFFF;\n",
1721
              "    }\n",
1722
              "  </style>\n",
1723
              "\n",
1724
              "      <script>\n",
1725
              "        const buttonEl =\n",
1726
              "          document.querySelector('#df-8d5ad3ee-589c-4ab9-8835-80dd6049362e button.colab-df-convert');\n",
1727
              "        buttonEl.style.display =\n",
1728
              "          google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
1729
              "\n",
1730
              "        async function convertToInteractive(key) {\n",
1731
              "          const element = document.querySelector('#df-8d5ad3ee-589c-4ab9-8835-80dd6049362e');\n",
1732
              "          const dataTable =\n",
1733
              "            await google.colab.kernel.invokeFunction('convertToInteractive',\n",
1734
              "                                                     [key], {});\n",
1735
              "          if (!dataTable) return;\n",
1736
              "\n",
1737
              "          const docLinkHtml = 'Like what you see? Visit the ' +\n",
1738
              "            '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n",
1739
              "            + ' to learn more about interactive tables.';\n",
1740
              "          element.innerHTML = '';\n",
1741
              "          dataTable['output_type'] = 'display_data';\n",
1742
              "          await google.colab.output.renderOutput(dataTable, element);\n",
1743
              "          const docLink = document.createElement('div');\n",
1744
              "          docLink.innerHTML = docLinkHtml;\n",
1745
              "          element.appendChild(docLink);\n",
1746
              "        }\n",
1747
              "      </script>\n",
1748
              "    </div>\n",
1749
              "  </div>\n",
1750
              "  "
1751
            ],
1752
            "text/plain": [
1753
              "      imdb_id  movie_id  user_id  rating         title  \\\n",
1754
              "97  tt3521164      5138    24875     5.0  Moana (2016)   \n",
1755
              "\n",
1756
              "                                               poster  \n",
1757
              "97  https://m.media-amazon.com/images/M/MV5BMjI4Mz...  "
1758
            ]
1759
          },
1760
          "execution_count": 24,
1761
          "metadata": {},
1762
          "output_type": "execute_result"
1763
        }
1764
      ],
1765
      "source": [
1766
        "# imdbid of Moana\n",
1767
        "imdb_id = \"tt3521164\"\n",
1768
        "# filter the imdbid from the unique_movies\n",
1769
        "movie = unique_movies[unique_movies[\"imdb_id\"] == imdb_id]\n",
1770
        "movie"
1771
      ]
1772
    },
1773
    {
1774
      "cell_type": "code",
1775
      "execution_count": 25,
1776
      "metadata": {
1777
        "colab": {
1778
          "base_uri": "https://localhost:8080/",
1779
          "height": 181
1780
        },
1781
        "id": "bpJUB1VF-02z",
1782
        "outputId": "0d7a0e6c-3c4b-410c-a1bb-a5024c012936"
1783
      },
1784
      "outputs": [
1785
        {
1786
          "data": {
1787
            "text/html": [
1788
              "\n",
1789
              "        <div style=\"display: flex; flex-flow: row wrap; text-align: center;\">\n",
1790
              "        \n",
1791
              "            <figure style=\"margin: 5px !important;\">\n",
1792
              "              <img src=\"https://m.media-amazon.com/images/M/MV5BMjI4MzU5NTExNF5BMl5BanBnXkFtZTgwNzY1MTEwMDI@._V1_SX300.jpg\" style=\"width: 120px; height: 150px\" >\n",
1793
              "            </figure>\n",
1794
              "        \n",
1795
              "        </div>\n",
1796
              "    "
1797
            ],
1798
            "text/plain": [
1799
              "<IPython.core.display.HTML object>"
1800
            ]
1801
          },
1802
          "execution_count": 25,
1803
          "metadata": {},
1804
          "output_type": "execute_result"
1805
        }
1806
      ],
1807
      "source": [
1808
        "# display the poster of the movie\n",
1809
        "display_posters(movie[\"poster\"])"
1810
      ]
1811
    },
1812
    {
1813
      "cell_type": "code",
1814
      "execution_count": 26,
1815
      "metadata": {
1816
        "colab": {
1817
          "base_uri": "https://localhost:8080/",
1818
          "height": 345
1819
        },
1820
        "id": "fxh7U8Fpwgkk",
1821
        "outputId": "fc7697c5-3246-4770-85e5-91f257775c06"
1822
      },
1823
      "outputs": [
1824
        {
1825
          "data": {
1826
            "text/html": [
1827
              "\n",
1828
              "        <div style=\"display: flex; flex-flow: row wrap; text-align: center;\">\n",
1829
              "        \n",
1830
              "            <figure style=\"margin: 5px !important;\">\n",
1831
              "              <img src=\"https://m.media-amazon.com/images/M/MV5BMjI4MzU5NTExNF5BMl5BanBnXkFtZTgwNzY1MTEwMDI@._V1_SX300.jpg\" style=\"width: 120px; height: 150px\" >\n",
1832
              "            </figure>\n",
1833
              "        \n",
1834
              "            <figure style=\"margin: 5px !important;\">\n",
1835
              "              <img src=\"https://m.media-amazon.com/images/M/MV5BMzJmNGFmYmMtMmZhOC00MGM2LTk5NWItYzMzZmM1MzgzMTgxXkEyXkFqcGdeQXVyNTM3MDMyMDQ@._V1_SX300.jpg\" style=\"width: 120px; height: 150px\" >\n",
1836
              "            </figure>\n",
1837
              "        \n",
1838
              "            <figure style=\"margin: 5px !important;\">\n",
1839
              "              <img src=\"https://m.media-amazon.com/images/M/MV5BMTM4ODg0MzM0MV5BMl5BanBnXkFtZTcwNDY2MTc3Nw@@._V1_SX300.jpg\" style=\"width: 120px; height: 150px\" >\n",
1840
              "            </figure>\n",
1841
              "        \n",
1842
              "            <figure style=\"margin: 5px !important;\">\n",
1843
              "              <img src=\"https://m.media-amazon.com/images/M/MV5BYjQ5NjM0Y2YtNjZkNC00ZDhkLWJjMWItN2QyNzFkMDE3ZjAxXkEyXkFqcGdeQXVyODIxMzk5NjA@._V1_SX300.jpg\" style=\"width: 120px; height: 150px\" >\n",
1844
              "            </figure>\n",
1845
              "        \n",
1846
              "            <figure style=\"margin: 5px !important;\">\n",
1847
              "              <img src=\"https://m.media-amazon.com/images/M/MV5BZGUxZGMzYTYtNjJlMS00OGQ5LTg5YjItN2JjM2Y2NjQzMzdkL2ltYWdlXkEyXkFqcGdeQXVyNTAyODkwOQ@@._V1_SX300.jpg\" style=\"width: 120px; height: 150px\" >\n",
1848
              "            </figure>\n",
1849
              "        \n",
1850
              "            <figure style=\"margin: 5px !important;\">\n",
1851
              "              <img src=\"https://m.media-amazon.com/images/M/MV5BNDMyZDc3YzktNWI3Yy00ZDM1LWJjYTMtY2I2YzRmZGQ5MTU4XkEyXkFqcGdeQXVyMTY5Nzc4MDY@._V1_SX300.jpg\" style=\"width: 120px; height: 150px\" >\n",
1852
              "            </figure>\n",
1853
              "        \n",
1854
              "            <figure style=\"margin: 5px !important;\">\n",
1855
              "              <img src=\"https://m.media-amazon.com/images/M/MV5BMjA2Mzg2NDMzNl5BMl5BanBnXkFtZTgwMjcwODUzOTE@._V1_SX300.jpg\" style=\"width: 120px; height: 150px\" >\n",
1856
              "            </figure>\n",
1857
              "        \n",
1858
              "            <figure style=\"margin: 5px !important;\">\n",
1859
              "              <img src=\"https://m.media-amazon.com/images/M/MV5BMjAyODEwOTE4OV5BMl5BanBnXkFtZTgwNDIzMDc3ODE@._V1_SX300.jpg\" style=\"width: 120px; height: 150px\" >\n",
1860
              "            </figure>\n",
1861
              "        \n",
1862
              "            <figure style=\"margin: 5px !important;\">\n",
1863
              "              <img src=\"https://m.media-amazon.com/images/M/MV5BNDk3MzYyMjU5NF5BMl5BanBnXkFtZTgwNzQ5MDkzMzE@._V1_SX300.jpg\" style=\"width: 120px; height: 150px\" >\n",
1864
              "            </figure>\n",
1865
              "        \n",
1866
              "            <figure style=\"margin: 5px !important;\">\n",
1867
              "              <img src=\"https://m.media-amazon.com/images/M/MV5BZDUyNzhjMTAtNGI5OC00MjYzLWFlNDUtMTQzYTdhZjliMDk0XkEyXkFqcGdeQXVyNTc5OTMwOTQ@._V1_SX300.jpg\" style=\"width: 120px; height: 150px\" >\n",
1868
              "            </figure>\n",
1869
              "        \n",
1870
              "            <figure style=\"margin: 5px !important;\">\n",
1871
              "              <img src=\"https://m.media-amazon.com/images/M/MV5BOGY5ZDA4MDEtNWIzNi00YjkxLWE3Y2EtNmJiNzBhOWEyMWVjXkEyXkFqcGdeQXVyNTE1NjY5Mg@@._V1_SX300.jpg\" style=\"width: 120px; height: 150px\" >\n",
1872
              "            </figure>\n",
1873
              "        \n",
1874
              "            <figure style=\"margin: 5px !important;\">\n",
1875
              "              <img src=\"https://m.media-amazon.com/images/M/MV5BYzMzZWM0NjYtMmNjMi00MzUzLThlNTAtZWQ1NjQzM2QyNzIwXkEyXkFqcGdeQXVyNDQ5MDYzMTk@._V1_SX300.jpg\" style=\"width: 120px; height: 150px\" >\n",
1876
              "            </figure>\n",
1877
              "        \n",
1878
              "            <figure style=\"margin: 5px !important;\">\n",
1879
              "              <img src=\"https://m.media-amazon.com/images/M/MV5BMzg2Mzg4YmUtNDdkNy00NWY1LWE3NmEtZWMwNGNlMzE5YzU3XkEyXkFqcGdeQXVyMjA5MTIzMjQ@._V1_SX300.jpg\" style=\"width: 120px; height: 150px\" >\n",
1880
              "            </figure>\n",
1881
              "        \n",
1882
              "            <figure style=\"margin: 5px !important;\">\n",
1883
              "              <img src=\"https://m.media-amazon.com/images/M/MV5BNDc3YTEzZDItNjE2Yy00Nzg2LTgxMDAtNWMxOTJiMWQxZmNiXkEyXkFqcGdeQXVyMjExNjgyMTc@._V1_SX300.jpg\" style=\"width: 120px; height: 150px\" >\n",
1884
              "            </figure>\n",
1885
              "        \n",
1886
              "        </div>\n",
1887
              "    "
1888
            ],
1889
            "text/plain": [
1890
              "<IPython.core.display.HTML object>"
1891
            ]
1892
          },
1893
          "execution_count": 26,
1894
          "metadata": {},
1895
          "output_type": "execute_result"
1896
        }
1897
      ],
1898
      "source": [
1899
        "similar_movies = get_similar_movies(imdb_id)\n",
1900
        "display_posters(similar_movies)"
1901
      ]
1902
    },
1903
    {
1904
      "cell_type": "markdown",
1905
      "metadata": {
1906
        "id": "9g_FxVwwDyer"
1907
      },
1908
      "source": [
1909
        "This result quality is good again. The top results returning plenty of cartoons."
1910
      ]
1911
    }
1912
  ],
1913
  "metadata": {
1914
    "colab": {
1915
      "collapsed_sections": [],
1916
      "name": "00_movie_recommender.ipynb",
1917
      "provenance": []
1918
    },
1919
    "gpuClass": "standard",
1920
    "kernelspec": {
1921
      "display_name": "Python 3",
1922
      "language": "python",
1923
      "name": "python3"
1924
    },
1925
    "language_info": {
1926
      "codemirror_mode": {
1927
        "name": "ipython",
1928
        "version": 3
1929
      },
1930
      "file_extension": ".py",
1931
      "mimetype": "text/x-python",
1932
      "name": "python",
1933
      "nbconvert_exporter": "python",
1934
      "pygments_lexer": "ipython3",
1935
      "version": "3.9.12"
1936
    },
1937
    "vscode": {
1938
      "interpreter": {
1939
        "hash": "b8e7999f96e1b425e2d542f21b571f5a4be3e97158b0b46ea1b2500df63956ce"
1940
      }
1941
    },
1942
    "widgets": {
1943
      "application/vnd.jupyter.widget-state+json": {
1944
        "15e64e605cff4e87b90d95dd7dd68b3c": {
1945
          "model_module": "@jupyter-widgets/controls",
1946
          "model_module_version": "1.5.0",
1947
          "model_name": "FloatProgressModel",
1948
          "state": {
1949
            "_dom_classes": [],
1950
            "_model_module": "@jupyter-widgets/controls",
1951
            "_model_module_version": "1.5.0",
1952
            "_model_name": "FloatProgressModel",
1953
            "_view_count": null,
1954
            "_view_module": "@jupyter-widgets/controls",
1955
            "_view_module_version": "1.5.0",
1956
            "_view_name": "ProgressView",
1957
            "bar_style": "success",
1958
            "description": "",
1959
            "description_tooltip": null,
1960
            "layout": "IPY_MODEL_e63c019f736a4b45801060fe141c6b3a",
1961
            "max": 161,
1962
            "min": 0,
1963
            "orientation": "horizontal",
1964
            "style": "IPY_MODEL_fd05a1870afc4b01b1ca8176908cc80b",
1965
            "value": 161
1966
          }
1967
        },
1968
        "3a3474a650984ac0a87334f2e7614adb": {
1969
          "model_module": "@jupyter-widgets/base",
1970
          "model_module_version": "1.2.0",
1971
          "model_name": "LayoutModel",
1972
          "state": {
1973
            "_model_module": "@jupyter-widgets/base",
1974
            "_model_module_version": "1.2.0",
1975
            "_model_name": "LayoutModel",
1976
            "_view_count": null,
1977
            "_view_module": "@jupyter-widgets/base",
1978
            "_view_module_version": "1.2.0",
1979
            "_view_name": "LayoutView",
1980
            "align_content": null,
1981
            "align_items": null,
1982
            "align_self": null,
1983
            "border": null,
1984
            "bottom": null,
1985
            "display": null,
1986
            "flex": null,
1987
            "flex_flow": null,
1988
            "grid_area": null,
1989
            "grid_auto_columns": null,
1990
            "grid_auto_flow": null,
1991
            "grid_auto_rows": null,
1992
            "grid_column": null,
1993
            "grid_gap": null,
1994
            "grid_row": null,
1995
            "grid_template_areas": null,
1996
            "grid_template_columns": null,
1997
            "grid_template_rows": null,
1998
            "height": null,
1999
            "justify_content": null,
2000
            "justify_items": null,
2001
            "left": null,
2002
            "margin": null,
2003
            "max_height": null,
2004
            "max_width": null,
2005
            "min_height": null,
2006
            "min_width": null,
2007
            "object_fit": null,
2008
            "object_position": null,
2009
            "order": null,
2010
            "overflow": null,
2011
            "overflow_x": null,
2012
            "overflow_y": null,
2013
            "padding": null,
2014
            "right": null,
2015
            "top": null,
2016
            "visibility": null,
2017
            "width": null
2018
          }
2019
        },
2020
        "519aa0cccee14aa49498e072aac368ac": {
2021
          "model_module": "@jupyter-widgets/controls",
2022
          "model_module_version": "1.5.0",
2023
          "model_name": "DescriptionStyleModel",
2024
          "state": {
2025
            "_model_module": "@jupyter-widgets/controls",
2026
            "_model_module_version": "1.5.0",
2027
            "_model_name": "DescriptionStyleModel",
2028
            "_view_count": null,
2029
            "_view_module": "@jupyter-widgets/base",
2030
            "_view_module_version": "1.2.0",
2031
            "_view_name": "StyleView",
2032
            "description_width": ""
2033
          }
2034
        },
2035
        "5d6e71aed5644c3781c3c63c306c549e": {
2036
          "model_module": "@jupyter-widgets/base",
2037
          "model_module_version": "1.2.0",
2038
          "model_name": "LayoutModel",
2039
          "state": {
2040
            "_model_module": "@jupyter-widgets/base",
2041
            "_model_module_version": "1.2.0",
2042
            "_model_name": "LayoutModel",
2043
            "_view_count": null,
2044
            "_view_module": "@jupyter-widgets/base",
2045
            "_view_module_version": "1.2.0",
2046
            "_view_name": "LayoutView",
2047
            "align_content": null,
2048
            "align_items": null,
2049
            "align_self": null,
2050
            "border": null,
2051
            "bottom": null,
2052
            "display": null,
2053
            "flex": null,
2054
            "flex_flow": null,
2055
            "grid_area": null,
2056
            "grid_auto_columns": null,
2057
            "grid_auto_flow": null,
2058
            "grid_auto_rows": null,
2059
            "grid_column": null,
2060
            "grid_gap": null,
2061
            "grid_row": null,
2062
            "grid_template_areas": null,
2063
            "grid_template_columns": null,
2064
            "grid_template_rows": null,
2065
            "height": null,
2066
            "justify_content": null,
2067
            "justify_items": null,
2068
            "left": null,
2069
            "margin": null,
2070
            "max_height": null,
2071
            "max_width": null,
2072
            "min_height": null,
2073
            "min_width": null,
2074
            "object_fit": null,
2075
            "object_position": null,
2076
            "order": null,
2077
            "overflow": null,
2078
            "overflow_x": null,
2079
            "overflow_y": null,
2080
            "padding": null,
2081
            "right": null,
2082
            "top": null,
2083
            "visibility": null,
2084
            "width": null
2085
          }
2086
        },
2087
        "6ebae25f1b544f86839aa30e039b1c4c": {
2088
          "model_module": "@jupyter-widgets/controls",
2089
          "model_module_version": "1.5.0",
2090
          "model_name": "DescriptionStyleModel",
2091
          "state": {
2092
            "_model_module": "@jupyter-widgets/controls",
2093
            "_model_module_version": "1.5.0",
2094
            "_model_name": "DescriptionStyleModel",
2095
            "_view_count": null,
2096
            "_view_module": "@jupyter-widgets/base",
2097
            "_view_module_version": "1.2.0",
2098
            "_view_name": "StyleView",
2099
            "description_width": ""
2100
          }
2101
        },
2102
        "803e5ce5e1474d2cbd5cb5cb32597476": {
2103
          "model_module": "@jupyter-widgets/controls",
2104
          "model_module_version": "1.5.0",
2105
          "model_name": "HBoxModel",
2106
          "state": {
2107
            "_dom_classes": [],
2108
            "_model_module": "@jupyter-widgets/controls",
2109
            "_model_module_version": "1.5.0",
2110
            "_model_name": "HBoxModel",
2111
            "_view_count": null,
2112
            "_view_module": "@jupyter-widgets/controls",
2113
            "_view_module_version": "1.5.0",
2114
            "_view_name": "HBoxView",
2115
            "box_style": "",
2116
            "children": [
2117
              "IPY_MODEL_9cf021d7e1ce41fa8d3e669fd036dacc",
2118
              "IPY_MODEL_15e64e605cff4e87b90d95dd7dd68b3c",
2119
              "IPY_MODEL_becf8f08940241a8afef20544f813180"
2120
            ],
2121
            "layout": "IPY_MODEL_3a3474a650984ac0a87334f2e7614adb"
2122
          }
2123
        },
2124
        "85c28595f31d45abae924197010930d4": {
2125
          "model_module": "@jupyter-widgets/base",
2126
          "model_module_version": "1.2.0",
2127
          "model_name": "LayoutModel",
2128
          "state": {
2129
            "_model_module": "@jupyter-widgets/base",
2130
            "_model_module_version": "1.2.0",
2131
            "_model_name": "LayoutModel",
2132
            "_view_count": null,
2133
            "_view_module": "@jupyter-widgets/base",
2134
            "_view_module_version": "1.2.0",
2135
            "_view_name": "LayoutView",
2136
            "align_content": null,
2137
            "align_items": null,
2138
            "align_self": null,
2139
            "border": null,
2140
            "bottom": null,
2141
            "display": null,
2142
            "flex": null,
2143
            "flex_flow": null,
2144
            "grid_area": null,
2145
            "grid_auto_columns": null,
2146
            "grid_auto_flow": null,
2147
            "grid_auto_rows": null,
2148
            "grid_column": null,
2149
            "grid_gap": null,
2150
            "grid_row": null,
2151
            "grid_template_areas": null,
2152
            "grid_template_columns": null,
2153
            "grid_template_rows": null,
2154
            "height": null,
2155
            "justify_content": null,
2156
            "justify_items": null,
2157
            "left": null,
2158
            "margin": null,
2159
            "max_height": null,
2160
            "max_width": null,
2161
            "min_height": null,
2162
            "min_width": null,
2163
            "object_fit": null,
2164
            "object_position": null,
2165
            "order": null,
2166
            "overflow": null,
2167
            "overflow_x": null,
2168
            "overflow_y": null,
2169
            "padding": null,
2170
            "right": null,
2171
            "top": null,
2172
            "visibility": null,
2173
            "width": null
2174
          }
2175
        },
2176
        "9cf021d7e1ce41fa8d3e669fd036dacc": {
2177
          "model_module": "@jupyter-widgets/controls",
2178
          "model_module_version": "1.5.0",
2179
          "model_name": "HTMLModel",
2180
          "state": {
2181
            "_dom_classes": [],
2182
            "_model_module": "@jupyter-widgets/controls",
2183
            "_model_module_version": "1.5.0",
2184
            "_model_name": "HTMLModel",
2185
            "_view_count": null,
2186
            "_view_module": "@jupyter-widgets/controls",
2187
            "_view_module_version": "1.5.0",
2188
            "_view_name": "HTMLView",
2189
            "description": "",
2190
            "description_tooltip": null,
2191
            "layout": "IPY_MODEL_5d6e71aed5644c3781c3c63c306c549e",
2192
            "placeholder": "​",
2193
            "style": "IPY_MODEL_6ebae25f1b544f86839aa30e039b1c4c",
2194
            "value": "100%"
2195
          }
2196
        },
2197
        "becf8f08940241a8afef20544f813180": {
2198
          "model_module": "@jupyter-widgets/controls",
2199
          "model_module_version": "1.5.0",
2200
          "model_name": "HTMLModel",
2201
          "state": {
2202
            "_dom_classes": [],
2203
            "_model_module": "@jupyter-widgets/controls",
2204
            "_model_module_version": "1.5.0",
2205
            "_model_name": "HTMLModel",
2206
            "_view_count": null,
2207
            "_view_module": "@jupyter-widgets/controls",
2208
            "_view_module_version": "1.5.0",
2209
            "_view_name": "HTMLView",
2210
            "description": "",
2211
            "description_tooltip": null,
2212
            "layout": "IPY_MODEL_85c28595f31d45abae924197010930d4",
2213
            "placeholder": "​",
2214
            "style": "IPY_MODEL_519aa0cccee14aa49498e072aac368ac",
2215
            "value": " 161/161 [00:37&lt;00:00,  4.36it/s]"
2216
          }
2217
        },
2218
        "e63c019f736a4b45801060fe141c6b3a": {
2219
          "model_module": "@jupyter-widgets/base",
2220
          "model_module_version": "1.2.0",
2221
          "model_name": "LayoutModel",
2222
          "state": {
2223
            "_model_module": "@jupyter-widgets/base",
2224
            "_model_module_version": "1.2.0",
2225
            "_model_name": "LayoutModel",
2226
            "_view_count": null,
2227
            "_view_module": "@jupyter-widgets/base",
2228
            "_view_module_version": "1.2.0",
2229
            "_view_name": "LayoutView",
2230
            "align_content": null,
2231
            "align_items": null,
2232
            "align_self": null,
2233
            "border": null,
2234
            "bottom": null,
2235
            "display": null,
2236
            "flex": null,
2237
            "flex_flow": null,
2238
            "grid_area": null,
2239
            "grid_auto_columns": null,
2240
            "grid_auto_flow": null,
2241
            "grid_auto_rows": null,
2242
            "grid_column": null,
2243
            "grid_gap": null,
2244
            "grid_row": null,
2245
            "grid_template_areas": null,
2246
            "grid_template_columns": null,
2247
            "grid_template_rows": null,
2248
            "height": null,
2249
            "justify_content": null,
2250
            "justify_items": null,
2251
            "left": null,
2252
            "margin": null,
2253
            "max_height": null,
2254
            "max_width": null,
2255
            "min_height": null,
2256
            "min_width": null,
2257
            "object_fit": null,
2258
            "object_position": null,
2259
            "order": null,
2260
            "overflow": null,
2261
            "overflow_x": null,
2262
            "overflow_y": null,
2263
            "padding": null,
2264
            "right": null,
2265
            "top": null,
2266
            "visibility": null,
2267
            "width": null
2268
          }
2269
        },
2270
        "fd05a1870afc4b01b1ca8176908cc80b": {
2271
          "model_module": "@jupyter-widgets/controls",
2272
          "model_module_version": "1.5.0",
2273
          "model_name": "ProgressStyleModel",
2274
          "state": {
2275
            "_model_module": "@jupyter-widgets/controls",
2276
            "_model_module_version": "1.5.0",
2277
            "_model_name": "ProgressStyleModel",
2278
            "_view_count": null,
2279
            "_view_module": "@jupyter-widgets/base",
2280
            "_view_module_version": "1.2.0",
2281
            "_view_name": "StyleView",
2282
            "bar_color": null,
2283
            "description_width": ""
2284
          }
2285
        }
2286
      }
2287
    }
2288
  },
2289
  "nbformat": 4,
2290
  "nbformat_minor": 0
2291
}
2292

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.