{ "nbformat": 4, "nbformat_minor": 0, "metadata": { "colab": { "name": "Building Recommender System with Surprise.ipynb", "provenance": [], "collapsed_sections": [ "ljexN0Hgsxj7", "K-yPIqzzt5et", "i5w94WTCzZe9", "FSAYBpkL1S-I", "SevuwLNb1UgS", "217_IWgm2OJk", "GOIdBWCl3VNt" ] }, "kernelspec": { "name": "python3", "display_name": "Python 3" }, "accelerator": "TPU" }, "cells": [ { "cell_type": "markdown", "metadata": { "id": "axAJMOjQsvDi" }, "source": [ "# Recommendation System\n", "\n", "Building recommendation system to scale using scikit-surprise (surprise library)\n", "\n", "[Recommender systems](https://en.wikipedia.org/wiki/Recommender_system) are one of the most common used and easily understandable applications of data science. Lots of work has been done on this topic, the interest and demand in this area remains very high because of the rapid growth of the internet and the information overload problem. It has become necessary for online businesses to help users to deal with information overload and provide personalized recommendations, content and services to them.\n", "\n", "Two of the most popular ways to approach recommender systems are [collaborative filtering](https://en.wikipedia.org/wiki/Collaborative_filtering) and [content-based recommendations](https://www.analyticsvidhya.com/blog/2015/08/beginners-guide-learn-content-based-recommender-systems/). In this post, we will focus on the **collaborative filtering** approach, that is: the user is recommended items that people with similar tastes and preferences liked in the past. In another word, this method predicts unknown ratings by using the similarities between users." ] }, { "cell_type": "markdown", "metadata": { "id": "ljexN0Hgsxj7" }, "source": [ "## Installing required libraries" ] }, { "cell_type": "code", "metadata": { "id": "JvJySjbosixd", "outputId": "fa6615a2-d754-4d18-98f4-df693f897e29", "colab": { "base_uri": "https://localhost:8080/", "height": 272 } }, "source": [ "!pip3 install numpy\n", "!pip3 install scikit-surprise" ], "execution_count": null, "outputs": [ { "output_type": "stream", "text": [ "Requirement already satisfied: numpy in /usr/local/lib/python3.6/dist-packages (1.18.3)\n", "Collecting scikit-surprise\n", "\u001b[?25l Downloading https://files.pythonhosted.org/packages/f5/da/b5700d96495fb4f092be497f02492768a3d96a3f4fa2ae7dea46d4081cfa/scikit-surprise-1.1.0.tar.gz (6.4MB)\n", "\u001b[K |████████████████████████████████| 6.5MB 3.2MB/s \n", "\u001b[?25hRequirement already satisfied: joblib>=0.11 in /usr/local/lib/python3.6/dist-packages (from scikit-surprise) (0.14.1)\n", "Requirement already satisfied: numpy>=1.11.2 in /usr/local/lib/python3.6/dist-packages (from scikit-surprise) (1.18.3)\n", "Requirement already satisfied: scipy>=1.0.0 in /usr/local/lib/python3.6/dist-packages (from scikit-surprise) (1.4.1)\n", "Requirement already satisfied: six>=1.10.0 in /usr/local/lib/python3.6/dist-packages (from scikit-surprise) (1.12.0)\n", "Building wheels for collected packages: scikit-surprise\n", " Building wheel for scikit-surprise (setup.py) ... \u001b[?25l\u001b[?25hdone\n", " Created wheel for scikit-surprise: filename=scikit_surprise-1.1.0-cp36-cp36m-linux_x86_64.whl size=1673673 sha256=ce5d7555545c8e7deba078f9b15d9edae474796c0a0fb5b91727218fd7da7e90\n", " Stored in directory: /root/.cache/pip/wheels/cc/fa/8c/16c93fccce688ae1bde7d979ff102f7bee980d9cfeb8641bcf\n", "Successfully built scikit-surprise\n", "Installing collected packages: scikit-surprise\n", "Successfully installed scikit-surprise-1.1.0\n" ], "name": "stdout" } ] }, { "cell_type": "markdown", "metadata": { "id": "K-yPIqzzt5et" }, "source": [ "## Importing required libraries" ] }, { "cell_type": "code", "metadata": { "id": "fnFQyJeIsRoW" }, "source": [ "import pandas as pd\n", "from surprise import Reader\n", "from surprise import Dataset\n", "from surprise.model_selection import cross_validate\n", "from surprise import NormalPredictor\n", "from surprise import KNNBasic\n", "from surprise import KNNWithMeans\n", "from surprise import KNNWithZScore\n", "from surprise import KNNBaseline\n", "from surprise import SVD\n", "from surprise import BaselineOnly\n", "from surprise import SVDpp\n", "from surprise import NMF\n", "from surprise import SlopeOne\n", "from surprise import CoClustering\n", "from surprise.accuracy import rmse\n", "from surprise import accuracy\n", "from surprise.model_selection import train_test_split\n", "from surprise.model_selection import GridSearchCV" ], "execution_count": null, "outputs": [] }, { "cell_type": "markdown", "metadata": { "id": "I5tdz4Wwx9vQ" }, "source": [ "## Importing data" ] }, { "cell_type": "markdown", "metadata": { "id": "sJJpFvepyCKx" }, "source": [ "GroupLens Research has collected and made available rating data sets from the MovieLens web site ([http://movielens.org](http://movielens.org/)). The data sets were collected over various periods of time, depending on the size of the set.\n", "\n", "We are using *Small*: 100,000 ratings and 3,600 tag applications applied to 9,000 movies by 600 users. Last updated 9/2018.\n", "\n", "Download: [ml-latest-small.zip](http://files.grouplens.org/datasets/movielens/ml-latest-small.zip) (size: 1 MB)" ] }, { "cell_type": "code", "metadata": { "id": "ofkkqibhsbMB" }, "source": [ "df = pd.read_csv (\"https://raw.githubusercontent.com/singhsidhukuldeep/Recommendation-System/master/data/ratings.csv\")" ], "execution_count": null, "outputs": [] }, { "cell_type": "code", "metadata": { "id": "G2lwZjoVx4VP", "outputId": "f032ac43-1e50-48b6-f9f6-ce331a4315f5", "colab": { "base_uri": "https://localhost:8080/", "height": 204 } }, "source": [ "df.head()" ], "execution_count": null, "outputs": [ { "output_type": "execute_result", "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
userIdmovieIdratingtimestamp
0114.0964982703
1134.0964981247
2164.0964982224
31475.0964983815
41505.0964982931
\n", "
" ], "text/plain": [ " userId movieId rating timestamp\n", "0 1 1 4.0 964982703\n", "1 1 3 4.0 964981247\n", "2 1 6 4.0 964982224\n", "3 1 47 5.0 964983815\n", "4 1 50 5.0 964982931" ] }, "metadata": { "tags": [] }, "execution_count": 4 } ] }, { "cell_type": "code", "metadata": { "id": "C470QI87x58S", "outputId": "21d4c370-956c-4645-d124-519d315f1254", "colab": { "base_uri": "https://localhost:8080/", "height": 204 } }, "source": [ "df.tail()" ], "execution_count": null, "outputs": [ { "output_type": "execute_result", "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
userIdmovieIdratingtimestamp
1008316101665344.01493848402
1008326101682485.01493850091
1008336101682505.01494273047
1008346101682525.01493846352
1008356101708753.01493846415
\n", "
" ], "text/plain": [ " userId movieId rating timestamp\n", "100831 610 166534 4.0 1493848402\n", "100832 610 168248 5.0 1493850091\n", "100833 610 168250 5.0 1494273047\n", "100834 610 168252 5.0 1493846352\n", "100835 610 170875 3.0 1493846415" ] }, "metadata": { "tags": [] }, "execution_count": 5 } ] }, { "cell_type": "code", "metadata": { "id": "nBjaHwBbyJKQ" }, "source": [ "df.drop(['timestamp'], axis=1, inplace=True)\n", "df.columns = ['userID', 'item', 'rating']" ], "execution_count": null, "outputs": [] }, { "cell_type": "code", "metadata": { "id": "iUF4O2AHy3Uf", "outputId": "88772eda-a589-4377-ffe2-124e37850e96", "colab": { "base_uri": "https://localhost:8080/", "height": 204 } }, "source": [ "df.head()" ], "execution_count": null, "outputs": [ { "output_type": "execute_result", "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
userIDitemrating
0114.0
1134.0
2164.0
31475.0
41505.0
\n", "
" ], "text/plain": [ " userID item rating\n", "0 1 1 4.0\n", "1 1 3 4.0\n", "2 1 6 4.0\n", "3 1 47 5.0\n", "4 1 50 5.0" ] }, "metadata": { "tags": [] }, "execution_count": 7 } ] }, { "cell_type": "code", "metadata": { "id": "Z_pC5wxXy5Km", "outputId": "4d2b2690-2cc0-4565-aa09-3ae319f9b2e5", "colab": { "base_uri": "https://localhost:8080/", "height": 34 } }, "source": [ "df.shape" ], "execution_count": null, "outputs": [ { "output_type": "execute_result", "data": { "text/plain": [ "(100836, 3)" ] }, "metadata": { "tags": [] }, "execution_count": 8 } ] }, { "cell_type": "code", "metadata": { "id": "hqLTBVX1y_sL", "outputId": "bd23c94b-bc91-4a34-b058-6ac9d6d7a6b7", "colab": { "base_uri": "https://localhost:8080/", "height": 187 } }, "source": [ "df.info()" ], "execution_count": null, "outputs": [ { "output_type": "stream", "text": [ "\n", "RangeIndex: 100836 entries, 0 to 100835\n", "Data columns (total 3 columns):\n", " # Column Non-Null Count Dtype \n", "--- ------ -------------- ----- \n", " 0 userID 100836 non-null int64 \n", " 1 item 100836 non-null int64 \n", " 2 rating 100836 non-null float64\n", "dtypes: float64(1), int64(2)\n", "memory usage: 2.3 MB\n" ], "name": "stdout" } ] }, { "cell_type": "code", "metadata": { "id": "FH4H6Fq-zCUv", "outputId": "6f86f061-110b-487e-cdac-ed6a3d21ab5c", "colab": { "base_uri": "https://localhost:8080/", "height": 170 } }, "source": [ "print('Dataset shape: {}'.format(df.shape))\n", "print('-Dataset examples-')\n", "print(df.iloc[::20000, :])" ], "execution_count": null, "outputs": [ { "output_type": "stream", "text": [ "Dataset shape: (100836, 3)\n", "-Dataset examples-\n", " userID item rating\n", "0 1 1 4.0\n", "20000 132 1079 3.5\n", "40000 274 5621 2.0\n", "60000 387 6748 3.0\n", "80000 501 11 3.0\n", "100000 610 6978 4.0\n" ], "name": "stdout" } ] }, { "cell_type": "markdown", "metadata": { "id": "i5w94WTCzZe9" }, "source": [ "## EDA" ] }, { "cell_type": "markdown", "metadata": { "id": "FSAYBpkL1S-I" }, "source": [ "### Ratings Distribution" ] }, { "cell_type": "code", "metadata": { "id": "vQCMZNdqzcak", "outputId": "6c7e51fa-d2ac-4497-a662-47675f8fe650", "colab": { "base_uri": "https://localhost:8080/", "height": 542 } }, "source": [ "from plotly.offline import init_notebook_mode, plot, iplot\n", "import plotly.graph_objs as go\n", "init_notebook_mode(connected=True)\n", "\n", "data = df['rating'].value_counts().sort_index(ascending=False)\n", "trace = go.Bar(x = data.index,\n", " text = ['{:.1f} %'.format(val) for val in (data.values / df.shape[0] * 100)],\n", " textposition = 'auto',\n", " textfont = dict(color = '#000000'),\n", " y = data.values,\n", " )\n", "# Create layout\n", "layout = dict(title = 'Distribution Of {} ratings'.format(df.shape[0]),\n", " xaxis = dict(title = 'Rating'),\n", " yaxis = dict(title = 'Count'))\n", "# Create plot\n", "fig = go.Figure(data=[trace], layout=layout)\n", "fig.show()" ], "execution_count": null, "outputs": [ { "output_type": "display_data", "data": { "text/html": [ " \n", " " ] }, "metadata": { "tags": [] } }, { "output_type": "display_data", "data": { "text/html": [ "
\n", " \n", " \n", "
\n", " \n", "
" ], "application/vnd.plotly.v1+json": { "data": [ { "textposition": "auto", "textfont": { "color": "#000000" }, "text": [ "13.1 %", "8.5 %", "26.6 %", "13.0 %", "19.9 %", "5.5 %", "7.5 %", "1.8 %", "2.8 %", "1.4 %" ], "y": [ 13211, 8551, 26818, 13136, 20047, 5550, 7551, 1791, 2811, 1370 ], "x": [ 5, 4.5, 4, 3.5, 3, 2.5, 2, 1.5, 1, 0.5 ], "type": "bar" } ], "config": { "plotlyServerURL": "https://plot.ly" }, "layout": { "yaxis": { "title": { "text": "Count" } }, "xaxis": { "title": { "text": "Rating" } }, "template": { "layout": { "shapedefaults": { "line": { "color": "#2a3f5f" } }, "polar": { "radialaxis": { "ticks": "", "gridcolor": "white", "linecolor": "white" }, "bgcolor": "#E5ECF6", "angularaxis": { "ticks": "", "gridcolor": "white", "linecolor": "white" } }, "colorway": [ "#636efa", "#EF553B", "#00cc96", "#ab63fa", "#FFA15A", "#19d3f3", "#FF6692", "#B6E880", "#FF97FF", "#FECB52" ], "xaxis": { "automargin": true, "title": { "standoff": 15 }, "zerolinewidth": 2, "ticks": "", "zerolinecolor": "white", "gridcolor": "white", "linecolor": "white" }, "colorscale": { "diverging": [ [ 0, "#8e0152" ], [ 0.1, "#c51b7d" ], [ 0.2, "#de77ae" ], [ 0.3, "#f1b6da" ], [ 0.4, "#fde0ef" ], [ 0.5, "#f7f7f7" ], [ 0.6, "#e6f5d0" ], [ 0.7, "#b8e186" ], [ 0.8, "#7fbc41" ], [ 0.9, "#4d9221" ], [ 1, "#276419" ] ], "sequential": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "sequentialminus": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ] }, "paper_bgcolor": "white", "plot_bgcolor": "#E5ECF6", "title": { "x": 0.05 }, "scene": { "zaxis": { "backgroundcolor": "#E5ECF6", "ticks": "", "gridwidth": 2, "showbackground": true, "zerolinecolor": "white", "gridcolor": "white", "linecolor": "white" }, "xaxis": { "backgroundcolor": "#E5ECF6", "ticks": "", "gridwidth": 2, "showbackground": true, "zerolinecolor": "white", "gridcolor": "white", "linecolor": "white" }, "yaxis": { "backgroundcolor": "#E5ECF6", "ticks": "", "gridwidth": 2, "showbackground": true, "zerolinecolor": "white", "gridcolor": "white", "linecolor": "white" } }, "yaxis": { "automargin": true, "title": { "standoff": 15 }, "zerolinewidth": 2, "ticks": "", "zerolinecolor": "white", "gridcolor": "white", "linecolor": "white" }, "annotationdefaults": { "arrowwidth": 1, "arrowhead": 0, "arrowcolor": "#2a3f5f" }, "hoverlabel": { "align": "left" }, "ternary": { "bgcolor": "#E5ECF6", "baxis": { "ticks": "", "gridcolor": "white", "linecolor": "white" }, "caxis": { "ticks": "", "gridcolor": "white", "linecolor": "white" }, "aaxis": { "ticks": "", "gridcolor": "white", "linecolor": "white" } }, "mapbox": { "style": "light" }, "hovermode": "closest", "font": { "color": "#2a3f5f" }, "geo": { "showland": true, "landcolor": "#E5ECF6", "showlakes": true, "bgcolor": "white", "subunitcolor": "white", "lakecolor": "white" }, "coloraxis": { "colorbar": { "outlinewidth": 0, "ticks": "" } } }, "data": { "mesh3d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "mesh3d" } ], "scattercarpet": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattercarpet" } ], "pie": [ { "automargin": true, "type": "pie" } ], "surface": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "surface", "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ] } ], "table": [ { "header": { "line": { "color": "white" }, "fill": { "color": "#C8D4E3" } }, "cells": { "line": { "color": "white" }, "fill": { "color": "#EBF0F8" } }, "type": "table" } ], "scatterpolargl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolargl" } ], "contour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "contour", "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ] } ], "carpet": [ { "type": "carpet", "baxis": { "minorgridcolor": "white", "gridcolor": "white", "linecolor": "white", "endlinecolor": "#2a3f5f", "startlinecolor": "#2a3f5f" }, "aaxis": { "minorgridcolor": "white", "gridcolor": "white", "linecolor": "white", "endlinecolor": "#2a3f5f", "startlinecolor": "#2a3f5f" } } ], "contourcarpet": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "contourcarpet" } ], "heatmap": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "heatmap", "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ] } ], "scattermapbox": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattermapbox" } ], "scatter3d": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatter3d" } ], "scattergl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergl" } ], "scatterternary": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterternary" } ], "histogram": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "histogram" } ], "heatmapgl": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "heatmapgl", "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ] } ], "scatterpolar": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolar" } ], "histogram2d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "histogram2d", "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ] } ], "scattergeo": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergeo" } ], "bar": [ { "marker": { "line": { "color": "#E5ECF6", "width": 0.5 } }, "type": "bar", "error_x": { "color": "#2a3f5f" }, "error_y": { "color": "#2a3f5f" } } ], "choropleth": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "choropleth" } ], "parcoords": [ { "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "parcoords" } ], "barpolar": [ { "marker": { "line": { "color": "#E5ECF6", "width": 0.5 } }, "type": "barpolar" } ], "histogram2dcontour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "histogram2dcontour", "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ] } ], "scatter": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatter" } ] } }, "title": { "text": "Distribution Of 100836 ratings" } } } }, "metadata": { "tags": [] } } ] }, { "cell_type": "markdown", "metadata": { "id": "SevuwLNb1UgS" }, "source": [ "### Ratings Distribution By Item" ] }, { "cell_type": "code", "metadata": { "id": "XelfoiCuzkq0", "outputId": "0e1015d1-2ee6-4df1-8fda-2283d19e43cd", "colab": { "base_uri": "https://localhost:8080/", "height": 542 } }, "source": [ "# Number of ratings per book\n", "data = df.groupby('item')['rating'].count().clip(upper=50)\n", "\n", "# Create trace\n", "trace = go.Histogram(x = data.values,\n", " name = 'Ratings',\n", " xbins = dict(start = 0,\n", " end = 50,\n", " size = 2))\n", "# Create layout\n", "layout = go.Layout(title = 'Distribution Of Number of Ratings Per Item (Clipped at 50)',\n", " xaxis = dict(title = 'Number of Ratings Per Item'),\n", " yaxis = dict(title = 'Count'),\n", " bargap = 0.2)\n", "\n", "# Create plot\n", "fig = go.Figure(data=[trace], layout=layout)\n", "fig.show()" ], "execution_count": null, "outputs": [ { "output_type": "display_data", "data": { "text/html": [ "
\n", " \n", " \n", "
\n", " \n", "
" ], "application/vnd.plotly.v1+json": { "data": [ { "x": [ 50, 50, 50, 7, 49, 50, 50, 8, 16, 50, 50, 19, 8, 18, 13, 50, 50, 20, 50, 15, 50, 36, 16, 28, 50, 13, 9, 11, 38, 3, 38, 50, 50, 50, 4, 50, 2, 15, 7, 8, 46, 32, 15, 50, 50, 1, 50, 28, 2, 3, 1, 8, 37, 34, 6, 50, 7, 5, 31, 9, 5, 20, 50, 5, 7, 13, 8, 5, 15, 1, 3, 17, 2, 14, 8, 1, 7, 15, 7, 16, 10, 8, 9, 10, 50, 1, 10, 2, 14, 23, 5, 3, 50, 23, 1, 26, 1, 50, 50, 46, 3, 5, 1, 2, 2, 2, 16, 4, 12, 7, 1, 1, 6, 31, 1, 16, 50, 12, 50, 3, 15, 1, 1, 50, 44, 2, 50, 12, 6, 3, 11, 50, 14, 50, 50, 17, 50, 14, 50, 3, 50, 10, 35, 6, 50, 50, 10, 20, 13, 8, 1, 2, 36, 17, 2, 2, 50, 48, 4, 12, 1, 5, 6, 35, 18, 10, 45, 28, 4, 1, 1, 22, 30, 9, 2, 21, 50, 3, 4, 2, 3, 6, 2, 24, 49, 6, 14, 1, 1, 16, 50, 40, 50, 22, 3, 7, 24, 50, 14, 12, 17, 50, 45, 22, 2, 17, 4, 1, 5, 1, 29, 21, 17, 18, 6, 3, 43, 50, 1, 7, 35, 14, 10, 5, 50, 42, 21, 1, 33, 50, 17, 2, 5, 4, 31, 28, 7, 6, 22, 38, 2, 2, 13, 14, 40, 3, 1, 1, 1, 50, 8, 14, 3, 50, 50, 2, 1, 50, 1, 4, 50, 1, 5, 32, 3, 9, 16, 24, 20, 1, 1, 9, 3, 16, 38, 50, 50, 50, 20, 1, 2, 10, 1, 7, 3, 34, 10, 50, 6, 2, 12, 50, 5, 2, 1, 50, 19, 50, 5, 2, 33, 5, 50, 36, 6, 6, 30, 50, 50, 17, 2, 50, 6, 42, 50, 50, 9, 1, 8, 17, 34, 2, 50, 4, 12, 50, 50, 2, 50, 21, 21, 11, 25, 40, 50, 7, 21, 50, 11, 16, 21, 2, 1, 1, 4, 2, 2, 5, 1, 10, 12, 1, 8, 2, 1, 50, 15, 26, 6, 16, 8, 13, 2, 20, 50, 12, 5, 10, 3, 2, 7, 12, 18, 6, 2, 42, 50, 8, 50, 50, 7, 9, 7, 50, 42, 50, 6, 12, 9, 8, 1, 7, 1, 3, 5, 50, 37, 4, 50, 5, 6, 3, 4, 10, 50, 1, 22, 5, 1, 40, 6, 7, 50, 25, 1, 17, 1, 4, 50, 19, 8, 2, 50, 3, 4, 1, 11, 12, 17, 14, 12, 41, 1, 1, 43, 2, 50, 6, 15, 2, 7, 2, 13, 50, 50, 1, 2, 4, 4, 18, 24, 18, 9, 4, 21, 50, 3, 7, 4, 34, 1, 50, 3, 40, 24, 16, 18, 14, 15, 3, 12, 12, 50, 18, 50, 14, 41, 8, 21, 2, 6, 2, 5, 50, 50, 50, 50, 6, 8, 23, 1, 2, 3, 2, 6, 1, 4, 16, 4, 1, 5, 4, 1, 36, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 11, 1, 1, 10, 4, 50, 14, 33, 6, 6, 8, 1, 45, 3, 1, 5, 1, 6, 35, 11, 1, 1, 4, 2, 1, 33, 1, 4, 11, 2, 29, 50, 1, 4, 50, 5, 49, 7, 12, 3, 8, 2, 2, 36, 50, 9, 9, 1, 4, 2, 9, 3, 4, 11, 2, 5, 1, 7, 2, 7, 1, 21, 50, 11, 8, 10, 15, 3, 4, 35, 27, 1, 31, 5, 1, 10, 3, 50, 7, 50, 20, 27, 11, 29, 48, 3, 22, 50, 1, 2, 2, 19, 41, 2, 19, 4, 1, 1, 50, 2, 50, 7, 8, 47, 50, 42, 50, 50, 1, 1, 2, 12, 23, 19, 11, 46, 1, 8, 35, 1, 2, 9, 12, 5, 10, 1, 1, 6, 9, 21, 37, 6, 3, 17, 33, 30, 15, 4, 2, 12, 7, 44, 6, 43, 50, 9, 23, 2, 3, 2, 1, 1, 4, 27, 5, 1, 2, 6, 3, 1, 5, 13, 3, 2, 2, 29, 47, 12, 7, 36, 50, 50, 14, 7, 2, 50, 27, 50, 13, 50, 44, 35, 30, 26, 2, 10, 50, 45, 9, 27, 50, 50, 24, 3, 18, 1, 20, 9, 8, 23, 12, 3, 6, 2, 6, 8, 2, 6, 7, 3, 7, 3, 4, 6, 6, 7, 14, 12, 50, 18, 18, 1, 1, 1, 1, 11, 28, 34, 1, 10, 5, 1, 1, 2, 1, 2, 13, 1, 2, 5, 11, 1, 11, 13, 3, 12, 3, 6, 8, 5, 10, 1, 9, 9, 8, 9, 12, 5, 20, 5, 10, 6, 17, 37, 27, 42, 13, 6, 25, 28, 50, 35, 15, 24, 40, 20, 5, 50, 50, 24, 1, 11, 42, 5, 4, 33, 21, 5, 3, 1, 1, 2, 7, 15, 36, 36, 29, 13, 4, 1, 50, 28, 11, 50, 50, 12, 6, 6, 35, 2, 25, 42, 50, 50, 21, 47, 37, 42, 15, 10, 50, 4, 19, 50, 15, 20, 3, 2, 4, 2, 1, 1, 1, 1, 27, 1, 2, 13, 24, 6, 50, 5, 39, 5, 11, 8, 13, 50, 1, 1, 1, 10, 50, 3, 2, 1, 3, 1, 1, 2, 2, 17, 34, 11, 21, 3, 6, 12, 27, 1, 45, 7, 10, 23, 5, 22, 11, 6, 6, 5, 50, 11, 50, 50, 50, 50, 50, 50, 7, 50, 45, 50, 50, 50, 18, 50, 13, 24, 50, 50, 50, 11, 15, 11, 50, 50, 50, 50, 28, 19, 50, 6, 16, 40, 50, 22, 8, 40, 50, 26, 3, 18, 9, 50, 10, 41, 16, 33, 20, 50, 50, 17, 35, 45, 14, 50, 25, 16, 6, 23, 27, 50, 50, 15, 34, 43, 43, 5, 50, 45, 30, 9, 29, 50, 30, 33, 11, 39, 48, 50, 12, 50, 8, 9, 15, 50, 19, 14, 41, 7, 34, 50, 11, 10, 50, 20, 27, 11, 17, 20, 23, 28, 9, 13, 50, 17, 50, 4, 5, 50, 1, 2, 1, 47, 23, 3, 3, 3, 2, 4, 15, 2, 2, 4, 1, 3, 44, 6, 1, 1, 1, 29, 3, 2, 11, 25, 14, 36, 8, 27, 16, 1, 22, 3, 2, 4, 7, 3, 50, 24, 47, 18, 6, 5, 6, 5, 47, 50, 45, 42, 30, 50, 42, 43, 50, 25, 11, 50, 19, 4, 24, 50, 17, 6, 9, 50, 4, 50, 50, 5, 46, 2, 1, 5, 3, 31, 2, 50, 39, 23, 16, 1, 2, 8, 2, 12, 2, 2, 4, 1, 8, 1, 1, 2, 20, 3, 16, 7, 2, 24, 3, 2, 19, 5, 7, 7, 4, 24, 3, 6, 1, 12, 1, 12, 2, 8, 17, 3, 50, 5, 1, 11, 1, 26, 1, 30, 11, 11, 3, 50, 5, 15, 2, 2, 1, 2, 1, 3, 5, 27, 50, 2, 4, 1, 29, 1, 15, 1, 50, 13, 1, 3, 50, 3, 2, 13, 10, 7, 50, 2, 1, 2, 1, 4, 3, 50, 5, 19, 42, 2, 1, 31, 40, 2, 2, 50, 1, 50, 3, 5, 2, 50, 1, 22, 31, 20, 16, 25, 26, 4, 6, 6, 3, 43, 4, 3, 2, 3, 4, 13, 3, 4, 3, 50, 3, 50, 5, 2, 1, 26, 11, 20, 50, 14, 13, 2, 2, 2, 50, 3, 7, 3, 1, 5, 17, 50, 50, 2, 5, 32, 50, 7, 3, 4, 3, 2, 1, 50, 1, 1, 1, 8, 1, 1, 1, 2, 34, 16, 5, 3, 1, 12, 39, 40, 1, 50, 1, 10, 1, 25, 7, 50, 6, 4, 1, 3, 18, 20, 7, 45, 19, 7, 2, 2, 2, 8, 16, 5, 50, 8, 24, 7, 31, 2, 16, 50, 45, 13, 4, 48, 4, 4, 50, 4, 9, 11, 1, 1, 31, 48, 4, 16, 15, 5, 1, 1, 10, 5, 2, 14, 2, 1, 12, 50, 23, 5, 50, 5, 3, 23, 2, 1, 6, 2, 13, 25, 3, 31, 8, 1, 6, 11, 3, 3, 6, 1, 1, 1, 3, 2, 29, 13, 11, 17, 3, 4, 1, 7, 1, 4, 15, 12, 7, 3, 1, 8, 3, 4, 9, 7, 7, 1, 1, 10, 6, 43, 2, 33, 24, 46, 12, 2, 3, 8, 1, 16, 1, 16, 15, 2, 1, 1, 3, 2, 45, 42, 2, 32, 32, 3, 9, 12, 50, 33, 5, 18, 47, 2, 50, 8, 1, 10, 1, 2, 6, 1, 1, 3, 3, 2, 3, 8, 1, 2, 4, 11, 24, 3, 34, 7, 6, 11, 7, 22, 39, 50, 14, 12, 13, 22, 15, 26, 50, 23, 11, 6, 21, 8, 42, 50, 10, 12, 7, 7, 5, 16, 7, 7, 6, 2, 4, 1, 3, 27, 5, 3, 1, 2, 2, 1, 12, 4, 5, 47, 6, 4, 50, 4, 4, 50, 47, 46, 41, 15, 50, 50, 2, 1, 19, 21, 50, 50, 21, 8, 9, 4, 5, 38, 48, 25, 37, 8, 45, 3, 7, 3, 9, 50, 1, 8, 9, 3, 6, 1, 3, 7, 3, 6, 4, 2, 24, 8, 4, 3, 23, 20, 50, 1, 1, 4, 30, 15, 14, 31, 13, 4, 21, 2, 2, 5, 2, 17, 5, 3, 1, 46, 5, 50, 50, 50, 26, 19, 5, 44, 41, 18, 10, 13, 4, 6, 6, 39, 3, 22, 10, 2, 6, 50, 3, 3, 1, 50, 5, 3, 24, 27, 18, 10, 8, 16, 50, 15, 14, 15, 3, 4, 7, 11, 15, 38, 21, 15, 8, 4, 7, 20, 22, 11, 14, 21, 10, 21, 34, 18, 10, 13, 49, 33, 16, 3, 9, 4, 28, 6, 3, 11, 2, 8, 1, 7, 32, 43, 8, 5, 1, 2, 4, 50, 7, 5, 8, 1, 50, 1, 10, 3, 2, 1, 1, 4, 4, 9, 6, 2, 25, 2, 5, 1, 40, 50, 7, 1, 2, 7, 7, 4, 4, 5, 1, 6, 2, 1, 3, 1, 3, 36, 27, 9, 6, 7, 4, 28, 2, 22, 12, 39, 11, 5, 20, 2, 2, 1, 8, 2, 6, 9, 5, 4, 4, 5, 2, 50, 8, 2, 2, 42, 5, 43, 10, 2, 1, 6, 2, 1, 5, 45, 38, 5, 50, 1, 45, 2, 10, 14, 1, 33, 16, 50, 5, 1, 6, 1, 3, 17, 12, 17, 2, 6, 7, 16, 9, 50, 8, 2, 50, 13, 3, 7, 50, 2, 3, 2, 4, 13, 28, 23, 4, 18, 1, 20, 2, 8, 11, 3, 8, 7, 2, 7, 25, 50, 7, 50, 5, 6, 1, 26, 12, 10, 1, 3, 2, 2, 25, 14, 1, 24, 1, 24, 9, 9, 9, 21, 21, 5, 22, 12, 10, 7, 5, 4, 29, 3, 16, 1, 9, 7, 22, 8, 33, 25, 50, 50, 17, 4, 2, 8, 19, 30, 12, 21, 50, 43, 9, 26, 24, 29, 17, 18, 11, 1, 16, 1, 6, 2, 38, 29, 14, 30, 50, 2, 35, 23, 5, 6, 27, 6, 11, 1, 6, 3, 3, 8, 8, 2, 15, 3, 16, 1, 3, 13, 43, 9, 8, 8, 13, 3, 1, 14, 3, 18, 15, 7, 50, 24, 3, 8, 13, 3, 12, 3, 26, 1, 2, 1, 29, 3, 45, 5, 7, 1, 2, 3, 23, 6, 5, 7, 30, 50, 1, 6, 18, 6, 3, 1, 10, 3, 2, 1, 10, 10, 3, 2, 4, 2, 9, 3, 3, 18, 24, 50, 18, 9, 12, 15, 3, 3, 3, 1, 47, 3, 40, 50, 1, 2, 6, 6, 7, 8, 2, 6, 3, 3, 1, 9, 1, 8, 4, 3, 12, 2, 19, 8, 5, 50, 50, 1, 6, 4, 1, 6, 39, 36, 3, 12, 2, 2, 4, 1, 1, 4, 10, 12, 2, 25, 50, 22, 43, 15, 2, 1, 1, 1, 8, 2, 4, 26, 50, 5, 1, 11, 1, 2, 2, 50, 2, 2, 1, 3, 3, 4, 50, 49, 22, 16, 9, 11, 1, 1, 5, 1, 1, 50, 1, 4, 1, 12, 13, 1, 8, 2, 5, 50, 12, 2, 6, 4, 3, 3, 50, 19, 24, 15, 10, 3, 50, 4, 48, 1, 3, 1, 1, 50, 50, 50, 15, 50, 22, 3, 9, 50, 50, 12, 50, 47, 10, 13, 21, 29, 39, 42, 1, 9, 1, 13, 7, 7, 12, 5, 2, 10, 16, 5, 1, 1, 12, 1, 2, 1, 1, 1, 9, 39, 9, 6, 2, 7, 1, 8, 1, 1, 8, 39, 50, 48, 7, 1, 2, 5, 38, 4, 10, 1, 1, 13, 3, 2, 4, 6, 28, 4, 2, 50, 19, 10, 15, 26, 11, 50, 12, 8, 1, 1, 13, 13, 50, 23, 9, 4, 17, 5, 1, 1, 7, 3, 3, 3, 16, 1, 11, 1, 26, 11, 2, 7, 1, 4, 1, 1, 23, 18, 9, 3, 7, 2, 1, 4, 1, 1, 14, 50, 7, 9, 8, 1, 19, 1, 5, 12, 2, 8, 30, 25, 3, 10, 1, 7, 2, 7, 6, 19, 4, 5, 1, 1, 2, 1, 5, 8, 45, 3, 1, 1, 1, 1, 1, 1, 3, 2, 14, 4, 2, 4, 7, 7, 39, 14, 42, 50, 10, 50, 8, 11, 5, 10, 5, 11, 2, 2, 2, 1, 3, 3, 8, 7, 5, 6, 9, 16, 3, 32, 7, 50, 36, 33, 14, 39, 12, 31, 6, 50, 5, 2, 1, 1, 14, 4, 41, 1, 4, 6, 1, 18, 1, 1, 6, 2, 4, 1, 1, 1, 1, 50, 25, 50, 3, 21, 20, 23, 1, 24, 14, 4, 50, 48, 1, 2, 11, 25, 31, 6, 1, 1, 4, 1, 1, 3, 14, 4, 10, 10, 17, 1, 9, 7, 2, 6, 13, 4, 6, 50, 36, 11, 7, 24, 5, 39, 9, 6, 2, 1, 13, 5, 2, 3, 3, 50, 11, 8, 3, 1, 1, 15, 8, 11, 6, 3, 7, 10, 7, 21, 9, 27, 1, 4, 3, 4, 2, 2, 6, 50, 39, 19, 1, 24, 12, 16, 6, 4, 4, 2, 9, 1, 3, 24, 7, 22, 36, 7, 2, 22, 22, 1, 23, 36, 4, 4, 1, 15, 50, 5, 4, 2, 1, 3, 3, 5, 1, 7, 3, 2, 2, 4, 1, 3, 17, 50, 26, 2, 8, 5, 9, 15, 19, 3, 15, 50, 2, 1, 4, 2, 4, 29, 5, 1, 18, 39, 50, 49, 6, 16, 3, 6, 5, 1, 3, 28, 11, 4, 1, 4, 9, 7, 14, 8, 8, 12, 8, 3, 8, 42, 2, 13, 2, 3, 13, 5, 2, 4, 4, 4, 3, 6, 2, 2, 15, 12, 15, 36, 14, 9, 9, 5, 27, 50, 27, 45, 31, 32, 15, 11, 12, 11, 11, 22, 26, 9, 6, 18, 11, 27, 12, 17, 8, 29, 12, 43, 1, 1, 1, 2, 1, 32, 5, 3, 1, 1, 1, 7, 21, 3, 39, 42, 2, 1, 4, 13, 7, 5, 2, 1, 13, 22, 1, 3, 3, 3, 5, 19, 1, 2, 1, 10, 7, 5, 1, 1, 9, 3, 1, 21, 15, 1, 10, 11, 22, 35, 38, 43, 3, 7, 2, 2, 2, 1, 1, 1, 4, 8, 31, 7, 11, 1, 1, 2, 6, 3, 7, 3, 33, 11, 15, 1, 5, 2, 1, 6, 1, 3, 50, 35, 1, 6, 1, 3, 1, 41, 3, 50, 6, 3, 27, 5, 7, 1, 12, 4, 3, 2, 1, 1, 17, 4, 25, 13, 14, 14, 1, 9, 4, 2, 2, 43, 1, 29, 11, 18, 2, 2, 1, 1, 13, 25, 8, 4, 18, 6, 5, 50, 2, 1, 2, 26, 13, 7, 18, 3, 50, 13, 10, 50, 1, 6, 1, 4, 8, 44, 4, 5, 3, 11, 22, 9, 5, 15, 18, 36, 6, 8, 7, 1, 9, 4, 6, 7, 10, 5, 15, 50, 5, 5, 1, 25, 50, 21, 3, 5, 2, 14, 3, 5, 2, 5, 8, 6, 13, 50, 5, 3, 33, 26, 5, 3, 3, 12, 7, 8, 1, 1, 2, 2, 4, 2, 1, 4, 2, 50, 2, 2, 4, 1, 2, 1, 15, 1, 19, 6, 1, 2, 3, 5, 1, 4, 25, 1, 8, 14, 10, 41, 12, 1, 1, 50, 43, 1, 3, 4, 2, 7, 5, 17, 1, 18, 1, 26, 18, 1, 2, 2, 17, 1, 8, 1, 3, 13, 2, 1, 2, 1, 2, 1, 1, 1, 15, 1, 50, 5, 2, 1, 8, 10, 4, 1, 2, 1, 33, 5, 19, 7, 9, 15, 1, 11, 4, 5, 1, 1, 8, 2, 2, 3, 21, 34, 13, 1, 13, 38, 40, 24, 8, 8, 10, 10, 1, 3, 1, 3, 1, 1, 2, 1, 50, 2, 1, 5, 5, 2, 5, 8, 4, 3, 17, 1, 4, 3, 17, 1, 1, 2, 1, 28, 11, 10, 3, 19, 29, 2, 2, 50, 46, 50, 9, 44, 1, 2, 3, 1, 16, 5, 2, 6, 3, 2, 3, 6, 3, 2, 4, 11, 11, 50, 4, 2, 6, 1, 2, 16, 1, 50, 2, 1, 3, 25, 6, 4, 4, 1, 1, 1, 35, 3, 7, 12, 3, 9, 1, 3, 16, 4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1, 1, 4, 1, 1, 2, 1, 1, 2, 1, 2, 4, 12, 5, 1, 1, 3, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ], "type": "histogram", "name": "Ratings", "xbins": { "start": 0, "end": 50, "size": 2 } } ], "config": { "plotlyServerURL": "https://plot.ly" }, "layout": { "bargap": 0.2, "yaxis": { "title": { "text": "Count" } }, "xaxis": { "title": { "text": "Number of Ratings Per Item" } }, "template": { "layout": { "shapedefaults": { "line": { "color": "#2a3f5f" } }, "polar": { "radialaxis": { "ticks": "", "gridcolor": "white", "linecolor": "white" }, "bgcolor": "#E5ECF6", "angularaxis": { "ticks": "", "gridcolor": "white", "linecolor": "white" } }, "colorway": [ "#636efa", "#EF553B", "#00cc96", "#ab63fa", "#FFA15A", "#19d3f3", "#FF6692", "#B6E880", "#FF97FF", "#FECB52" ], "xaxis": { "automargin": true, "title": { "standoff": 15 }, "zerolinewidth": 2, "ticks": "", "zerolinecolor": "white", "gridcolor": "white", "linecolor": "white" }, "colorscale": { "diverging": [ [ 0, "#8e0152" ], [ 0.1, "#c51b7d" ], [ 0.2, "#de77ae" ], [ 0.3, "#f1b6da" ], [ 0.4, "#fde0ef" ], [ 0.5, "#f7f7f7" ], [ 0.6, "#e6f5d0" ], [ 0.7, "#b8e186" ], [ 0.8, "#7fbc41" ], [ 0.9, "#4d9221" ], [ 1, "#276419" ] ], "sequential": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "sequentialminus": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ] }, "paper_bgcolor": "white", "plot_bgcolor": "#E5ECF6", "title": { "x": 0.05 }, "scene": { "zaxis": { "backgroundcolor": "#E5ECF6", "ticks": "", "gridwidth": 2, "showbackground": true, "zerolinecolor": "white", "gridcolor": "white", "linecolor": "white" }, "xaxis": { "backgroundcolor": "#E5ECF6", "ticks": "", "gridwidth": 2, "showbackground": true, "zerolinecolor": "white", "gridcolor": "white", "linecolor": "white" }, "yaxis": { "backgroundcolor": "#E5ECF6", "ticks": "", "gridwidth": 2, "showbackground": true, "zerolinecolor": "white", "gridcolor": "white", "linecolor": "white" } }, "yaxis": { "automargin": true, "title": { "standoff": 15 }, "zerolinewidth": 2, "ticks": "", "zerolinecolor": "white", "gridcolor": "white", "linecolor": "white" }, "annotationdefaults": { "arrowwidth": 1, "arrowhead": 0, "arrowcolor": "#2a3f5f" }, "hoverlabel": { "align": "left" }, "ternary": { "bgcolor": "#E5ECF6", "baxis": { "ticks": "", "gridcolor": "white", "linecolor": "white" }, "caxis": { "ticks": "", "gridcolor": "white", "linecolor": "white" }, "aaxis": { "ticks": "", "gridcolor": "white", "linecolor": "white" } }, "mapbox": { "style": "light" }, "hovermode": "closest", "font": { "color": "#2a3f5f" }, "geo": { "showland": true, "landcolor": "#E5ECF6", "showlakes": true, "bgcolor": "white", "subunitcolor": "white", "lakecolor": "white" }, "coloraxis": { "colorbar": { "outlinewidth": 0, "ticks": "" } } }, "data": { "mesh3d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "mesh3d" } ], "scattercarpet": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattercarpet" } ], "pie": [ { "automargin": true, "type": "pie" } ], "surface": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "surface", "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ] } ], "table": [ { "header": { "line": { "color": "white" }, "fill": { "color": "#C8D4E3" } }, "cells": { "line": { "color": "white" }, "fill": { "color": "#EBF0F8" } }, "type": "table" } ], "scatterpolargl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolargl" } ], "contour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "contour", "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ] } ], "carpet": [ { "type": "carpet", "baxis": { "minorgridcolor": "white", "gridcolor": "white", "linecolor": "white", "endlinecolor": "#2a3f5f", "startlinecolor": "#2a3f5f" }, "aaxis": { "minorgridcolor": "white", "gridcolor": "white", "linecolor": "white", "endlinecolor": "#2a3f5f", "startlinecolor": "#2a3f5f" } } ], "contourcarpet": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "contourcarpet" } ], "heatmap": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "heatmap", "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ] } ], "scattermapbox": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattermapbox" } ], "scatter3d": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatter3d" } ], "scattergl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergl" } ], "scatterternary": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterternary" } ], "histogram": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "histogram" } ], "heatmapgl": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "heatmapgl", "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ] } ], "scatterpolar": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolar" } ], "histogram2d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "histogram2d", "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ] } ], "scattergeo": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergeo" } ], "bar": [ { "marker": { "line": { "color": "#E5ECF6", "width": 0.5 } }, "type": "bar", "error_x": { "color": "#2a3f5f" }, "error_y": { "color": "#2a3f5f" } } ], "choropleth": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "choropleth" } ], "parcoords": [ { "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "parcoords" } ], "barpolar": [ { "marker": { "line": { "color": "#E5ECF6", "width": 0.5 } }, "type": "barpolar" } ], "histogram2dcontour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "histogram2dcontour", "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ] } ], "scatter": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatter" } ] } }, "title": { "text": "Distribution Of Number of Ratings Per Item (Clipped at 50)" } } } }, "metadata": { "tags": [] } } ] }, { "cell_type": "code", "metadata": { "id": "_G95bJX90FHz", "outputId": "585a5654-af36-4099-b9d5-61bba256c22d", "colab": { "base_uri": "https://localhost:8080/", "height": 359 } }, "source": [ "df.groupby('item')['rating'].count().reset_index().sort_values('rating', ascending=False)[:10]" ], "execution_count": null, "outputs": [ { "output_type": "execute_result", "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
itemrating
314356329
277318317
257296307
510593279
19382571278
224260251
418480238
97110237
507589224
461527220
\n", "
" ], "text/plain": [ " item rating\n", "314 356 329\n", "277 318 317\n", "257 296 307\n", "510 593 279\n", "1938 2571 278\n", "224 260 251\n", "418 480 238\n", "97 110 237\n", "507 589 224\n", "461 527 220" ] }, "metadata": { "tags": [] }, "execution_count": 13 } ] }, { "cell_type": "markdown", "metadata": { "id": "217_IWgm2OJk" }, "source": [ "### Ratings Distribution By User" ] }, { "cell_type": "code", "metadata": { "id": "x77YkfkH1tYG", "outputId": "0a2b2daa-c7ad-479e-ce9f-496514bfe832", "colab": { "base_uri": "https://localhost:8080/", "height": 542 } }, "source": [ "# Number of ratings per user\n", "data = df.groupby('userID')['rating'].count().clip(upper=50)\n", "\n", "# Create trace\n", "trace = go.Histogram(x = data.values,\n", " name = 'Ratings',\n", " xbins = dict(start = 0,\n", " end = 50,\n", " size = 2))\n", "# Create layout\n", "layout = go.Layout(title = 'Distribution Of Number of Ratings Per User (Clipped at 50)',\n", " xaxis = dict(title = 'Ratings Per User'),\n", " yaxis = dict(title = 'Count'),\n", " bargap = 0.2)\n", "\n", "# Create plot\n", "fig = go.Figure(data=[trace], layout=layout)\n", "fig.show()" ], "execution_count": null, "outputs": [ { "output_type": "display_data", "data": { "text/html": [ "
\n", " \n", " \n", "
\n", " \n", "
" ], "application/vnd.plotly.v1+json": { "data": [ { "x": [ 50, 29, 39, 50, 44, 50, 50, 47, 46, 50, 50, 32, 31, 48, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 26, 21, 50, 50, 50, 34, 50, 50, 50, 50, 23, 50, 21, 50, 50, 50, 50, 50, 50, 48, 50, 42, 50, 33, 21, 50, 50, 50, 20, 33, 25, 46, 50, 50, 50, 22, 39, 50, 50, 50, 34, 50, 36, 50, 46, 50, 35, 45, 50, 50, 50, 50, 29, 50, 50, 50, 26, 50, 50, 50, 34, 50, 21, 50, 50, 50, 50, 24, 50, 50, 50, 50, 36, 50, 50, 50, 50, 50, 50, 50, 50, 33, 34, 50, 50, 50, 50, 50, 50, 31, 50, 50, 50, 22, 50, 22, 50, 50, 50, 50, 50, 38, 22, 33, 50, 28, 50, 50, 35, 35, 50, 50, 50, 22, 50, 50, 50, 38, 50, 50, 23, 32, 20, 48, 50, 26, 50, 50, 50, 34, 46, 50, 21, 26, 50, 50, 39, 38, 23, 36, 50, 50, 50, 50, 50, 50, 50, 26, 25, 50, 24, 36, 50, 50, 50, 24, 50, 50, 50, 50, 47, 50, 50, 48, 20, 50, 50, 22, 35, 20, 50, 32, 35, 50, 50, 50, 50, 50, 45, 50, 27, 25, 20, 26, 35, 50, 50, 50, 50, 22, 50, 50, 50, 26, 50, 50, 50, 50, 50, 50, 50, 50, 50, 25, 50, 50, 24, 50, 50, 50, 50, 30, 50, 44, 50, 50, 50, 35, 36, 50, 21, 50, 50, 50, 50, 27, 23, 38, 47, 50, 44, 50, 20, 25, 29, 50, 50, 50, 50, 50, 50, 50, 50, 50, 29, 40, 43, 31, 50, 50, 50, 41, 28, 20, 50, 50, 21, 50, 35, 50, 36, 50, 50, 50, 24, 50, 31, 50, 21, 50, 41, 27, 50, 50, 23, 32, 50, 32, 50, 50, 50, 50, 50, 50, 50, 50, 28, 50, 50, 50, 33, 50, 50, 50, 35, 20, 50, 50, 50, 21, 50, 50, 48, 50, 23, 50, 50, 50, 25, 50, 28, 50, 50, 39, 50, 28, 50, 50, 50, 50, 50, 50, 45, 50, 37, 40, 50, 50, 50, 50, 26, 50, 50, 41, 50, 25, 50, 50, 30, 21, 50, 31, 50, 50, 50, 50, 41, 50, 50, 33, 33, 50, 50, 48, 36, 50, 50, 50, 34, 50, 50, 50, 50, 29, 34, 50, 50, 25, 50, 23, 50, 28, 23, 46, 36, 43, 50, 48, 34, 50, 50, 20, 22, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 37, 50, 23, 50, 50, 50, 50, 50, 50, 50, 20, 50, 22, 50, 42, 50, 50, 50, 21, 33, 45, 20, 37, 42, 50, 50, 50, 50, 38, 50, 34, 50, 50, 45, 50, 43, 50, 50, 26, 50, 27, 50, 33, 50, 50, 50, 22, 33, 50, 50, 28, 29, 37, 50, 50, 50, 50, 22, 50, 50, 31, 50, 50, 50, 23, 50, 50, 50, 50, 50, 50, 50, 50, 22, 50, 29, 50, 35, 27, 50, 45, 35, 50, 50, 31, 42, 21, 24, 50, 50, 50, 50, 32, 50, 26, 26, 50, 24, 26, 50, 40, 50, 50, 50, 50, 50, 50, 50, 25, 27, 22, 50, 38, 50, 30, 40, 47, 37, 38, 42, 50, 50, 50, 22, 23, 50, 21, 26, 21, 28, 50, 50, 50, 50, 50, 32, 27, 50, 50, 50, 50, 50, 50, 50, 29, 50, 50, 23, 20, 50, 50, 50, 50, 23, 36, 20, 50, 27, 50, 50, 40, 50, 50, 50, 50, 50, 50, 50, 40, 50, 50, 50, 50, 50, 20, 50, 50, 21, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 37, 50 ], "type": "histogram", "name": "Ratings", "xbins": { "start": 0, "end": 50, "size": 2 } } ], "config": { "plotlyServerURL": "https://plot.ly" }, "layout": { "bargap": 0.2, "yaxis": { "title": { "text": "Count" } }, "xaxis": { "title": { "text": "Ratings Per User" } }, "template": { "layout": { "shapedefaults": { "line": { "color": "#2a3f5f" } }, "polar": { "radialaxis": { "ticks": "", "gridcolor": "white", "linecolor": "white" }, "bgcolor": "#E5ECF6", "angularaxis": { "ticks": "", "gridcolor": "white", "linecolor": "white" } }, "colorway": [ "#636efa", "#EF553B", "#00cc96", "#ab63fa", "#FFA15A", "#19d3f3", "#FF6692", "#B6E880", "#FF97FF", "#FECB52" ], "xaxis": { "automargin": true, "title": { "standoff": 15 }, "zerolinewidth": 2, "ticks": "", "zerolinecolor": "white", "gridcolor": "white", "linecolor": "white" }, "colorscale": { "diverging": [ [ 0, "#8e0152" ], [ 0.1, "#c51b7d" ], [ 0.2, "#de77ae" ], [ 0.3, "#f1b6da" ], [ 0.4, "#fde0ef" ], [ 0.5, "#f7f7f7" ], [ 0.6, "#e6f5d0" ], [ 0.7, "#b8e186" ], [ 0.8, "#7fbc41" ], [ 0.9, "#4d9221" ], [ 1, "#276419" ] ], "sequential": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "sequentialminus": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ] }, "paper_bgcolor": "white", "plot_bgcolor": "#E5ECF6", "title": { "x": 0.05 }, "scene": { "zaxis": { "backgroundcolor": "#E5ECF6", "ticks": "", "gridwidth": 2, "showbackground": true, "zerolinecolor": "white", "gridcolor": "white", "linecolor": "white" }, "xaxis": { "backgroundcolor": "#E5ECF6", "ticks": "", "gridwidth": 2, "showbackground": true, "zerolinecolor": "white", "gridcolor": "white", "linecolor": "white" }, "yaxis": { "backgroundcolor": "#E5ECF6", "ticks": "", "gridwidth": 2, "showbackground": true, "zerolinecolor": "white", "gridcolor": "white", "linecolor": "white" } }, "yaxis": { "automargin": true, "title": { "standoff": 15 }, "zerolinewidth": 2, "ticks": "", "zerolinecolor": "white", "gridcolor": "white", "linecolor": "white" }, "annotationdefaults": { "arrowwidth": 1, "arrowhead": 0, "arrowcolor": "#2a3f5f" }, "hoverlabel": { "align": "left" }, "ternary": { "bgcolor": "#E5ECF6", "baxis": { "ticks": "", "gridcolor": "white", "linecolor": "white" }, "caxis": { "ticks": "", "gridcolor": "white", "linecolor": "white" }, "aaxis": { "ticks": "", "gridcolor": "white", "linecolor": "white" } }, "mapbox": { "style": "light" }, "hovermode": "closest", "font": { "color": "#2a3f5f" }, "geo": { "showland": true, "landcolor": "#E5ECF6", "showlakes": true, "bgcolor": "white", "subunitcolor": "white", "lakecolor": "white" }, "coloraxis": { "colorbar": { "outlinewidth": 0, "ticks": "" } } }, "data": { "mesh3d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "mesh3d" } ], "scattercarpet": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattercarpet" } ], "pie": [ { "automargin": true, "type": "pie" } ], "surface": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "surface", "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ] } ], "table": [ { "header": { "line": { "color": "white" }, "fill": { "color": "#C8D4E3" } }, "cells": { "line": { "color": "white" }, "fill": { "color": "#EBF0F8" } }, "type": "table" } ], "scatterpolargl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolargl" } ], "contour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "contour", "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ] } ], "carpet": [ { "type": "carpet", "baxis": { "minorgridcolor": "white", "gridcolor": "white", "linecolor": "white", "endlinecolor": "#2a3f5f", "startlinecolor": "#2a3f5f" }, "aaxis": { "minorgridcolor": "white", "gridcolor": "white", "linecolor": "white", "endlinecolor": "#2a3f5f", "startlinecolor": "#2a3f5f" } } ], "contourcarpet": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "contourcarpet" } ], "heatmap": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "heatmap", "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ] } ], "scattermapbox": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattermapbox" } ], "scatter3d": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatter3d" } ], "scattergl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergl" } ], "scatterternary": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterternary" } ], "histogram": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "histogram" } ], "heatmapgl": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "heatmapgl", "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ] } ], "scatterpolar": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolar" } ], "histogram2d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "histogram2d", "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ] } ], "scattergeo": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergeo" } ], "bar": [ { "marker": { "line": { "color": "#E5ECF6", "width": 0.5 } }, "type": "bar", "error_x": { "color": "#2a3f5f" }, "error_y": { "color": "#2a3f5f" } } ], "choropleth": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "choropleth" } ], "parcoords": [ { "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "parcoords" } ], "barpolar": [ { "marker": { "line": { "color": "#E5ECF6", "width": 0.5 } }, "type": "barpolar" } ], "histogram2dcontour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "histogram2dcontour", "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ] } ], "scatter": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatter" } ] } }, "title": { "text": "Distribution Of Number of Ratings Per User (Clipped at 50)" } } } }, "metadata": { "tags": [] } } ] }, { "cell_type": "code", "metadata": { "id": "YLt_VoYh2ZP6", "outputId": "ce16fc3c-abe7-42a5-9698-a89d040afdf9", "colab": { "base_uri": "https://localhost:8080/", "height": 359 } }, "source": [ "df.groupby('userID')['rating'].count().reset_index().sort_values('rating', ascending=False)[:10]" ], "execution_count": null, "outputs": [ { "output_type": "execute_result", "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
userIDrating
4134142698
5985992478
4734742108
4474481864
2732741346
6096101302
67681260
3793801218
6056061115
2872881055
\n", "
" ], "text/plain": [ " userID rating\n", "413 414 2698\n", "598 599 2478\n", "473 474 2108\n", "447 448 1864\n", "273 274 1346\n", "609 610 1302\n", "67 68 1260\n", "379 380 1218\n", "605 606 1115\n", "287 288 1055" ] }, "metadata": { "tags": [] }, "execution_count": 15 } ] }, { "cell_type": "markdown", "metadata": { "id": "GOIdBWCl3VNt" }, "source": [ "### Dimensionality\n", "\n", "To reduce the dimensionality of the dataset, we will filter out rarely rated movies and rarely rating users" ] }, { "cell_type": "code", "metadata": { "id": "1QZNP2jb2n51", "outputId": "baf6f52c-e1b8-4c54-d93d-4eeacccadd8b", "colab": { "base_uri": "https://localhost:8080/", "height": 51 } }, "source": [ "min_ratings = 5\n", "filter_items = df['item'].value_counts() > min_ratings\n", "filter_items = filter_items[filter_items].index.tolist()\n", "\n", "min_user_ratings = 5\n", "filter_users = df['userID'].value_counts() > min_user_ratings\n", "filter_users = filter_users[filter_users].index.tolist()\n", "\n", "df_new = df[(df['item'].isin(filter_items)) & (df['userID'].isin(filter_users))]\n", "print('The original data frame shape:\\t{}'.format(df.shape))\n", "print('The new data frame shape:\\t{}'.format(df_new.shape))" ], "execution_count": null, "outputs": [ { "output_type": "stream", "text": [ "The original data frame shape:\t(100836, 3)\n", "The new data frame shape:\t(88364, 3)\n" ], "name": "stdout" } ] }, { "cell_type": "markdown", "metadata": { "id": "dUSIbusO6Rr1" }, "source": [ "## Surprise" ] }, { "cell_type": "markdown", "metadata": { "id": "C8eFDsEI6Zxk" }, "source": [ "To load a dataset from a pandas dataframe, we will use the load_from_df() method, we will also need a Reader object, and the rating_scale parameter must be specified. The dataframe must have three columns, corresponding to the user ids, the item ids, and the ratings in this order. Each row thus corresponds to a given rating." ] }, { "cell_type": "code", "metadata": { "id": "WX7-al0g3PCF" }, "source": [ "reader = Reader(rating_scale=(1, 5))\n", "data = Dataset.load_from_df(df_new[['userID', 'item', 'rating']], reader)" ], "execution_count": null, "outputs": [] }, { "cell_type": "markdown", "metadata": { "id": "1BKNsZL_6ttL" }, "source": [ "### Basic algorithms\n", "\n", "With the Surprise library, we will benchmark the following algorithms\n" ] }, { "cell_type": "markdown", "metadata": { "id": "us5FjYjd7Vls" }, "source": [ "\n", "#### NormalPredictor\n", "\n", "* NormalPredictor algorithm predicts a random rating based on the distribution of the training set, which is assumed to be normal. This is one of the most basic algorithms that do not do much work.\n", "\n", "#### BaselineOnly\n", "\n", "* BasiclineOnly algorithm predicts the baseline estimate for given user and item.\n", "\n", "### k-NN algorithms\n", "\n", "#### KNNBasic\n", "\n", "* KNNBasic is a basic collaborative filtering algorithm.\n", "\n", "#### KNNWithMeans\n", "\n", "* KNNWithMeans is basic collaborative filtering algorithm, taking into account the mean ratings of each user.\n", "\n", "#### KNNWithZScore\n", "\n", "* KNNWithZScore is a basic collaborative filtering algorithm, taking into account the z-score normalization of each user.\n", "\n", "#### KNNBaseline\n", "\n", "* KNNBaseline is a basic collaborative filtering algorithm taking into account a baseline rating.\n", "\n", "### Matrix Factorization-based algorithms\n", "\n", "#### SVD\n", "\n", "* SVD algorithm is equivalent to Probabilistic Matrix Factorization (http://papers.nips.cc/paper/3208-probabilistic-matrix-factorization.pdf)\n", "\n", "#### SVDpp\n", "\n", "* The SVDpp algorithm is an extension of SVD that takes into account implicit ratings.\n", "\n", "#### NMF\n", "\n", "* NMF is a collaborative filtering algorithm based on Non-negative Matrix Factorization. It is very similar with SVD.\n", "\n", "### Slope One\n", "\n", "* Slope One is a straightforward implementation of the SlopeOne algorithm. (https://arxiv.org/abs/cs/0702144)\n", "\n", "### Co-clustering\n", "\n", "* Co-clustering is a collaborative filtering algorithm based on co-clustering (http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.113.6458&rep=rep1&type=pdf)\n", "\n", "\n", "We use rmse as our accuracy metric for the predictions." ] }, { "cell_type": "code", "metadata": { "id": "GuJyfbZc6miT", "outputId": "73fb3bd3-bcc2-4130-9d56-041616dad525", "colab": { "base_uri": "https://localhost:8080/", "height": 1000 } }, "source": [ "benchmark = []\n", "# Iterate over all algorithms\n", "\n", "algorithms = [SVD(), SVDpp(), SlopeOne(), NMF(), NormalPredictor(), KNNBaseline(), KNNBasic(), KNNWithMeans(), KNNWithZScore(), BaselineOnly(), CoClustering()]\n", "\n", "print (\"Attempting: \", str(algorithms), '\\n\\n\\n')\n", "\n", "for algorithm in algorithms:\n", " print(\"Starting: \" ,str(algorithm))\n", " # Perform cross validation\n", " results = cross_validate(algorithm, data, measures=['RMSE'], cv=3, verbose=False)\n", " # results = cross_validate(algorithm, data, measures=['RMSE','MAE'], cv=3, verbose=False)\n", " \n", " # Get results & append algorithm name\n", " tmp = pd.DataFrame.from_dict(results).mean(axis=0)\n", " tmp = tmp.append(pd.Series([str(algorithm).split(' ')[0].split('.')[-1]], index=['Algorithm']))\n", " benchmark.append(tmp)\n", " print(\"Done: \" ,str(algorithm), \"\\n\\n\")\n", "\n", "print ('\\n\\tDONE\\n')" ], "execution_count": null, "outputs": [ { "output_type": "stream", "text": [ "Attempting: [, , , , , , , , , , ] \n", "\n", "\n", "\n", "Starting: \n", "Done: \n", "\n", "\n", "Starting: \n", "Done: \n", "\n", "\n", "Starting: \n", "Done: \n", "\n", "\n", "Starting: \n", "Done: \n", "\n", "\n", "Starting: \n", "Done: \n", "\n", "\n", "Starting: \n", "Estimating biases using als...\n", "Computing the msd similarity matrix...\n", "Done computing similarity matrix.\n", "Estimating biases using als...\n", "Computing the msd similarity matrix...\n", "Done computing similarity matrix.\n", "Estimating biases using als...\n", "Computing the msd similarity matrix...\n", "Done computing similarity matrix.\n", "Done: \n", "\n", "\n", "Starting: \n", "Computing the msd similarity matrix...\n", "Done computing similarity matrix.\n", "Computing the msd similarity matrix...\n", "Done computing similarity matrix.\n", "Computing the msd similarity matrix...\n", "Done computing similarity matrix.\n", "Done: \n", "\n", "\n", "Starting: \n", "Computing the msd similarity matrix...\n", "Done computing similarity matrix.\n", "Computing the msd similarity matrix...\n", "Done computing similarity matrix.\n", "Computing the msd similarity matrix...\n", "Done computing similarity matrix.\n", "Done: \n", "\n", "\n", "Starting: \n", "Computing the msd similarity matrix...\n", "Done computing similarity matrix.\n", "Computing the msd similarity matrix...\n", "Done computing similarity matrix.\n", "Computing the msd similarity matrix...\n", "Done computing similarity matrix.\n", "Done: \n", "\n", "\n", "Starting: \n", "Estimating biases using als...\n", "Estimating biases using als...\n", "Estimating biases using als...\n", "Done: \n", "\n", "\n", "Starting: \n", "Done: \n", "\n", "\n", "\n", "\tDONE\n", "\n" ], "name": "stdout" } ] }, { "cell_type": "code", "metadata": { "id": "FQ-gO0oA7xJs" }, "source": [ "surprise_results = pd.DataFrame(benchmark).set_index('Algorithm').sort_values('test_rmse')" ], "execution_count": null, "outputs": [] }, { "cell_type": "code", "metadata": { "id": "VMoYn_xx760o", "outputId": "93691a3a-a704-464c-89b5-e48296a2604f", "colab": { "base_uri": "https://localhost:8080/", "height": 421 } }, "source": [ "surprise_results" ], "execution_count": null, "outputs": [ { "output_type": "execute_result", "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
test_rmsefit_timetest_time
Algorithm
SVDpp0.849133224.42783010.164514
KNNBaseline0.8557280.1981522.959032
BaselineOnly0.8610780.1417930.198635
SVD0.8639733.4709470.207932
KNNWithZScore0.8667930.1426992.660879
KNNWithMeans0.8700650.1013802.389334
SlopeOne0.8727131.3401277.466537
NMF0.9013703.7663730.215193
CoClustering0.9205211.4046560.216376
KNNBasic0.9233320.0888852.163818
NormalPredictor1.4014110.0868560.249340
\n", "
" ], "text/plain": [ " test_rmse fit_time test_time\n", "Algorithm \n", "SVDpp 0.849133 224.427830 10.164514\n", "KNNBaseline 0.855728 0.198152 2.959032\n", "BaselineOnly 0.861078 0.141793 0.198635\n", "SVD 0.863973 3.470947 0.207932\n", "KNNWithZScore 0.866793 0.142699 2.660879\n", "KNNWithMeans 0.870065 0.101380 2.389334\n", "SlopeOne 0.872713 1.340127 7.466537\n", "NMF 0.901370 3.766373 0.215193\n", "CoClustering 0.920521 1.404656 0.216376\n", "KNNBasic 0.923332 0.088885 2.163818\n", "NormalPredictor 1.401411 0.086856 0.249340" ] }, "metadata": { "tags": [] }, "execution_count": 20 } ] }, { "cell_type": "markdown", "metadata": { "id": "fCsGGpZKDDRa" }, "source": [ "SVDpp is performing best but it is taking a lot of time so we will use SED instean but apply GridSearch CV." ] }, { "cell_type": "code", "metadata": { "id": "mBTeRS7GDC-D", "outputId": "63f65525-1d79-43d3-f967-231580767b59", "colab": { "base_uri": "https://localhost:8080/", "height": 68 } }, "source": [ "# param_grid = {\n", "# \"n_epochs\": [5, 10, 15, 20, 30, 40, 50, 100],\n", "# \"lr_all\": [0.001, 0.002, 0.005],\n", "# \"reg_all\": [0.02, 0.08, 0.4, 0.6]\n", "# }\n", "\n", "# smaller grid for testing\n", "param_grid = {\n", " \"n_epochs\": [10, 20],\n", " \"lr_all\": [0.002, 0.005],\n", " \"reg_all\": [0.02]\n", "}\n", "gs = GridSearchCV(SVD, param_grid, measures=[\"rmse\", \"mae\"], refit=True, cv=5)\n", "\n", "gs.fit(data)\n", "\n", "training_parameters = gs.best_params[\"rmse\"]\n", "\n", "print(\"BEST RMSE: \\t\", gs.best_score[\"rmse\"])\n", "print(\"BEST MAE: \\t\", gs.best_score[\"mae\"])\n", "print(\"BEST params: \\t\", gs.best_params[\"rmse\"])" ], "execution_count": null, "outputs": [ { "output_type": "stream", "text": [ "BEST RMSE: \t 0.8561578829115689\n", "BEST MAE: \t 0.656644347489449\n", "BEST params: \t {'n_epochs': 20, 'lr_all': 0.005, 'reg_all': 0.02}\n" ], "name": "stdout" } ] }, { "cell_type": "code", "metadata": { "id": "j8BidQh53A8g", "colab": { "base_uri": "https://localhost:8080/", "height": 238 }, "outputId": "03248097-18f8-42c0-f5a4-8464e862a1b6" }, "source": [ "from datetime import datetime\n", "print(training_parameters)\n", "reader = Reader(rating_scale=(1, 5))\n", "\n", "print(\"\\n\\n\\t\\t STARTING\\n\\n\")\n", "start = datetime.now()\n", "\n", "print(\"> Loading data...\")\n", "data = Dataset.load_from_df(df_new[['userID', 'item', 'rating']], reader)\n", "print(\"> OK\")\n", "\n", "print(\"> Creating trainset...\")\n", "trainset = data.build_full_trainset()\n", "print(\"> OK\")\n", "\n", "\n", "startTraining = datetime.now()\n", "print(\"> Training...\")\n", "\n", "algo = SVD(n_epochs = training_parameters['n_epochs'], lr_all = training_parameters['lr_all'], reg_all = training_parameters['reg_all'])\n", "\n", "algo.fit(trainset)\n", "\n", "endTraining = datetime.now()\n", "print(\"> OK \\t\\t It Took: \", (endTraining-startTraining).seconds, \"seconds\")\n", "\n", "end = datetime.now()\n", "print (\">> DONE \\t\\t It Took\", (end-start).seconds, \"seconds\" )" ], "execution_count": null, "outputs": [ { "output_type": "stream", "text": [ "{'n_epochs': 20, 'lr_all': 0.005, 'reg_all': 0.02}\n", "\n", "\n", "\t\t STARTING\n", "\n", "\n", "> Loading data...\n", "> OK\n", "> Creating trainset...\n", "> OK\n", "> Training...\n", "> OK \t\t It Took: 4 seconds\n", ">> DONE \t\t It Took 4 seconds\n" ], "name": "stdout" } ] }, { "cell_type": "code", "metadata": { "id": "lM7Db2cj7-IZ", "outputId": "bc675bc8-555e-4a41-9635-685486607e72", "colab": { "base_uri": "https://localhost:8080/", "height": 68 } }, "source": [ "## SAVING TRAINED MODEL\n", "from surprise import dump\n", "import os\n", "model_filename = \"./model.pickle\"\n", "print (\">> Starting dump\")\n", "# Dump algorithm and reload it.\n", "file_name = os.path.expanduser(model_filename)\n", "dump.dump(file_name, algo=algo)\n", "print (\">> Dump done\")\n", "print(model_filename)" ], "execution_count": null, "outputs": [ { "output_type": "stream", "text": [ ">> Starting dump\n", ">> Dump done\n", "./model.pickle\n" ], "name": "stdout" } ] }, { "cell_type": "code", "metadata": { "id": "oNNXNd7AxnIN" }, "source": [ "## LOAD SAVED MODEL\n", "def load_model(model_filename):\n", " print (\">> Loading dump\")\n", " from surprise import dump\n", " import os\n", " file_name = os.path.expanduser(model_filename)\n", " _, loaded_model = dump.load(file_name)\n", " print (\">> Loaded dump\")\n", " return loaded_model" ], "execution_count": null, "outputs": [] }, { "cell_type": "code", "metadata": { "id": "_zqHKyGm38B4", "colab": { "base_uri": "https://localhost:8080/", "height": 255 }, "outputId": "24f2ae93-1cbb-486a-9d2c-bb4b320ec957" }, "source": [ "# predicitng\n", "from pprint import pprint as pp\n", "model_filename = \"./model.pickle\"\n", "def itemRating(user, item):\n", " uid = str(user)\n", " iid = str(item) \n", " loaded_model = load_model(model_filename)\n", " prediction = loaded_model.predict(user, item, verbose=True)\n", " rating = prediction.est\n", " details = prediction.details\n", " uid = prediction.uid\n", " iid = prediction.iid\n", " true = prediction.r_ui\n", " ret = {\n", " 'user': user, \n", " 'item': item, \n", " 'rating': rating, \n", " 'details': details,\n", " 'uid': uid,\n", " 'iid': iid,\n", " 'true': true\n", " }\n", " pp (ret)\n", " print ('\\n\\n')\n", " return ret\n", "print(itemRating(user = \"610\", item = \"10\"))" ], "execution_count": null, "outputs": [ { "output_type": "stream", "text": [ ">> Loading dump\n", ">> Loaded dump\n", "user: 610 item: 10 r_ui = None est = 3.54 {'was_impossible': False}\n", "{'details': {'was_impossible': False},\n", " 'iid': '10',\n", " 'item': '10',\n", " 'rating': 3.543813091304151,\n", " 'true': None,\n", " 'uid': '610',\n", " 'user': '610'}\n", "\n", "\n", "\n", "{'user': '610', 'item': '10', 'rating': 3.543813091304151, 'details': {'was_impossible': False}, 'uid': '610', 'iid': '10', 'true': None}\n" ], "name": "stdout" } ] } ] }