Last active
March 3, 2022 18:51
-
-
Save uni-3/89ef1999772306213b9038095af80aff to your computer and use it in GitHub Desktop.
implicit.ipynb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"nbformat": 4, | |
"nbformat_minor": 0, | |
"metadata": { | |
"colab": { | |
"name": "implicit.ipynb", | |
"provenance": [], | |
"collapsed_sections": [], | |
"machine_shape": "hm", | |
"authorship_tag": "ABX9TyO6dJ3wucfEJS7xGPVTVM5P", | |
"include_colab_link": true | |
}, | |
"kernelspec": { | |
"name": "python3", | |
"display_name": "Python 3" | |
}, | |
"accelerator": "GPU", | |
"widgets": { | |
"application/vnd.jupyter.widget-state+json": { | |
"f179d940d66440a4b41db41dc3522533": { | |
"model_module": "@jupyter-widgets/controls", | |
"model_name": "HBoxModel", | |
"model_module_version": "1.5.0", | |
"state": { | |
"_view_name": "HBoxView", | |
"_dom_classes": [], | |
"_model_name": "HBoxModel", | |
"_view_module": "@jupyter-widgets/controls", | |
"_model_module_version": "1.5.0", | |
"_view_count": null, | |
"_view_module_version": "1.5.0", | |
"box_style": "", | |
"layout": "IPY_MODEL_92b5d10fa8e8483aa86f82bdf06babbf", | |
"_model_module": "@jupyter-widgets/controls", | |
"children": [ | |
"IPY_MODEL_d599d08b9bcd4b1c80da1d9ee8ca6a03", | |
"IPY_MODEL_4530f88cb56e411d8ce6d2baa02a8628", | |
"IPY_MODEL_63ad7390f5464406bba5ce647cd1740d" | |
] | |
} | |
}, | |
"92b5d10fa8e8483aa86f82bdf06babbf": { | |
"model_module": "@jupyter-widgets/base", | |
"model_name": "LayoutModel", | |
"model_module_version": "1.2.0", | |
"state": { | |
"_view_name": "LayoutView", | |
"grid_template_rows": null, | |
"right": null, | |
"justify_content": null, | |
"_view_module": "@jupyter-widgets/base", | |
"overflow": null, | |
"_model_module_version": "1.2.0", | |
"_view_count": null, | |
"flex_flow": null, | |
"width": null, | |
"min_width": null, | |
"border": null, | |
"align_items": null, | |
"bottom": null, | |
"_model_module": "@jupyter-widgets/base", | |
"top": null, | |
"grid_column": null, | |
"overflow_y": null, | |
"overflow_x": null, | |
"grid_auto_flow": null, | |
"grid_area": null, | |
"grid_template_columns": null, | |
"flex": null, | |
"_model_name": "LayoutModel", | |
"justify_items": null, | |
"grid_row": null, | |
"max_height": null, | |
"align_content": null, | |
"visibility": null, | |
"align_self": null, | |
"height": null, | |
"min_height": null, | |
"padding": null, | |
"grid_auto_rows": null, | |
"grid_gap": null, | |
"max_width": null, | |
"order": null, | |
"_view_module_version": "1.2.0", | |
"grid_template_areas": null, | |
"object_position": null, | |
"object_fit": null, | |
"grid_auto_columns": null, | |
"margin": null, | |
"display": null, | |
"left": null | |
} | |
}, | |
"d599d08b9bcd4b1c80da1d9ee8ca6a03": { | |
"model_module": "@jupyter-widgets/controls", | |
"model_name": "HTMLModel", | |
"model_module_version": "1.5.0", | |
"state": { | |
"_view_name": "HTMLView", | |
"style": "IPY_MODEL_8595e340cef645bb98ce663f6575ee29", | |
"_dom_classes": [], | |
"description": "", | |
"_model_name": "HTMLModel", | |
"placeholder": "", | |
"_view_module": "@jupyter-widgets/controls", | |
"_model_module_version": "1.5.0", | |
"value": "", | |
"_view_count": null, | |
"_view_module_version": "1.5.0", | |
"description_tooltip": null, | |
"_model_module": "@jupyter-widgets/controls", | |
"layout": "IPY_MODEL_b80b46057ff14e9186200853d053720d" | |
} | |
}, | |
"4530f88cb56e411d8ce6d2baa02a8628": { | |
"model_module": "@jupyter-widgets/controls", | |
"model_name": "FloatProgressModel", | |
"model_module_version": "1.5.0", | |
"state": { | |
"_view_name": "ProgressView", | |
"style": "IPY_MODEL_10e5c791c5ed42e58fc014a82a993803", | |
"_dom_classes": [], | |
"description": "", | |
"_model_name": "FloatProgressModel", | |
"bar_style": "success", | |
"max": 1, | |
"_view_module": "@jupyter-widgets/controls", | |
"_model_module_version": "1.5.0", | |
"value": 1, | |
"_view_count": null, | |
"_view_module_version": "1.5.0", | |
"orientation": "horizontal", | |
"min": 0, | |
"description_tooltip": null, | |
"_model_module": "@jupyter-widgets/controls", | |
"layout": "IPY_MODEL_e9f455650d8c4e0cbe68c2cc3518cf9b" | |
} | |
}, | |
"63ad7390f5464406bba5ce647cd1740d": { | |
"model_module": "@jupyter-widgets/controls", | |
"model_name": "HTMLModel", | |
"model_module_version": "1.5.0", | |
"state": { | |
"_view_name": "HTMLView", | |
"style": "IPY_MODEL_ff0cba985e8a4b7b9881ddad501913e3", | |
"_dom_classes": [], | |
"description": "", | |
"_model_name": "HTMLModel", | |
"placeholder": "", | |
"_view_module": "@jupyter-widgets/controls", | |
"_model_module_version": "1.5.0", | |
"value": " 184M/? [00:10<00:00, 13.4MB/s]", | |
"_view_count": null, | |
"_view_module_version": "1.5.0", | |
"description_tooltip": null, | |
"_model_module": "@jupyter-widgets/controls", | |
"layout": "IPY_MODEL_c14eca439c1d4e5ab0ce231ba1a101ca" | |
} | |
}, | |
"8595e340cef645bb98ce663f6575ee29": { | |
"model_module": "@jupyter-widgets/controls", | |
"model_name": "DescriptionStyleModel", | |
"model_module_version": "1.5.0", | |
"state": { | |
"_view_name": "StyleView", | |
"_model_name": "DescriptionStyleModel", | |
"description_width": "", | |
"_view_module": "@jupyter-widgets/base", | |
"_model_module_version": "1.5.0", | |
"_view_count": null, | |
"_view_module_version": "1.2.0", | |
"_model_module": "@jupyter-widgets/controls" | |
} | |
}, | |
"b80b46057ff14e9186200853d053720d": { | |
"model_module": "@jupyter-widgets/base", | |
"model_name": "LayoutModel", | |
"model_module_version": "1.2.0", | |
"state": { | |
"_view_name": "LayoutView", | |
"grid_template_rows": null, | |
"right": null, | |
"justify_content": null, | |
"_view_module": "@jupyter-widgets/base", | |
"overflow": null, | |
"_model_module_version": "1.2.0", | |
"_view_count": null, | |
"flex_flow": null, | |
"width": null, | |
"min_width": null, | |
"border": null, | |
"align_items": null, | |
"bottom": null, | |
"_model_module": "@jupyter-widgets/base", | |
"top": null, | |
"grid_column": null, | |
"overflow_y": null, | |
"overflow_x": null, | |
"grid_auto_flow": null, | |
"grid_area": null, | |
"grid_template_columns": null, | |
"flex": null, | |
"_model_name": "LayoutModel", | |
"justify_items": null, | |
"grid_row": null, | |
"max_height": null, | |
"align_content": null, | |
"visibility": null, | |
"align_self": null, | |
"height": null, | |
"min_height": null, | |
"padding": null, | |
"grid_auto_rows": null, | |
"grid_gap": null, | |
"max_width": null, | |
"order": null, | |
"_view_module_version": "1.2.0", | |
"grid_template_areas": null, | |
"object_position": null, | |
"object_fit": null, | |
"grid_auto_columns": null, | |
"margin": null, | |
"display": null, | |
"left": null | |
} | |
}, | |
"10e5c791c5ed42e58fc014a82a993803": { | |
"model_module": "@jupyter-widgets/controls", | |
"model_name": "ProgressStyleModel", | |
"model_module_version": "1.5.0", | |
"state": { | |
"_view_name": "StyleView", | |
"_model_name": "ProgressStyleModel", | |
"description_width": "", | |
"_view_module": "@jupyter-widgets/base", | |
"_model_module_version": "1.5.0", | |
"_view_count": null, | |
"_view_module_version": "1.2.0", | |
"bar_color": null, | |
"_model_module": "@jupyter-widgets/controls" | |
} | |
}, | |
"e9f455650d8c4e0cbe68c2cc3518cf9b": { | |
"model_module": "@jupyter-widgets/base", | |
"model_name": "LayoutModel", | |
"model_module_version": "1.2.0", | |
"state": { | |
"_view_name": "LayoutView", | |
"grid_template_rows": null, | |
"right": null, | |
"justify_content": null, | |
"_view_module": "@jupyter-widgets/base", | |
"overflow": null, | |
"_model_module_version": "1.2.0", | |
"_view_count": null, | |
"flex_flow": null, | |
"width": "20px", | |
"min_width": null, | |
"border": null, | |
"align_items": null, | |
"bottom": null, | |
"_model_module": "@jupyter-widgets/base", | |
"top": null, | |
"grid_column": null, | |
"overflow_y": null, | |
"overflow_x": null, | |
"grid_auto_flow": null, | |
"grid_area": null, | |
"grid_template_columns": null, | |
"flex": null, | |
"_model_name": "LayoutModel", | |
"justify_items": null, | |
"grid_row": null, | |
"max_height": null, | |
"align_content": null, | |
"visibility": null, | |
"align_self": null, | |
"height": null, | |
"min_height": null, | |
"padding": null, | |
"grid_auto_rows": null, | |
"grid_gap": null, | |
"max_width": null, | |
"order": null, | |
"_view_module_version": "1.2.0", | |
"grid_template_areas": null, | |
"object_position": null, | |
"object_fit": null, | |
"grid_auto_columns": null, | |
"margin": null, | |
"display": null, | |
"left": null | |
} | |
}, | |
"ff0cba985e8a4b7b9881ddad501913e3": { | |
"model_module": "@jupyter-widgets/controls", | |
"model_name": "DescriptionStyleModel", | |
"model_module_version": "1.5.0", | |
"state": { | |
"_view_name": "StyleView", | |
"_model_name": "DescriptionStyleModel", | |
"description_width": "", | |
"_view_module": "@jupyter-widgets/base", | |
"_model_module_version": "1.5.0", | |
"_view_count": null, | |
"_view_module_version": "1.2.0", | |
"_model_module": "@jupyter-widgets/controls" | |
} | |
}, | |
"c14eca439c1d4e5ab0ce231ba1a101ca": { | |
"model_module": "@jupyter-widgets/base", | |
"model_name": "LayoutModel", | |
"model_module_version": "1.2.0", | |
"state": { | |
"_view_name": "LayoutView", | |
"grid_template_rows": null, | |
"right": null, | |
"justify_content": null, | |
"_view_module": "@jupyter-widgets/base", | |
"overflow": null, | |
"_model_module_version": "1.2.0", | |
"_view_count": null, | |
"flex_flow": null, | |
"width": null, | |
"min_width": null, | |
"border": null, | |
"align_items": null, | |
"bottom": null, | |
"_model_module": "@jupyter-widgets/base", | |
"top": null, | |
"grid_column": null, | |
"overflow_y": null, | |
"overflow_x": null, | |
"grid_auto_flow": null, | |
"grid_area": null, | |
"grid_template_columns": null, | |
"flex": null, | |
"_model_name": "LayoutModel", | |
"justify_items": null, | |
"grid_row": null, | |
"max_height": null, | |
"align_content": null, | |
"visibility": null, | |
"align_self": null, | |
"height": null, | |
"min_height": null, | |
"padding": null, | |
"grid_auto_rows": null, | |
"grid_gap": null, | |
"max_width": null, | |
"order": null, | |
"_view_module_version": "1.2.0", | |
"grid_template_areas": null, | |
"object_position": null, | |
"object_fit": null, | |
"grid_auto_columns": null, | |
"margin": null, | |
"display": null, | |
"left": null | |
} | |
}, | |
"202ee6bed0b04b159b5409abfcef971e": { | |
"model_module": "@jupyter-widgets/controls", | |
"model_name": "HBoxModel", | |
"model_module_version": "1.5.0", | |
"state": { | |
"_view_name": "HBoxView", | |
"_dom_classes": [], | |
"_model_name": "HBoxModel", | |
"_view_module": "@jupyter-widgets/controls", | |
"_model_module_version": "1.5.0", | |
"_view_count": null, | |
"_view_module_version": "1.5.0", | |
"box_style": "", | |
"layout": "IPY_MODEL_ad40114298d94a4b96bcab26cc801fc8", | |
"_model_module": "@jupyter-widgets/controls", | |
"children": [ | |
"IPY_MODEL_6b5dbaaf87f043bf8568d1c2e9b541b5", | |
"IPY_MODEL_24a80c1141ab4c008497bc770dc89b7a", | |
"IPY_MODEL_2d6bfbbb564a4420a0506b9f91646838" | |
] | |
} | |
}, | |
"ad40114298d94a4b96bcab26cc801fc8": { | |
"model_module": "@jupyter-widgets/base", | |
"model_name": "LayoutModel", | |
"model_module_version": "1.2.0", | |
"state": { | |
"_view_name": "LayoutView", | |
"grid_template_rows": null, | |
"right": null, | |
"justify_content": null, | |
"_view_module": "@jupyter-widgets/base", | |
"overflow": null, | |
"_model_module_version": "1.2.0", | |
"_view_count": null, | |
"flex_flow": null, | |
"width": null, | |
"min_width": null, | |
"border": null, | |
"align_items": null, | |
"bottom": null, | |
"_model_module": "@jupyter-widgets/base", | |
"top": null, | |
"grid_column": null, | |
"overflow_y": null, | |
"overflow_x": null, | |
"grid_auto_flow": null, | |
"grid_area": null, | |
"grid_template_columns": null, | |
"flex": null, | |
"_model_name": "LayoutModel", | |
"justify_items": null, | |
"grid_row": null, | |
"max_height": null, | |
"align_content": null, | |
"visibility": null, | |
"align_self": null, | |
"height": null, | |
"min_height": null, | |
"padding": null, | |
"grid_auto_rows": null, | |
"grid_gap": null, | |
"max_width": null, | |
"order": null, | |
"_view_module_version": "1.2.0", | |
"grid_template_areas": null, | |
"object_position": null, | |
"object_fit": null, | |
"grid_auto_columns": null, | |
"margin": null, | |
"display": null, | |
"left": null | |
} | |
}, | |
"6b5dbaaf87f043bf8568d1c2e9b541b5": { | |
"model_module": "@jupyter-widgets/controls", | |
"model_name": "HTMLModel", | |
"model_module_version": "1.5.0", | |
"state": { | |
"_view_name": "HTMLView", | |
"style": "IPY_MODEL_c383fd6d9c694c4f8832c39e84731cc3", | |
"_dom_classes": [], | |
"description": "", | |
"_model_name": "HTMLModel", | |
"placeholder": "", | |
"_view_module": "@jupyter-widgets/controls", | |
"_model_module_version": "1.5.0", | |
"value": "100%", | |
"_view_count": null, | |
"_view_module_version": "1.5.0", | |
"description_tooltip": null, | |
"_model_module": "@jupyter-widgets/controls", | |
"layout": "IPY_MODEL_e56819fda3b3405aacb81d614c590997" | |
} | |
}, | |
"24a80c1141ab4c008497bc770dc89b7a": { | |
"model_module": "@jupyter-widgets/controls", | |
"model_name": "FloatProgressModel", | |
"model_module_version": "1.5.0", | |
"state": { | |
"_view_name": "ProgressView", | |
"style": "IPY_MODEL_63cc51d7d5564c6db6ddd8d904026832", | |
"_dom_classes": [], | |
"description": "", | |
"_model_name": "FloatProgressModel", | |
"bar_style": "success", | |
"max": 25, | |
"_view_module": "@jupyter-widgets/controls", | |
"_model_module_version": "1.5.0", | |
"value": 25, | |
"_view_count": null, | |
"_view_module_version": "1.5.0", | |
"orientation": "horizontal", | |
"min": 0, | |
"description_tooltip": null, | |
"_model_module": "@jupyter-widgets/controls", | |
"layout": "IPY_MODEL_c92f7e3267384faf9386bb34ed03b0db" | |
} | |
}, | |
"2d6bfbbb564a4420a0506b9f91646838": { | |
"model_module": "@jupyter-widgets/controls", | |
"model_name": "HTMLModel", | |
"model_module_version": "1.5.0", | |
"state": { | |
"_view_name": "HTMLView", | |
"style": "IPY_MODEL_20c22fa7c572427abcdead4be262a3ff", | |
"_dom_classes": [], | |
"description": "", | |
"_model_name": "HTMLModel", | |
"placeholder": "", | |
"_view_module": "@jupyter-widgets/controls", | |
"_model_module_version": "1.5.0", | |
"value": " 25/25 [00:45<00:00, 1.80s/it]", | |
"_view_count": null, | |
"_view_module_version": "1.5.0", | |
"description_tooltip": null, | |
"_model_module": "@jupyter-widgets/controls", | |
"layout": "IPY_MODEL_b1a9193d59a44e24a4edecbcfcc31554" | |
} | |
}, | |
"c383fd6d9c694c4f8832c39e84731cc3": { | |
"model_module": "@jupyter-widgets/controls", | |
"model_name": "DescriptionStyleModel", | |
"model_module_version": "1.5.0", | |
"state": { | |
"_view_name": "StyleView", | |
"_model_name": "DescriptionStyleModel", | |
"description_width": "", | |
"_view_module": "@jupyter-widgets/base", | |
"_model_module_version": "1.5.0", | |
"_view_count": null, | |
"_view_module_version": "1.2.0", | |
"_model_module": "@jupyter-widgets/controls" | |
} | |
}, | |
"e56819fda3b3405aacb81d614c590997": { | |
"model_module": "@jupyter-widgets/base", | |
"model_name": "LayoutModel", | |
"model_module_version": "1.2.0", | |
"state": { | |
"_view_name": "LayoutView", | |
"grid_template_rows": null, | |
"right": null, | |
"justify_content": null, | |
"_view_module": "@jupyter-widgets/base", | |
"overflow": null, | |
"_model_module_version": "1.2.0", | |
"_view_count": null, | |
"flex_flow": null, | |
"width": null, | |
"min_width": null, | |
"border": null, | |
"align_items": null, | |
"bottom": null, | |
"_model_module": "@jupyter-widgets/base", | |
"top": null, | |
"grid_column": null, | |
"overflow_y": null, | |
"overflow_x": null, | |
"grid_auto_flow": null, | |
"grid_area": null, | |
"grid_template_columns": null, | |
"flex": null, | |
"_model_name": "LayoutModel", | |
"justify_items": null, | |
"grid_row": null, | |
"max_height": null, | |
"align_content": null, | |
"visibility": null, | |
"align_self": null, | |
"height": null, | |
"min_height": null, | |
"padding": null, | |
"grid_auto_rows": null, | |
"grid_gap": null, | |
"max_width": null, | |
"order": null, | |
"_view_module_version": "1.2.0", | |
"grid_template_areas": null, | |
"object_position": null, | |
"object_fit": null, | |
"grid_auto_columns": null, | |
"margin": null, | |
"display": null, | |
"left": null | |
} | |
}, | |
"63cc51d7d5564c6db6ddd8d904026832": { | |
"model_module": "@jupyter-widgets/controls", | |
"model_name": "ProgressStyleModel", | |
"model_module_version": "1.5.0", | |
"state": { | |
"_view_name": "StyleView", | |
"_model_name": "ProgressStyleModel", | |
"description_width": "", | |
"_view_module": "@jupyter-widgets/base", | |
"_model_module_version": "1.5.0", | |
"_view_count": null, | |
"_view_module_version": "1.2.0", | |
"bar_color": null, | |
"_model_module": "@jupyter-widgets/controls" | |
} | |
}, | |
"c92f7e3267384faf9386bb34ed03b0db": { | |
"model_module": "@jupyter-widgets/base", | |
"model_name": "LayoutModel", | |
"model_module_version": "1.2.0", | |
"state": { | |
"_view_name": "LayoutView", | |
"grid_template_rows": null, | |
"right": null, | |
"justify_content": null, | |
"_view_module": "@jupyter-widgets/base", | |
"overflow": null, | |
"_model_module_version": "1.2.0", | |
"_view_count": null, | |
"flex_flow": null, | |
"width": null, | |
"min_width": null, | |
"border": null, | |
"align_items": null, | |
"bottom": null, | |
"_model_module": "@jupyter-widgets/base", | |
"top": null, | |
"grid_column": null, | |
"overflow_y": null, | |
"overflow_x": null, | |
"grid_auto_flow": null, | |
"grid_area": null, | |
"grid_template_columns": null, | |
"flex": null, | |
"_model_name": "LayoutModel", | |
"justify_items": null, | |
"grid_row": null, | |
"max_height": null, | |
"align_content": null, | |
"visibility": null, | |
"align_self": null, | |
"height": null, | |
"min_height": null, | |
"padding": null, | |
"grid_auto_rows": null, | |
"grid_gap": null, | |
"max_width": null, | |
"order": null, | |
"_view_module_version": "1.2.0", | |
"grid_template_areas": null, | |
"object_position": null, | |
"object_fit": null, | |
"grid_auto_columns": null, | |
"margin": null, | |
"display": null, | |
"left": null | |
} | |
}, | |
"20c22fa7c572427abcdead4be262a3ff": { | |
"model_module": "@jupyter-widgets/controls", | |
"model_name": "DescriptionStyleModel", | |
"model_module_version": "1.5.0", | |
"state": { | |
"_view_name": "StyleView", | |
"_model_name": "DescriptionStyleModel", | |
"description_width": "", | |
"_view_module": "@jupyter-widgets/base", | |
"_model_module_version": "1.5.0", | |
"_view_count": null, | |
"_view_module_version": "1.2.0", | |
"_model_module": "@jupyter-widgets/controls" | |
} | |
}, | |
"b1a9193d59a44e24a4edecbcfcc31554": { | |
"model_module": "@jupyter-widgets/base", | |
"model_name": "LayoutModel", | |
"model_module_version": "1.2.0", | |
"state": { | |
"_view_name": "LayoutView", | |
"grid_template_rows": null, | |
"right": null, | |
"justify_content": null, | |
"_view_module": "@jupyter-widgets/base", | |
"overflow": null, | |
"_model_module_version": "1.2.0", | |
"_view_count": null, | |
"flex_flow": null, | |
"width": null, | |
"min_width": null, | |
"border": null, | |
"align_items": null, | |
"bottom": null, | |
"_model_module": "@jupyter-widgets/base", | |
"top": null, | |
"grid_column": null, | |
"overflow_y": null, | |
"overflow_x": null, | |
"grid_auto_flow": null, | |
"grid_area": null, | |
"grid_template_columns": null, | |
"flex": null, | |
"_model_name": "LayoutModel", | |
"justify_items": null, | |
"grid_row": null, | |
"max_height": null, | |
"align_content": null, | |
"visibility": null, | |
"align_self": null, | |
"height": null, | |
"min_height": null, | |
"padding": null, | |
"grid_auto_rows": null, | |
"grid_gap": null, | |
"max_width": null, | |
"order": null, | |
"_view_module_version": "1.2.0", | |
"grid_template_areas": null, | |
"object_position": null, | |
"object_fit": null, | |
"grid_auto_columns": null, | |
"margin": null, | |
"display": null, | |
"left": null | |
} | |
} | |
} | |
} | |
}, | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"id": "view-in-github", | |
"colab_type": "text" | |
}, | |
"source": [ | |
"<a href=\"https://colab.research.google.com/gist/uni-3/89ef1999772306213b9038095af80aff/implicit.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"id": "SE9BsXJ1JIsH" | |
}, | |
"source": [ | |
"https://github.com/benfred/implicit/blob/master/examples/lastfm.py" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "R9AmX4s4BqhG", | |
"colab": { | |
"base_uri": "https://localhost:8080/" | |
}, | |
"outputId": "6a1b1295-e47c-48f5-c5f1-ea08adc5e6ed" | |
}, | |
"source": [ | |
"!pip install implicit" | |
], | |
"execution_count": 1, | |
"outputs": [ | |
{ | |
"output_type": "stream", | |
"name": "stdout", | |
"text": [ | |
"Collecting implicit\n", | |
" Downloading implicit-0.5.2-cp37-cp37m-manylinux2014_x86_64.whl (18.5 MB)\n", | |
"\u001b[K |████████████████████████████████| 18.5 MB 1.3 MB/s \n", | |
"\u001b[?25hRequirement already satisfied: numpy in /usr/local/lib/python3.7/dist-packages (from implicit) (1.21.5)\n", | |
"Requirement already satisfied: tqdm>=4.27 in /usr/local/lib/python3.7/dist-packages (from implicit) (4.63.0)\n", | |
"Requirement already satisfied: scipy>=0.16 in /usr/local/lib/python3.7/dist-packages (from implicit) (1.4.1)\n", | |
"Installing collected packages: implicit\n", | |
"Successfully installed implicit-0.5.2\n" | |
] | |
} | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "fsyifWCQCK1W" | |
}, | |
"source": [ | |
"import pandas as pd\n", | |
"import numpy as np\n", | |
"import implicit\n", | |
"import scipy" | |
], | |
"execution_count": 2, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "yagthZstCSs_", | |
"colab": { | |
"base_uri": "https://localhost:8080/", | |
"height": 49, | |
"referenced_widgets": [ | |
"f179d940d66440a4b41db41dc3522533", | |
"92b5d10fa8e8483aa86f82bdf06babbf", | |
"d599d08b9bcd4b1c80da1d9ee8ca6a03", | |
"4530f88cb56e411d8ce6d2baa02a8628", | |
"63ad7390f5464406bba5ce647cd1740d", | |
"8595e340cef645bb98ce663f6575ee29", | |
"b80b46057ff14e9186200853d053720d", | |
"10e5c791c5ed42e58fc014a82a993803", | |
"e9f455650d8c4e0cbe68c2cc3518cf9b", | |
"ff0cba985e8a4b7b9881ddad501913e3", | |
"c14eca439c1d4e5ab0ce231ba1a101ca" | |
] | |
}, | |
"outputId": "0ec18b2d-6676-4362-aceb-85f792a8aad5" | |
}, | |
"source": [ | |
"from implicit.datasets.lastfm import get_lastfm\n", | |
"artists, users, plays = get_lastfm()" | |
], | |
"execution_count": 3, | |
"outputs": [ | |
{ | |
"output_type": "display_data", | |
"data": { | |
"application/vnd.jupyter.widget-view+json": { | |
"model_id": "f179d940d66440a4b41db41dc3522533", | |
"version_minor": 0, | |
"version_major": 2 | |
}, | |
"text/plain": [ | |
"0.00B [00:00, ?B/s]" | |
] | |
}, | |
"metadata": {} | |
} | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "XSh4wSLJEgan", | |
"colab": { | |
"base_uri": "https://localhost:8080/", | |
"height": 49, | |
"referenced_widgets": [ | |
"202ee6bed0b04b159b5409abfcef971e", | |
"ad40114298d94a4b96bcab26cc801fc8", | |
"6b5dbaaf87f043bf8568d1c2e9b541b5", | |
"24a80c1141ab4c008497bc770dc89b7a", | |
"2d6bfbbb564a4420a0506b9f91646838", | |
"c383fd6d9c694c4f8832c39e84731cc3", | |
"e56819fda3b3405aacb81d614c590997", | |
"63cc51d7d5564c6db6ddd8d904026832", | |
"c92f7e3267384faf9386bb34ed03b0db", | |
"20c22fa7c572427abcdead4be262a3ff", | |
"b1a9193d59a44e24a4edecbcfcc31554" | |
] | |
}, | |
"outputId": "28e479bd-4740-4e87-926e-0ec2b0ca82f8" | |
}, | |
"source": [ | |
"model = implicit.als.AlternatingLeastSquares(factors=50,\n", | |
" regularization=0.01,\n", | |
" iterations=25)\n", | |
"model.fit(plays)" | |
], | |
"execution_count": 49, | |
"outputs": [ | |
{ | |
"output_type": "display_data", | |
"data": { | |
"application/vnd.jupyter.widget-view+json": { | |
"model_id": "202ee6bed0b04b159b5409abfcef971e", | |
"version_minor": 0, | |
"version_major": 2 | |
}, | |
"text/plain": [ | |
" 0%| | 0/25 [00:00<?, ?it/s]" | |
] | |
}, | |
"metadata": {} | |
} | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"source": [ | |
"import tqdm\n", | |
"user_items = plays.T.tocsr()\n", | |
"with tqdm.tqdm(total=len(users[:5])) as progress:\n", | |
" for userid, username in enumerate(users[:5]):\n", | |
" artistids, scores = model.recommend(userid, user_items[userid], filter_already_liked_items=True)\n", | |
" for artistid, score in zip(artistids, scores):\n", | |
" if len(artists) < artistid:\n", | |
" continue\n", | |
" print((\"%s\\t%s\\t%s\\n\" % (username, artists[artistid], score)))\n", | |
" progress.update(1)" | |
], | |
"metadata": { | |
"colab": { | |
"base_uri": "https://localhost:8080/" | |
}, | |
"id": "K6OGVOyZE_8E", | |
"outputId": "abab2f84-85f3-437f-c2ba-341a3edb0a95" | |
}, | |
"execution_count": 50, | |
"outputs": [ | |
{ | |
"output_type": "stream", | |
"name": "stderr", | |
"text": [ | |
"44it [00:00, 1810.44it/s] " | |
] | |
}, | |
{ | |
"output_type": "stream", | |
"name": "stdout", | |
"text": [ | |
"00000c289a1829a808ac09c00daf10bc3c4e223b\tsilly wizard\t0.32093942\n", | |
"\n", | |
"00000c289a1829a808ac09c00daf10bc3c4e223b\tbmc & l'assemblée\t0.3008999\n", | |
"\n", | |
"00000c289a1829a808ac09c00daf10bc3c4e223b\t@unbekannt (extreme g)\t0.27779818\n", | |
"\n", | |
"00000c289a1829a808ac09c00daf10bc3c4e223b\tpearson dunn strings orchestra\t0.2701014\n", | |
"\n", | |
"00000c289a1829a808ac09c00daf10bc3c4e223b\twilliam grant still\t0.25775927\n", | |
"\n", | |
"00000c289a1829a808ac09c00daf10bc3c4e223b\tthe gibson bros.\t0.25568268\n", | |
"\n", | |
"00000c289a1829a808ac09c00daf10bc3c4e223b\tnora below\t0.2555275\n", | |
"\n", | |
"00000c289a1829a808ac09c00daf10bc3c4e223b\tcorpus vile\t0.24885125\n", | |
"\n", | |
"00000c289a1829a808ac09c00daf10bc3c4e223b\tprima j\t0.24642985\n", | |
"\n", | |
"00001411dc427966b17297bf4d69e7e193135d89\tmixed by bong-ra\t0.002320768\n", | |
"\n", | |
"00001411dc427966b17297bf4d69e7e193135d89\tandré galluzzi\t0.0022442508\n", | |
"\n", | |
"00001411dc427966b17297bf4d69e7e193135d89\tfire bomber american\t0.0021687988\n", | |
"\n", | |
"00001411dc427966b17297bf4d69e7e193135d89\tlauren harris\t0.0021116708\n", | |
"\n", | |
"00001411dc427966b17297bf4d69e7e193135d89\tahp\t0.002070656\n", | |
"\n", | |
"00001411dc427966b17297bf4d69e7e193135d89\tpirron & knapp\t0.002061388\n", | |
"\n", | |
"00001411dc427966b17297bf4d69e7e193135d89\tluiz arruda paez\t0.0020361017\n", | |
"\n", | |
"00001411dc427966b17297bf4d69e7e193135d89\talka yagnik; amit kumar; kavita krishnamurthy; sonu nigam; sunidhi chauhan; udit narayan\t0.0020130437\n", | |
"\n", | |
"00001411dc427966b17297bf4d69e7e193135d89\tmimi ibarra\t0.0020004525\n", | |
"\n", | |
"00004d2ac9316e22dc007ab2243d6fcb239e707d\tאדיר אוחיון\t0.01643908\n", | |
"\n", | |
"00004d2ac9316e22dc007ab2243d6fcb239e707d\tadam harasiwicz\t0.014793498\n", | |
"\n", | |
"00004d2ac9316e22dc007ab2243d6fcb239e707d\tcovers i\t0.014467024\n", | |
"\n", | |
"00004d2ac9316e22dc007ab2243d6fcb239e707d\tcasino shanghai\t0.014415927\n", | |
"\n", | |
"00004d2ac9316e22dc007ab2243d6fcb239e707d\there are the facts you requested\t0.014056971\n", | |
"\n", | |
"00004d2ac9316e22dc007ab2243d6fcb239e707d\tâľ„ÃÀ\t0.0140068885\n", | |
"\n", | |
"00004d2ac9316e22dc007ab2243d6fcb239e707d\tahmet yildirim\t0.013593333\n", | |
"\n", | |
"00004d2ac9316e22dc007ab2243d6fcb239e707d\tfusio quartet\t0.013570644\n", | |
"\n", | |
"00004d2ac9316e22dc007ab2243d6fcb239e707d\ts.w.\t0.013510642\n", | |
"\n", | |
"00004d2ac9316e22dc007ab2243d6fcb239e707d\tmcnamara\t0.0134634925\n", | |
"\n", | |
"000063d3fe1cf2ba248b9e3c3f0334845a27a6bf\t'09$\t0.0018271955\n", | |
"\n", | |
"000063d3fe1cf2ba248b9e3c3f0334845a27a6bf\tarkaic\t0.0018102586\n", | |
"\n", | |
"000063d3fe1cf2ba248b9e3c3f0334845a27a6bf\tnihil fist\t0.0017790272\n", | |
"\n", | |
"000063d3fe1cf2ba248b9e3c3f0334845a27a6bf\tinmemory\t0.001728881\n", | |
"\n", | |
"000063d3fe1cf2ba248b9e3c3f0334845a27a6bf\taeronaut\t0.0016901582\n", | |
"\n", | |
"000063d3fe1cf2ba248b9e3c3f0334845a27a6bf\tno idea ?\t0.0016497249\n", | |
"\n", | |
"000063d3fe1cf2ba248b9e3c3f0334845a27a6bf\tbarefoot walker\t0.0016180675\n", | |
"\n", | |
"00007a47085b9aab8af55f52ec8846ac479ac4fe\tПроект БИ-2\t0.00072488165\n", | |
"\n", | |
"00007a47085b9aab8af55f52ec8846ac479ac4fe\tdan turéll\t0.0005463393\n", | |
"\n", | |
"00007a47085b9aab8af55f52ec8846ac479ac4fe\tensemble romula larrea & veronica larc\t0.00054521876\n", | |
"\n", | |
"00007a47085b9aab8af55f52ec8846ac479ac4fe\tmisha segal\t0.00049472187\n", | |
"\n", | |
"00007a47085b9aab8af55f52ec8846ac479ac4fe\tgod among insects\t0.00048513158\n", | |
"\n", | |
"00007a47085b9aab8af55f52ec8846ac479ac4fe\totra puse\t0.00047571148\n", | |
"\n", | |
"00007a47085b9aab8af55f52ec8846ac479ac4fe\tpyroclastic\t0.00047549844\n", | |
"\n", | |
"00007a47085b9aab8af55f52ec8846ac479ac4fe\tthe cairos\t0.0004738106\n", | |
"\n", | |
"00007a47085b9aab8af55f52ec8846ac479ac4fe\tearth stood still\t0.00047162396\n", | |
"\n" | |
] | |
}, | |
{ | |
"output_type": "stream", | |
"name": "stderr", | |
"text": [ | |
"\n" | |
] | |
} | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "qXvKRMx-GPvA", | |
"colab": { | |
"base_uri": "https://localhost:8080/" | |
}, | |
"outputId": "5e657212-abfc-4502-de4c-2b81544ac74d" | |
}, | |
"source": [ | |
"# artistid, other artistid, score\n", | |
"user_count = np.ediff1d(plays.indptr)\n", | |
"to_generate = sorted(np.arange(len(artists)), key=lambda x: -user_count[x])\n", | |
"for artistid in to_generate[:5]:\n", | |
" artist = artists[artistid]\n", | |
" others, scores = model.similar_items(artistid, 11)\n", | |
" for other, score in zip(others, scores):\n", | |
" if len(artists) < other:\n", | |
" continue\n", | |
" print(f\"%s\\t%s\\t%s\\n\" % (artist, artists[other], score))\n", | |
" " | |
], | |
"execution_count": 52, | |
"outputs": [ | |
{ | |
"output_type": "stream", | |
"name": "stdout", | |
"text": [ | |
"radiohead\tradiohead\t1.0000001\n", | |
"\n", | |
"radiohead\tblack taxi\t0.89469194\n", | |
"\n", | |
"radiohead\tvibert / simmonds\t0.8650032\n", | |
"\n", | |
"radiohead\t銀杏boyz\t0.85511833\n", | |
"\n", | |
"radiohead\tbunky & jake\t0.85470194\n", | |
"\n", | |
"radiohead\tadrien sala\t0.8506106\n", | |
"\n", | |
"radiohead\tpremix\t0.8426455\n", | |
"\n", | |
"radiohead\tbioshock soundtrack\t0.838582\n", | |
"\n", | |
"radiohead\telisa fiorillo\t0.8345544\n", | |
"\n", | |
"radiohead\tthe coffin nails\t0.832676\n", | |
"\n", | |
"the beatles\tthe beatles\t1.0\n", | |
"\n", | |
"the beatles\tedu kehäkettunen & djpp\t0.9491118\n", | |
"\n", | |
"the beatles\tmuharrem ertaş\t0.9371736\n", | |
"\n", | |
"the beatles\tmarilyn mazurs future song\t0.9290759\n", | |
"\n", | |
"the beatles\tg. malone\t0.92577535\n", | |
"\n", | |
"the beatles\tagent 94\t0.92286485\n", | |
"\n", | |
"the beatles\tstyx & the contemporary youth orchestra\t0.91779476\n", | |
"\n", | |
"the beatles\tČertuf punk\t0.9173099\n", | |
"\n", | |
"the beatles\thawkeye\t0.9168076\n", | |
"\n", | |
"the beatles\tnation of boats\t0.91515106\n", | |
"\n", | |
"coldplay\tcoldplay\t1.0\n", | |
"\n", | |
"coldplay\tКоммунизм\t0.85884345\n", | |
"\n", | |
"coldplay\t赵鹏\t0.8561648\n", | |
"\n", | |
"coldplay\trobin hall and jimmie macgregor\t0.8549474\n", | |
"\n", | |
"coldplay\tasfixia\t0.8509144\n", | |
"\n", | |
"coldplay\tashford & simpson\t0.8365757\n", | |
"\n", | |
"coldplay\tcrystal castles vs the little ones\t0.83328277\n", | |
"\n", | |
"coldplay\twinter gloves\t0.8228376\n", | |
"\n", | |
"red hot chili peppers\tred hot chili peppers\t0.99999994\n", | |
"\n", | |
"red hot chili peppers\tmadbrenda\t0.91473454\n", | |
"\n", | |
"red hot chili peppers\tsümeyra\t0.900723\n", | |
"\n", | |
"red hot chili peppers\tthe privates\t0.8995463\n", | |
"\n", | |
"red hot chili peppers\tthe sugargliders\t0.8878148\n", | |
"\n", | |
"red hot chili peppers\tkill casino\t0.8871299\n", | |
"\n", | |
"red hot chili peppers\tbobby matos\t0.8856506\n", | |
"\n", | |
"red hot chili peppers\thugh dillon redemption choir\t0.88531375\n", | |
"\n", | |
"red hot chili peppers\tbajzel\t0.8838702\n", | |
"\n", | |
"muse\tmuse\t1.0000001\n", | |
"\n", | |
"muse\tavtomobili\t0.84405726\n", | |
"\n", | |
"muse\tad2\t0.83693504\n", | |
"\n", | |
"muse\tleon de juda\t0.8270184\n", | |
"\n", | |
"muse\tjudith edelman\t0.8172238\n", | |
"\n", | |
"muse\tsolal presents the moonshine sessions\t0.81517977\n", | |
"\n", | |
"muse\tannie´s trip\t0.8117278\n", | |
"\n", | |
"muse\tjez lowe\t0.81077415\n", | |
"\n", | |
"muse\tcheese on bread\t0.81030524\n", | |
"\n", | |
"muse\twilliam duckworth\t0.81024516\n", | |
"\n" | |
] | |
} | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"source": [ | |
"" | |
], | |
"metadata": { | |
"id": "85ENQUOMGkn5" | |
}, | |
"execution_count": null, | |
"outputs": [] | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment