{"id":7842,"date":"2023-10-06T12:38:00","date_gmt":"2023-10-06T20:38:00","guid":{"rendered":"https:\/\/live-cometml.pantheonsite.io\/?p=7842"},"modified":"2025-04-24T17:05:57","modified_gmt":"2025-04-24T17:05:57","slug":"logging-recommendation-system-visualizations-in-comet","status":"publish","type":"post","link":"https:\/\/www.comet.com\/site\/blog\/logging-recommendation-system-visualizations-in-comet\/","title":{"rendered":"Logging Recommendation System Visualizations in Comet"},"content":{"rendered":"\n<link rel=\"canonical\" href=\"https:\/\/www.comet.com\/site\/blog\/logging-recommendation-system-visualizations-in-comet\">\n\n\n\n<div class=\"fi fj fk fl fm\">\n<div class=\"ab ca\">\n<div class=\"ch bg eu ev ew ex\">\n<figure class=\"mi mj mk ml mm mn mf mg paragraph-image\">\n<div class=\"mo mp ec mq bg mr\" tabindex=\"0\" role=\"button\">\n<figure><img loading=\"lazy\" decoding=\"async\" class=\"bg ms mt c\" role=\"presentation\" src=\"https:\/\/miro.medium.com\/v2\/resize:fit:700\/1*Pe6ibd8O4G225zvqGA1wNQ.jpeg\" alt=\"\" width=\"700\" height=\"467\"><\/figure><div class=\"mf mg mh\"><picture><\/picture><\/div>\n<\/div><figcaption class=\"mu mv mw mf mg mx my be b bf z dw\" data-selectable-paragraph=\"\">Photo Credit: Pexels.com<\/figcaption><\/figure>\n<h2 id=\"14ce\" class=\"mz na fp be nb nc nd ne nf ng nh ni nj nk nl nm nn no np nq nr ns nt nu nv nw bj\" data-selectable-paragraph=\"\"><strong class=\"al\">Introduction<\/strong><\/h2>\n<p id=\"dfd9\" class=\"pw-post-body-paragraph nx ny fp be b gn nz oa ob gq oc od oe nk of og oh no oi oj ok ns ol om on oo fi bj\" data-selectable-paragraph=\"\">Have you ever questioned how we can become so engrossed in watching videos on YouTube and how some of these posts end up on your Facebook or Instagram timeline? For those of us who are familiar with Netflix, we frequently receive recommendations for movies that are similar to the ones we are looking for or perhaps the ones we have just finished watching. This is made possible by an algorithm known as the &#8220;recommendation system.&#8221; In this tutorial, we\u2019ll talk more about the recommendation system, build a system for recommending movies, and then integrate it into Comet.<\/p>\n<h2 id=\"a1e2\" class=\"mz na fp be nb nc nd ne nf ng nh ni nj nk nl nm nn no np nq nr ns nt nu nv nw bj\" data-selectable-paragraph=\"\"><strong class=\"al\">Recommendation Systems<\/strong><\/h2>\n<p id=\"9411\" class=\"pw-post-body-paragraph nx ny fp be b gn nz oa ob gq oc od oe nk of og oh no oi oj ok ns ol om on oo fi bj\" data-selectable-paragraph=\"\">There are 3 main types of Recommendation systems<\/p>\n<ol class=\"\">\n<li id=\"52f6\" class=\"nx ny fp be b gn op oa ob gq oq od oe nk or og oh no os oj ok ns ot om on oo ou ov ow bj\" data-selectable-paragraph=\"\">Content-Based Recommendation system.<\/li>\n<li id=\"14f1\" class=\"nx ny fp be b gn ox oa ob gq oy od oe nk oz og oh no pa oj ok ns pb om on oo ou ov ow bj\" data-selectable-paragraph=\"\">Popularity-Based Recommendation system.<\/li>\n<li id=\"07aa\" class=\"nx ny fp be b gn ox oa ob gq oy od oe nk oz og oh no pa oj ok ns pb om on oo ou ov ow bj\" data-selectable-paragraph=\"\">Collaborative Recommendation system.<\/li>\n<\/ol>\n<p id=\"f283\" class=\"pw-post-body-paragraph nx ny fp be b gn op oa ob gq oq od oe nk pc og oh no pd oj ok ns pe om on oo fi bj\" data-selectable-paragraph=\"\">Content-Based Recommendation system:<\/p>\n<p id=\"94b4\" class=\"pw-post-body-paragraph nx ny fp be b gn op oa ob gq oq od oe nk pc og oh no pd oj ok ns pe om on oo fi bj\" data-selectable-paragraph=\"\">It is a type of recommendation system that operates on a similar content principle. If a user is watching a movie, the system will look for other movies with similar content or in the same genre as the one the user is watching. When comparing similar content, various fundamental attributes are used to compute similarity.<\/p>\n<h2 id=\"5756\" class=\"mz na fp be nb nc nd ne nf ng nh ni nj nk nl nm nn no np nq nr ns nt nu nv nw bj\" data-selectable-paragraph=\"\"><strong class=\"al\">Popularity-Based Recommendation System:<\/strong><\/h2>\n<p id=\"d098\" class=\"pw-post-body-paragraph nx ny fp be b gn nz oa ob gq oc od oe nk of og oh no oi oj ok ns ol om on oo fi bj\" data-selectable-paragraph=\"\">It is a type of recommendation system that operates based on popularity of anything that is currently popular. These systems examine the products or movies that are popular among users and directly recommend them.<\/p>\n<p id=\"1677\" class=\"pw-post-body-paragraph nx ny fp be b gn op oa ob gq oq od oe nk pc og oh no pd oj ok ns pe om on oo fi bj\" data-selectable-paragraph=\"\">For instance, if a product is frequently purchased by the majority of people, the system will learn that it is the most popular, so for every new user who has just signed up, the system will recommend that product to that user as well, and the chances are that the new user will also purchase that.<\/p>\n<h2 id=\"a3d9\" class=\"mz na fp be nb nc nd ne nf ng nh ni nj nk nl nm nn no np nq nr ns nt nu nv nw bj\" data-selectable-paragraph=\"\"><strong class=\"al\">Collaborative Recommendation system<\/strong><\/h2>\n<p id=\"5231\" class=\"pw-post-body-paragraph nx ny fp be b gn nz oa ob gq oc od oe nk of og oh no oi oj ok ns ol om on oo fi bj\" data-selectable-paragraph=\"\">Collaborative recommendation, also called collaborative filtering, works by analyzing the preferences and data of numerous users. Collaborative filtering predicts a user\u2019s interests. This is accomplished by applying techniques involving cooperation among numerous agents, data sources, etc. to filter data for information or patterns. The underlying premise of collaborative filtering is that users A and B are likely to have similar tastes in products if they have similar tastes in one product.<\/p>\n<h2 id=\"c53c\" class=\"mz na fp be nb nc nd ne nf ng nh ni nj nk nl nm nn no np nq nr ns nt nu nv nw bj\" data-selectable-paragraph=\"\"><strong class=\"al\">Comet<\/strong><\/h2>\n<p id=\"e0ff\" class=\"pw-post-body-paragraph nx ny fp be b gn nz oa ob gq oc od oe nk of og oh no oi oj ok ns ol om on oo fi bj\" data-selectable-paragraph=\"\">Comet is a platform for experimentation that enables you to monitor your machine-learning experiments. Comet has another noteworthy feature: it allows us to conduct exploratory data analysis. We can accomplish our EDA objectives thanks to Comet\u2019s integration with well-known Python visualization frameworks. You can learn more about <a class=\"af pf\" href=\"https:\/\/www.comet.com\/docs\/v2\/\" target=\"_blank\" rel=\"noopener ugc nofollow\">comet here.<\/a><\/p>\n<p id=\"3a41\" class=\"pw-post-body-paragraph nx ny fp be b gn op oa ob gq oq od oe nk pc og oh no pd oj ok ns pe om on oo fi bj\" data-selectable-paragraph=\"\">This lesson will teach us how to connect Comet with our recommendation system. We will carry out some EDA on our movie dataset to achieve this, and we will log the visualization onto the Comet experimentation website or platform. Let\u2019s begin without further ado.<\/p>\n<h2 id=\"1fc8\" class=\"mz na fp be nb nc nd ne nf ng nh ni nj nk nl nm nn no np nq nr ns nt nu nv nw bj\" data-selectable-paragraph=\"\"><strong class=\"al\">Prerequisites<\/strong><\/h2>\n<p id=\"043e\" class=\"pw-post-body-paragraph nx ny fp be b gn nz oa ob gq oc od oe nk of og oh no oi oj ok ns ol om on oo fi bj\" data-selectable-paragraph=\"\">You may install the Comet library on your computer if you don\u2019t already have it there by using the following line at the command prompt.<\/p>\n<pre class=\"mi mj mk ml mm pg ph pi pj ax pk bj\"><span id=\"38e0\" class=\"mz na fp ph b ia pl pm l iq pn\" data-selectable-paragraph=\"\">pip install comet_ml<\/span><\/pre>\n<p id=\"5df2\" class=\"pw-post-body-paragraph nx ny fp be b gn op oa ob gq oq od oe nk pc og oh no pd oj ok ns pe om on oo fi bj\" data-selectable-paragraph=\"\">\u2014 or \u2014<\/p>\n<pre class=\"mi mj mk ml mm pg ph pi pj ax pk bj\"><span id=\"aa61\" class=\"mz na fp ph b ia pl pm l iq pn\" data-selectable-paragraph=\"\">conda install -c comet_ml<\/span><\/pre>\n<h2 id=\"127a\" class=\"mz na fp be nb nc nd ne nf ng nh ni nj nk nl nm nn no np nq nr ns nt nu nv nw bj\" data-selectable-paragraph=\"\"><strong class=\"al\">About the data<\/strong><\/h2>\n<p id=\"8132\" class=\"pw-post-body-paragraph nx ny fp be b gn nz oa ob gq oc od oe nk of og oh no oi oj ok ns ol om on oo fi bj\" data-selectable-paragraph=\"\">All 45,000 films mentioned in the Full MovieLens Dataset are represented by these files\u2019 information. Movies that were released on or before July 2017 are included in the dataset. Cast, crew, narrative keywords, budget, revenue, posters, release dates, language breakdowns, production firms, nations, and TMDB vote counts and averages are just a few examples of the data points.<\/p>\n<p id=\"7614\" class=\"pw-post-body-paragraph nx ny fp be b gn op oa ob gq oq od oe nk pc og oh no pd oj ok ns pe om on oo fi bj\" data-selectable-paragraph=\"\">Additionally, this collection includes files with 26 million user ratings for all 45,000 movies, collected from 270,000 individuals. A scale of 1 to 5 stars was used to rate each item on the GroupLens official website. You can get the <a class=\"af pf\" href=\"https:\/\/www.kaggle.com\/datasets\/rounakbanik\/the-movies-dataset\" target=\"_blank\" rel=\"noopener ugc nofollow\">data from Kaggle here.<\/a><\/p>\n<\/div>\n<\/div>\n<\/div>\n\n\n\n<div class=\"fi fj fk fl fm\">\n<div class=\"ab ca\">\n<div class=\"ch bg eu ev ew ex\">\n<blockquote class=\"pw\"><p id=\"d315\" class=\"px py fp be pz qa qb qc qd qe qf oo dw\" data-selectable-paragraph=\"\">Real-time model analysis allows your team to track, monitor, and adjust models already in production. <a class=\"af pf\" href=\"https:\/\/www.comet.com\/site\/ty\/lessons-from-the-field-in-building-your-mlops-strategy\/\" target=\"_blank\" rel=\"noopener ugc nofollow\">Learn more lessons from the field with Comet experts<\/a>.<\/p><\/blockquote>\n<\/div>\n<\/div>\n<\/div>\n\n\n\n<div class=\"fi fj fk fl fm\">\n<div class=\"ab ca\">\n<div class=\"ch bg eu ev ew ex\">\n<h2 id=\"b7e3\" class=\"mz na fp be nb nc nd ne nf ng nh ni nj nk nl nm nn no np nq nr ns nt nu nv nw bj\" data-selectable-paragraph=\"\"><strong class=\"al\">Movie Recommendation system<\/strong><\/h2>\n<p id=\"6716\" class=\"pw-post-body-paragraph nx ny fp be b gn nz oa ob gq oc od oe nk of og oh no oi oj ok ns ol om on oo fi bj\" data-selectable-paragraph=\"\">The first step involves importing the dependencies.<\/p>\n<pre class=\"mi mj mk ml mm pg ph pi pj ax pk bj\"><span id=\"bacc\" class=\"mz na fp ph b ia pl pm l iq pn\" data-selectable-paragraph=\"\">import numpy as np\nimport pandas as pd\nimport seaborn as sns\nimport matplotlib.pyplot as plt\nimport difflib\nfrom sklearn.feature_extraction.text import TfidfVectorizer\nfrom sklearn.metrics.pairwise import cosine_similarity<\/span><\/pre>\n<p id=\"bcb3\" class=\"pw-post-body-paragraph nx ny fp be b gn op oa ob gq oq od oe nk pc og oh no pd oj ok ns pe om on oo fi bj\" data-selectable-paragraph=\"\">We then move to load our dataset into the pandas dataframe.<\/p>\n<pre class=\"mi mj mk ml mm pg ph pi pj ax pk bj\"><span id=\"f70b\" class=\"mz na fp ph b ia pl pm l iq pn\" data-selectable-paragraph=\"\">movie_data = pd.read_csv('\/content\/jmovies.csv')<\/span><\/pre>\n<p id=\"168e\" class=\"pw-post-body-paragraph nx ny fp be b gn op oa ob gq oq od oe nk pc og oh no pd oj ok ns pe om on oo fi bj\" data-selectable-paragraph=\"\">We then move to the next step, which is data preprocessing.<\/p>\n<pre class=\"mi mj mk ml mm pg ph pi pj ax pk bj\"><span id=\"aba0\" class=\"mz na fp ph b ia pl pm l iq pn\" data-selectable-paragraph=\"\">movie_data.head()<\/span><\/pre>\n<figure class=\"mi mj mk ml mm mn mf mg paragraph-image\">\n<div class=\"mo mp ec mq bg mr\" tabindex=\"0\" role=\"button\">\n<figure><img loading=\"lazy\" decoding=\"async\" class=\"bg ms mt c\" role=\"presentation\" src=\"https:\/\/miro.medium.com\/v2\/resize:fit:700\/1*lMRIcZWegabMcQY2NrMDzw.png\" alt=\"\" width=\"700\" height=\"255\"><\/figure><div class=\"mf mg qg\"><picture><source srcset=\"https:\/\/miro.medium.com\/v2\/resize:fit:640\/format:webp\/1*lMRIcZWegabMcQY2NrMDzw.png 640w, https:\/\/miro.medium.com\/v2\/resize:fit:720\/format:webp\/1*lMRIcZWegabMcQY2NrMDzw.png 720w, https:\/\/miro.medium.com\/v2\/resize:fit:750\/format:webp\/1*lMRIcZWegabMcQY2NrMDzw.png 750w, https:\/\/miro.medium.com\/v2\/resize:fit:786\/format:webp\/1*lMRIcZWegabMcQY2NrMDzw.png 786w, https:\/\/miro.medium.com\/v2\/resize:fit:828\/format:webp\/1*lMRIcZWegabMcQY2NrMDzw.png 828w, https:\/\/miro.medium.com\/v2\/resize:fit:1100\/format:webp\/1*lMRIcZWegabMcQY2NrMDzw.png 1100w, https:\/\/miro.medium.com\/v2\/resize:fit:1400\/format:webp\/1*lMRIcZWegabMcQY2NrMDzw.png 1400w\" type=\"image\/webp\" sizes=\"(min-resolution: 4dppx) and (max-width: 700px) 50vw, (-webkit-min-device-pixel-ratio: 4) and (max-width: 700px) 50vw, (min-resolution: 3dppx) and (max-width: 700px) 67vw, (-webkit-min-device-pixel-ratio: 3) and (max-width: 700px) 65vw, (min-resolution: 2.5dppx) and (max-width: 700px) 80vw, (-webkit-min-device-pixel-ratio: 2.5) and (max-width: 700px) 80vw, (min-resolution: 2dppx) and (max-width: 700px) 100vw, (-webkit-min-device-pixel-ratio: 2) and (max-width: 700px) 100vw, 700px\"><source srcset=\"https:\/\/miro.medium.com\/v2\/resize:fit:640\/1*lMRIcZWegabMcQY2NrMDzw.png 640w, https:\/\/miro.medium.com\/v2\/resize:fit:720\/1*lMRIcZWegabMcQY2NrMDzw.png 720w, https:\/\/miro.medium.com\/v2\/resize:fit:750\/1*lMRIcZWegabMcQY2NrMDzw.png 750w, https:\/\/miro.medium.com\/v2\/resize:fit:786\/1*lMRIcZWegabMcQY2NrMDzw.png 786w, https:\/\/miro.medium.com\/v2\/resize:fit:828\/1*lMRIcZWegabMcQY2NrMDzw.png 828w, https:\/\/miro.medium.com\/v2\/resize:fit:1100\/1*lMRIcZWegabMcQY2NrMDzw.png 1100w, https:\/\/miro.medium.com\/v2\/resize:fit:1400\/1*lMRIcZWegabMcQY2NrMDzw.png 1400w\" sizes=\"(min-resolution: 4dppx) and (max-width: 700px) 50vw, (-webkit-min-device-pixel-ratio: 4) and (max-width: 700px) 50vw, (min-resolution: 3dppx) and (max-width: 700px) 67vw, (-webkit-min-device-pixel-ratio: 3) and (max-width: 700px) 65vw, (min-resolution: 2.5dppx) and (max-width: 700px) 80vw, (-webkit-min-device-pixel-ratio: 2.5) and (max-width: 700px) 80vw, (min-resolution: 2dppx) and (max-width: 700px) 100vw, (-webkit-min-device-pixel-ratio: 2) and (max-width: 700px) 100vw, 700px\" data-testid=\"og\"><\/picture><\/div>\n<\/div>\n<\/figure>\n<pre class=\"mi mj mk ml mm pg ph pi pj ax pk bj\"><span id=\"4d2e\" class=\"mz na fp ph b ia pl pm l iq pn\" data-selectable-paragraph=\"\">movie_data.info()<\/span><\/pre>\n<figure class=\"mi mj mk ml mm mn mf mg paragraph-image\">\n<figure><img loading=\"lazy\" decoding=\"async\" class=\"bg ms mt c\" role=\"presentation\" src=\"https:\/\/miro.medium.com\/v2\/resize:fit:531\/1*dWpOC_qpVd7ew6qN1HXxKQ.png\" alt=\"\" width=\"531\" height=\"497\"><\/figure><div class=\"mf mg qh\"><picture><source srcset=\"https:\/\/miro.medium.com\/v2\/resize:fit:640\/format:webp\/1*dWpOC_qpVd7ew6qN1HXxKQ.png 640w, https:\/\/miro.medium.com\/v2\/resize:fit:720\/format:webp\/1*dWpOC_qpVd7ew6qN1HXxKQ.png 720w, https:\/\/miro.medium.com\/v2\/resize:fit:750\/format:webp\/1*dWpOC_qpVd7ew6qN1HXxKQ.png 750w, https:\/\/miro.medium.com\/v2\/resize:fit:786\/format:webp\/1*dWpOC_qpVd7ew6qN1HXxKQ.png 786w, https:\/\/miro.medium.com\/v2\/resize:fit:828\/format:webp\/1*dWpOC_qpVd7ew6qN1HXxKQ.png 828w, https:\/\/miro.medium.com\/v2\/resize:fit:1100\/format:webp\/1*dWpOC_qpVd7ew6qN1HXxKQ.png 1100w, https:\/\/miro.medium.com\/v2\/resize:fit:1062\/format:webp\/1*dWpOC_qpVd7ew6qN1HXxKQ.png 1062w\" type=\"image\/webp\" sizes=\"(min-resolution: 4dppx) and (max-width: 700px) 50vw, (-webkit-min-device-pixel-ratio: 4) and (max-width: 700px) 50vw, (min-resolution: 3dppx) and (max-width: 700px) 67vw, (-webkit-min-device-pixel-ratio: 3) and (max-width: 700px) 65vw, (min-resolution: 2.5dppx) and (max-width: 700px) 80vw, (-webkit-min-device-pixel-ratio: 2.5) and (max-width: 700px) 80vw, (min-resolution: 2dppx) and (max-width: 700px) 100vw, (-webkit-min-device-pixel-ratio: 2) and (max-width: 700px) 100vw, 531px\"><source srcset=\"https:\/\/miro.medium.com\/v2\/resize:fit:640\/1*dWpOC_qpVd7ew6qN1HXxKQ.png 640w, https:\/\/miro.medium.com\/v2\/resize:fit:720\/1*dWpOC_qpVd7ew6qN1HXxKQ.png 720w, https:\/\/miro.medium.com\/v2\/resize:fit:750\/1*dWpOC_qpVd7ew6qN1HXxKQ.png 750w, https:\/\/miro.medium.com\/v2\/resize:fit:786\/1*dWpOC_qpVd7ew6qN1HXxKQ.png 786w, https:\/\/miro.medium.com\/v2\/resize:fit:828\/1*dWpOC_qpVd7ew6qN1HXxKQ.png 828w, https:\/\/miro.medium.com\/v2\/resize:fit:1100\/1*dWpOC_qpVd7ew6qN1HXxKQ.png 1100w, https:\/\/miro.medium.com\/v2\/resize:fit:1062\/1*dWpOC_qpVd7ew6qN1HXxKQ.png 1062w\" sizes=\"(min-resolution: 4dppx) and (max-width: 700px) 50vw, (-webkit-min-device-pixel-ratio: 4) and (max-width: 700px) 50vw, (min-resolution: 3dppx) and (max-width: 700px) 67vw, (-webkit-min-device-pixel-ratio: 3) and (max-width: 700px) 65vw, (min-resolution: 2.5dppx) and (max-width: 700px) 80vw, (-webkit-min-device-pixel-ratio: 2.5) and (max-width: 700px) 80vw, (min-resolution: 2dppx) and (max-width: 700px) 100vw, (-webkit-min-device-pixel-ratio: 2) and (max-width: 700px) 100vw, 531px\" data-testid=\"og\"><\/picture><\/div>\n<\/figure>\n<pre class=\"mi mj mk ml mm pg ph pi pj ax pk bj\"><span id=\"5eea\" class=\"mz na fp ph b ia pl pm l iq pn\" data-selectable-paragraph=\"\">movie_data. isnull()<\/span><\/pre>\n<p id=\"c70c\" class=\"pw-post-body-paragraph nx ny fp be b gn op oa ob gq oq od oe nk pc og oh no pd oj ok ns pe om on oo fi bj\" data-selectable-paragraph=\"\">The movie_data. isnull() function returns false if the values in the dataset are not missing and return true if they are missing.<\/p>\n<figure class=\"mi mj mk ml mm mn mf mg paragraph-image\">\n<div class=\"mo mp ec mq bg mr\" tabindex=\"0\" role=\"button\">\n<figure><img loading=\"lazy\" decoding=\"async\" class=\"bg ms mt c\" role=\"presentation\" src=\"https:\/\/miro.medium.com\/v2\/resize:fit:700\/1*3TJvmz5EO1YT1Hqm3pec7g.png\" alt=\"\" width=\"700\" height=\"172\"><\/figure><div class=\"mf mg qi\"><picture><source srcset=\"https:\/\/miro.medium.com\/v2\/resize:fit:640\/format:webp\/1*3TJvmz5EO1YT1Hqm3pec7g.png 640w, https:\/\/miro.medium.com\/v2\/resize:fit:720\/format:webp\/1*3TJvmz5EO1YT1Hqm3pec7g.png 720w, https:\/\/miro.medium.com\/v2\/resize:fit:750\/format:webp\/1*3TJvmz5EO1YT1Hqm3pec7g.png 750w, https:\/\/miro.medium.com\/v2\/resize:fit:786\/format:webp\/1*3TJvmz5EO1YT1Hqm3pec7g.png 786w, https:\/\/miro.medium.com\/v2\/resize:fit:828\/format:webp\/1*3TJvmz5EO1YT1Hqm3pec7g.png 828w, https:\/\/miro.medium.com\/v2\/resize:fit:1100\/format:webp\/1*3TJvmz5EO1YT1Hqm3pec7g.png 1100w, https:\/\/miro.medium.com\/v2\/resize:fit:1400\/format:webp\/1*3TJvmz5EO1YT1Hqm3pec7g.png 1400w\" type=\"image\/webp\" sizes=\"(min-resolution: 4dppx) and (max-width: 700px) 50vw, (-webkit-min-device-pixel-ratio: 4) and (max-width: 700px) 50vw, (min-resolution: 3dppx) and (max-width: 700px) 67vw, (-webkit-min-device-pixel-ratio: 3) and (max-width: 700px) 65vw, (min-resolution: 2.5dppx) and (max-width: 700px) 80vw, (-webkit-min-device-pixel-ratio: 2.5) and (max-width: 700px) 80vw, (min-resolution: 2dppx) and (max-width: 700px) 100vw, (-webkit-min-device-pixel-ratio: 2) and (max-width: 700px) 100vw, 700px\"><source srcset=\"https:\/\/miro.medium.com\/v2\/resize:fit:640\/1*3TJvmz5EO1YT1Hqm3pec7g.png 640w, https:\/\/miro.medium.com\/v2\/resize:fit:720\/1*3TJvmz5EO1YT1Hqm3pec7g.png 720w, https:\/\/miro.medium.com\/v2\/resize:fit:750\/1*3TJvmz5EO1YT1Hqm3pec7g.png 750w, https:\/\/miro.medium.com\/v2\/resize:fit:786\/1*3TJvmz5EO1YT1Hqm3pec7g.png 786w, https:\/\/miro.medium.com\/v2\/resize:fit:828\/1*3TJvmz5EO1YT1Hqm3pec7g.png 828w, https:\/\/miro.medium.com\/v2\/resize:fit:1100\/1*3TJvmz5EO1YT1Hqm3pec7g.png 1100w, https:\/\/miro.medium.com\/v2\/resize:fit:1400\/1*3TJvmz5EO1YT1Hqm3pec7g.png 1400w\" sizes=\"(min-resolution: 4dppx) and (max-width: 700px) 50vw, (-webkit-min-device-pixel-ratio: 4) and (max-width: 700px) 50vw, (min-resolution: 3dppx) and (max-width: 700px) 67vw, (-webkit-min-device-pixel-ratio: 3) and (max-width: 700px) 65vw, (min-resolution: 2.5dppx) and (max-width: 700px) 80vw, (-webkit-min-device-pixel-ratio: 2.5) and (max-width: 700px) 80vw, (min-resolution: 2dppx) and (max-width: 700px) 100vw, (-webkit-min-device-pixel-ratio: 2) and (max-width: 700px) 100vw, 700px\" data-testid=\"og\"><\/picture><\/div>\n<\/div>\n<\/figure>\n<p id=\"3b76\" class=\"pw-post-body-paragraph nx ny fp be b gn op oa ob gq oq od oe nk pc og oh no pd oj ok ns pe om on oo fi bj\" data-selectable-paragraph=\"\">The movie_data. isnull().head() function only gives us the details on the first 5 columns, but to know the exact column and how many values are missing, we use the movie_data. isnull().sum() function tells us which column has missing values and the number of missing values it has.<\/p>\n<pre class=\"mi mj mk ml mm pg ph pi pj ax pk bj\"><span id=\"c37b\" class=\"mz na fp ph b ia pl pm l iq pn\" data-selectable-paragraph=\"\">movie_data. isnull().sum()<\/span><\/pre>\n<figure class=\"mi mj mk ml mm mn mf mg paragraph-image\">\n<figure><img loading=\"lazy\" decoding=\"async\" class=\"bg ms mt c\" role=\"presentation\" src=\"https:\/\/miro.medium.com\/v2\/resize:fit:352\/1*VZ8lBKwf-j9e338jBlhQsQ.png\" alt=\"\" width=\"352\" height=\"450\"><\/figure><div class=\"mf mg qj\"><picture><source srcset=\"https:\/\/miro.medium.com\/v2\/resize:fit:640\/format:webp\/1*VZ8lBKwf-j9e338jBlhQsQ.png 640w, https:\/\/miro.medium.com\/v2\/resize:fit:720\/format:webp\/1*VZ8lBKwf-j9e338jBlhQsQ.png 720w, https:\/\/miro.medium.com\/v2\/resize:fit:750\/format:webp\/1*VZ8lBKwf-j9e338jBlhQsQ.png 750w, https:\/\/miro.medium.com\/v2\/resize:fit:786\/format:webp\/1*VZ8lBKwf-j9e338jBlhQsQ.png 786w, https:\/\/miro.medium.com\/v2\/resize:fit:828\/format:webp\/1*VZ8lBKwf-j9e338jBlhQsQ.png 828w, https:\/\/miro.medium.com\/v2\/resize:fit:1100\/format:webp\/1*VZ8lBKwf-j9e338jBlhQsQ.png 1100w, https:\/\/miro.medium.com\/v2\/resize:fit:704\/format:webp\/1*VZ8lBKwf-j9e338jBlhQsQ.png 704w\" type=\"image\/webp\" sizes=\"(min-resolution: 4dppx) and (max-width: 700px) 50vw, (-webkit-min-device-pixel-ratio: 4) and (max-width: 700px) 50vw, (min-resolution: 3dppx) and (max-width: 700px) 67vw, (-webkit-min-device-pixel-ratio: 3) and (max-width: 700px) 65vw, (min-resolution: 2.5dppx) and (max-width: 700px) 80vw, (-webkit-min-device-pixel-ratio: 2.5) and (max-width: 700px) 80vw, (min-resolution: 2dppx) and (max-width: 700px) 100vw, (-webkit-min-device-pixel-ratio: 2) and (max-width: 700px) 100vw, 352px\"><source srcset=\"https:\/\/miro.medium.com\/v2\/resize:fit:640\/1*VZ8lBKwf-j9e338jBlhQsQ.png 640w, https:\/\/miro.medium.com\/v2\/resize:fit:720\/1*VZ8lBKwf-j9e338jBlhQsQ.png 720w, https:\/\/miro.medium.com\/v2\/resize:fit:750\/1*VZ8lBKwf-j9e338jBlhQsQ.png 750w, https:\/\/miro.medium.com\/v2\/resize:fit:786\/1*VZ8lBKwf-j9e338jBlhQsQ.png 786w, https:\/\/miro.medium.com\/v2\/resize:fit:828\/1*VZ8lBKwf-j9e338jBlhQsQ.png 828w, https:\/\/miro.medium.com\/v2\/resize:fit:1100\/1*VZ8lBKwf-j9e338jBlhQsQ.png 1100w, https:\/\/miro.medium.com\/v2\/resize:fit:704\/1*VZ8lBKwf-j9e338jBlhQsQ.png 704w\" sizes=\"(min-resolution: 4dppx) and (max-width: 700px) 50vw, (-webkit-min-device-pixel-ratio: 4) and (max-width: 700px) 50vw, (min-resolution: 3dppx) and (max-width: 700px) 67vw, (-webkit-min-device-pixel-ratio: 3) and (max-width: 700px) 65vw, (min-resolution: 2.5dppx) and (max-width: 700px) 80vw, (-webkit-min-device-pixel-ratio: 2.5) and (max-width: 700px) 80vw, (min-resolution: 2dppx) and (max-width: 700px) 100vw, (-webkit-min-device-pixel-ratio: 2) and (max-width: 700px) 100vw, 352px\" data-testid=\"og\"><\/picture><\/div>\n<\/figure>\n<p id=\"8d43\" class=\"pw-post-body-paragraph nx ny fp be b gn op oa ob gq oq od oe nk pc og oh no pd oj ok ns pe om on oo fi bj\" data-selectable-paragraph=\"\">We have a lot of elements in our dataset and not all can be used for our recommendation system, so we select only those that can be used. We also pick elements that will affect the accuracy of our recommendation system. Users are most likely to watch a movie based on the class of genres, the type of cast in the movie, and also the director in charge of the movie<\/p>\n<p id=\"ac24\" class=\"pw-post-body-paragraph nx ny fp be b gn op oa ob gq oq od oe nk pc og oh no pd oj ok ns pe om on oo fi bj\" data-selectable-paragraph=\"\">From our data preprocessing, we can see that we have a lot of missing values in our dataset, which will affect the result of our recommendation system. We need to fill it up with null strings, but before we do that, we need to perform some EDA.<\/p>\n<pre class=\"mi mj mk ml mm pg ph pi pj ax pk bj\"><span id=\"e06c\" class=\"mz na fp ph b ia pl pm l iq pn\" data-selectable-paragraph=\"\">movie_data[['keywords','tagline','cast','director']].fillna('')<\/span><\/pre>\n<p id=\"ddc0\" class=\"pw-post-body-paragraph nx ny fp be b gn op oa ob gq oq od oe nk pc og oh no pd oj ok ns pe om on oo fi bj\" data-selectable-paragraph=\"\">We then create a variable named &#8220;combined features&#8221; input all the selected features and print them. This is done so we can input it as a whole into our vectorizer, which converts the text to feature vectors.<\/p>\n<pre class=\"mi mj mk ml mm pg ph pi pj ax pk bj\"><span id=\"be6f\" class=\"mz na fp ph b ia pl pm l iq pn\" data-selectable-paragraph=\"\">combined_features= movie_data['genres']+' '+movie_data['keywords'] \\\n+' '+movie_data['tagline']+' '+movie_data['cast'] \\\n+' '+movie_data['director']<\/span><\/pre>\n<p id=\"ff8c\" class=\"pw-post-body-paragraph nx ny fp be b gn op oa ob gq oq od oe nk pc og oh no pd oj ok ns pe om on oo fi bj\" data-selectable-paragraph=\"\">The next step involves converting our text data to numerical data and this is done so it can be understood by the cosine similarity, which works well with numerical data we be using TfidfVectorizer to convert.<\/p>\n<pre class=\"mi mj mk ml mm pg ph pi pj ax pk bj\"><span id=\"f0fb\" class=\"mz na fp ph b ia pl pm l iq pn\" data-selectable-paragraph=\"\">vectorizer = TfidfVectorizer()\nfeature_vectors = vectorizer.fit_transform(combined_features)<\/span><\/pre>\n<p id=\"3e4b\" class=\"pw-post-body-paragraph nx ny fp be b gn op oa ob gq oq od oe nk pc og oh no pd oj ok ns pe om on oo fi bj\" data-selectable-paragraph=\"\">So once the numerical data is ready, we then try and get the similarity scores using cosine similarity, and we then load our feature vector into the cosine similarity to find movies that are similar to each other. So what the cosine similarity does is iterate through the list and try to find similarities between the selected character and the remaining movies in the dataset, it does this for each of the movies.<\/p>\n<pre class=\"mi mj mk ml mm pg ph pi pj ax pk bj\"><span id=\"c960\" class=\"mz na fp ph b ia pl pm l iq pn\" data-selectable-paragraph=\"\">similarity = cosine_similarity(feature_vectors)<\/span><span id=\"3d45\" class=\"mz na fp ph b ia qk pm l iq pn\" data-selectable-paragraph=\"\">print(similarity)\nprint(similarity.shape)<\/span><\/pre>\n<p id=\"5926\" class=\"pw-post-body-paragraph nx ny fp be b gn op oa ob gq oq od oe nk pc og oh no pd oj ok ns pe om on oo fi bj\" data-selectable-paragraph=\"\">To get our recommendation system working we need to create an input section for the user to input the name of their selected movie.<\/p>\n<pre class=\"mi mj mk ml mm pg ph pi pj ax pk bj\"><span id=\"20de\" class=\"mz na fp ph b ia pl pm l iq pn\" data-selectable-paragraph=\"\">movie_name = input(' Enter your favourite movie name : ')<\/span><\/pre>\n<p id=\"ac4a\" class=\"pw-post-body-paragraph nx ny fp be b gn op oa ob gq oq od oe nk pc og oh no pd oj ok ns pe om on oo fi bj\" data-selectable-paragraph=\"\">We then need to create a list of the names of all movies in the dataset.<\/p>\n<pre class=\"mi mj mk ml mm pg ph pi pj ax pk bj\"><span id=\"e6a1\" class=\"mz na fp ph b ia pl pm l iq pn\" data-selectable-paragraph=\"\">list_of_all_titles = movie_data['title'].tolist()\nprint(list_of_all_titles)<\/span><\/pre>\n<p id=\"f2a8\" class=\"pw-post-body-paragraph nx ny fp be b gn op oa ob gq oq od oe nk pc og oh no pd oj ok ns pe om on oo fi bj\" data-selectable-paragraph=\"\">The next step is finding a movie match for the movie name that the user inputs.<\/p>\n<pre class=\"mi mj mk ml mm pg ph pi pj ax pk bj\"><span id=\"5e54\" class=\"mz na fp ph b ia pl pm l iq pn\" data-selectable-paragraph=\"\">find_close_match = difflib.get_close_matches(movie_name,\n                                             list_of_all_titles)\nprint(find_close_match)<\/span><\/pre>\n<p id=\"f18e\" class=\"pw-post-body-paragraph nx ny fp be b gn op oa ob gq oq od oe nk pc og oh no pd oj ok ns pe om on oo fi bj\" data-selectable-paragraph=\"\">The above code gives us a list of related movies but we need to narrow it down to the exact movie the user inputs.<\/p>\n<pre class=\"mi mj mk ml mm pg ph pi pj ax pk bj\"><span id=\"88a6\" class=\"mz na fp ph b ia pl pm l iq pn\" data-selectable-paragraph=\"\">close_match = find_close_match[0]\nprint(close_match)<\/span><\/pre>\n<p id=\"a4e3\" class=\"pw-post-body-paragraph nx ny fp be b gn op oa ob gq oq od oe nk pc og oh no pd oj ok ns pe om on oo fi bj\" data-selectable-paragraph=\"\">To get the index of each movie we use the title of the movie to find the index<\/p>\n<pre class=\"mi mj mk ml mm pg ph pi pj ax pk bj\"><span id=\"5532\" class=\"mz na fp ph b ia pl pm l iq pn\" data-selectable-paragraph=\"\">index_of_the_movie = movie_data[movie_data.title == close_match]['index'].values[0]\nprint(index_of_the_movie)<\/span><\/pre>\n<p id=\"1b7f\" class=\"pw-post-body-paragraph nx ny fp be b gn op oa ob gq oq od oe nk pc og oh no pd oj ok ns pe om on oo fi bj\" data-selectable-paragraph=\"\">So, using the index value, we will be getting a list of similar values. So when you run this code you\u2019ll notice the index of the movie.<\/p>\n<pre class=\"mi mj mk ml mm pg ph pi pj ax pk bj\"><span id=\"811d\" class=\"mz na fp ph b ia pl pm l iq pn\" data-selectable-paragraph=\"\">similarity_score = list(enumerate(similarity[index_of_the_movie]))\nprint(similarity_score)<\/span><\/pre>\n<p id=\"ce77\" class=\"pw-post-body-paragraph nx ny fp be b gn op oa ob gq oq od oe nk pc og oh no pd oj ok ns pe om on oo fi bj\" data-selectable-paragraph=\"\">We then print the length of the similarity score.<\/p>\n<pre class=\"mi mj mk ml mm pg ph pi pj ax pk bj\"><span id=\"3db7\" class=\"mz na fp ph b ia pl pm l iq pn\" data-selectable-paragraph=\"\">len(similarity_score)<\/span><\/pre>\n<p id=\"ccda\" class=\"pw-post-body-paragraph nx ny fp be b gn op oa ob gq oq od oe nk pc og oh no pd oj ok ns pe om on oo fi bj\" data-selectable-paragraph=\"\">We then sort the movie based on the similarity score. So the same genres of movies are sorted together.<\/p>\n<pre class=\"mi mj mk ml mm pg ph pi pj ax pk bj\"><span id=\"5ce0\" class=\"mz na fp ph b ia pl pm l iq pn\" data-selectable-paragraph=\"\">sorted_similar_movies = sorted(similarity_score, key = lambda x:x[1], reverse = True)\nprint(sorted_similar_movies)<\/span><\/pre>\n<p id=\"138e\" class=\"pw-post-body-paragraph nx ny fp be b gn op oa ob gq oq od oe nk pc og oh no pd oj ok ns pe om on oo fi bj\" data-selectable-paragraph=\"\">Then we work on printing a list based on the similarity scores.<\/p>\n<pre class=\"mi mj mk ml mm pg ph pi pj ax pk bj\"><span id=\"ed3c\" class=\"mz na fp ph b ia pl pm l iq pn\" data-selectable-paragraph=\"\">print('Movies suggested for you : \\n')<\/span><span id=\"e176\" class=\"mz na fp ph b ia qk pm l iq pn\" data-selectable-paragraph=\"\">i = 1<\/span><span id=\"6695\" class=\"mz na fp ph b ia qk pm l iq pn\" data-selectable-paragraph=\"\">for movie in sorted_similar_movies:\n    index = movie[0]\n    title_from_index = movies_data[movies_data.index==index]['title'].values[0]\n    if (i&lt;30):\n        print(i, '.',title_from_index)\n        i+=1<\/span><\/pre>\n<p id=\"a88b\" class=\"pw-post-body-paragraph nx ny fp be b gn op oa ob gq oq od oe nk pc og oh no pd oj ok ns pe om on oo fi bj\" data-selectable-paragraph=\"\">So we can see that our recommendation system is up and running and the movie\u2019s recommendation works just fine. So the next step includes logging our visualization on the comet platform.<\/p>\n<p id=\"5516\" class=\"pw-post-body-paragraph nx ny fp be b gn op oa ob gq oq od oe nk pc og oh no pd oj ok ns pe om on oo fi bj\" data-selectable-paragraph=\"\">So we need to visualize some of the characters in our dataset using matplotlib and seaborn.<\/p>\n<pre class=\"mi mj mk ml mm pg ph pi pj ax pk bj\"><span id=\"aeda\" class=\"mz na fp ph b ia pl pm l iq pn\" data-selectable-paragraph=\"\">mask_df = movie_data[\"director\"].value_counts().head(10)\nfig1 = plt.figure(figsize=(12, 10))\nplt.bar(x = mask_df.index, height=mask_df, color=\"sienna\")\nplt.xlabel(\"director\")\nplt.ylabel(\"budget\")\nplt. title(\"Budget of each director per movie\")\nplt.xticks(rotation=45)<\/span><\/pre>\n<p id=\"8656\" class=\"pw-post-body-paragraph nx ny fp be b gn op oa ob gq oq od oe nk pc og oh no pd oj ok ns pe om on oo fi bj\" data-selectable-paragraph=\"\">So the above code shows the budget of each director per movie and we can see how the budget for each movie varies per director.<\/p>\n<p id=\"2175\" class=\"pw-post-body-paragraph nx ny fp be b gn op oa ob gq oq od oe nk pc og oh no pd oj ok ns pe om on oo fi bj\" data-selectable-paragraph=\"\">In the next step, we input the budget per movie, and we can see which of the movies has the highest budget.<\/p>\n<pre class=\"mi mj mk ml mm pg ph pi pj ax pk bj\"><span id=\"4dc6\" class=\"mz na fp ph b ia pl pm l iq pn\" data-selectable-paragraph=\"\">fig2 = plt.figure(figsize=(12, 10))\nsns.histplot(movie_data[\"budget\"], color=\"darkslategrey\", bins=50)\nplt.title(\"Budget of Movie\");<\/span><\/pre>\n<p id=\"76e0\" class=\"pw-post-body-paragraph nx ny fp be b gn op oa ob gq oq od oe nk pc og oh no pd oj ok ns pe om on oo fi bj\" data-selectable-paragraph=\"\">The next step will be to log the visualization onto the Comet platform once we have finished it. In this section, we\u2019ll use the Comet experiment library to build a brand-new project.<\/p>\n<p id=\"6884\" class=\"pw-post-body-paragraph nx ny fp be b gn op oa ob gq oq od oe nk pc og oh no pd oj ok ns pe om on oo fi bj\" data-selectable-paragraph=\"\">You will require a Comet API key to continue with this phase. Click here to sign up for their platform if you haven\u2019t already. By clicking on your profile photo, selecting the settings icon, and then scrolling down, as demonstrated below, you can find your API key.<\/p>\n<figure class=\"mi mj mk ml mm mn mf mg paragraph-image\">\n<div class=\"mo mp ec mq bg mr\" tabindex=\"0\" role=\"button\">\n<figure><img loading=\"lazy\" decoding=\"async\" class=\"bg ms mt c\" role=\"presentation\" src=\"https:\/\/miro.medium.com\/v2\/resize:fit:700\/1*P2DLupXzej9mAP4EGPNc2w.png\" alt=\"\" width=\"700\" height=\"303\"><\/figure><div class=\"mf mg ql\"><picture><source srcset=\"https:\/\/miro.medium.com\/v2\/resize:fit:640\/format:webp\/1*P2DLupXzej9mAP4EGPNc2w.png 640w, https:\/\/miro.medium.com\/v2\/resize:fit:720\/format:webp\/1*P2DLupXzej9mAP4EGPNc2w.png 720w, https:\/\/miro.medium.com\/v2\/resize:fit:750\/format:webp\/1*P2DLupXzej9mAP4EGPNc2w.png 750w, https:\/\/miro.medium.com\/v2\/resize:fit:786\/format:webp\/1*P2DLupXzej9mAP4EGPNc2w.png 786w, https:\/\/miro.medium.com\/v2\/resize:fit:828\/format:webp\/1*P2DLupXzej9mAP4EGPNc2w.png 828w, https:\/\/miro.medium.com\/v2\/resize:fit:1100\/format:webp\/1*P2DLupXzej9mAP4EGPNc2w.png 1100w, https:\/\/miro.medium.com\/v2\/resize:fit:1400\/format:webp\/1*P2DLupXzej9mAP4EGPNc2w.png 1400w\" type=\"image\/webp\" sizes=\"(min-resolution: 4dppx) and (max-width: 700px) 50vw, (-webkit-min-device-pixel-ratio: 4) and (max-width: 700px) 50vw, (min-resolution: 3dppx) and (max-width: 700px) 67vw, (-webkit-min-device-pixel-ratio: 3) and (max-width: 700px) 65vw, (min-resolution: 2.5dppx) and (max-width: 700px) 80vw, (-webkit-min-device-pixel-ratio: 2.5) and (max-width: 700px) 80vw, (min-resolution: 2dppx) and (max-width: 700px) 100vw, (-webkit-min-device-pixel-ratio: 2) and (max-width: 700px) 100vw, 700px\"><source srcset=\"https:\/\/miro.medium.com\/v2\/resize:fit:640\/1*P2DLupXzej9mAP4EGPNc2w.png 640w, https:\/\/miro.medium.com\/v2\/resize:fit:720\/1*P2DLupXzej9mAP4EGPNc2w.png 720w, https:\/\/miro.medium.com\/v2\/resize:fit:750\/1*P2DLupXzej9mAP4EGPNc2w.png 750w, https:\/\/miro.medium.com\/v2\/resize:fit:786\/1*P2DLupXzej9mAP4EGPNc2w.png 786w, https:\/\/miro.medium.com\/v2\/resize:fit:828\/1*P2DLupXzej9mAP4EGPNc2w.png 828w, https:\/\/miro.medium.com\/v2\/resize:fit:1100\/1*P2DLupXzej9mAP4EGPNc2w.png 1100w, https:\/\/miro.medium.com\/v2\/resize:fit:1400\/1*P2DLupXzej9mAP4EGPNc2w.png 1400w\" sizes=\"(min-resolution: 4dppx) and (max-width: 700px) 50vw, (-webkit-min-device-pixel-ratio: 4) and (max-width: 700px) 50vw, (min-resolution: 3dppx) and (max-width: 700px) 67vw, (-webkit-min-device-pixel-ratio: 3) and (max-width: 700px) 65vw, (min-resolution: 2.5dppx) and (max-width: 700px) 80vw, (-webkit-min-device-pixel-ratio: 2.5) and (max-width: 700px) 80vw, (min-resolution: 2dppx) and (max-width: 700px) 100vw, (-webkit-min-device-pixel-ratio: 2) and (max-width: 700px) 100vw, 700px\" data-testid=\"og\"><\/picture><\/div>\n<\/div>\n<figcaption class=\"mu mv mw mf mg mx my be b bf z dw\" data-selectable-paragraph=\"\">Image by Author<\/figcaption>\n<\/figure>\n<pre class=\"mi mj mk ml mm pg ph pi pj ax pk bj\"><span id=\"ce86\" class=\"mz na fp ph b ia pl pm l iq pn\" data-selectable-paragraph=\"\">from comet_ml import Experiment<\/span><span id=\"bba0\" class=\"mz na fp ph b ia qk pm l iq pn\" data-selectable-paragraph=\"\"># Create an experiment with your API key<\/span><span id=\"6882\" class=\"mz na fp ph b ia qk pm l iq pn\" data-selectable-paragraph=\"\">experiment = Experiment(\napi_key=\"xGZbEEC8bB2VnpxWFcWXd3BI3\",\nproject_name=\"Recommendation system\",\nworkspace=\"olujerry\",\n)\nexperiment.log_figure(figure_name=\"Matplotlib Viz\", figure=fig1)\nexperiment.log_figure(figure_name= \"Seaborn Viz\", figure=fig2)<\/span><\/pre>\n<p id=\"70dc\" class=\"pw-post-body-paragraph nx ny fp be b gn op oa ob gq oq od oe nk pc og oh no pd oj ok ns pe om on oo fi bj\" data-selectable-paragraph=\"\">We imported the <code class=\"cw qm qn qo ph b\">Experiment<\/code> library from<code class=\"cw qm qn qo ph b\"> <strong class=\"be qp\">comet ml<\/strong><\/code> into the code above. We then instantiated it and assigned it to the experiment variable. Your API key, the name of your project, and the name of your workspace are some of the parameters needed by the Experiment library. The Comet platform will display the workspace name, such as:<\/p>\n<figure class=\"mi mj mk ml mm mn mf mg paragraph-image\">\n<div class=\"mo mp ec mq bg mr\" tabindex=\"0\" role=\"button\">\n<figure><img loading=\"lazy\" decoding=\"async\" class=\"bg ms mt c\" role=\"presentation\" src=\"https:\/\/miro.medium.com\/v2\/resize:fit:700\/1*cLzvP2vCU7HYWg6PK4dUzw.png\" alt=\"\" width=\"700\" height=\"287\"><\/figure><div class=\"mf mg qq\"><picture><source srcset=\"https:\/\/miro.medium.com\/v2\/resize:fit:640\/format:webp\/1*cLzvP2vCU7HYWg6PK4dUzw.png 640w, https:\/\/miro.medium.com\/v2\/resize:fit:720\/format:webp\/1*cLzvP2vCU7HYWg6PK4dUzw.png 720w, https:\/\/miro.medium.com\/v2\/resize:fit:750\/format:webp\/1*cLzvP2vCU7HYWg6PK4dUzw.png 750w, https:\/\/miro.medium.com\/v2\/resize:fit:786\/format:webp\/1*cLzvP2vCU7HYWg6PK4dUzw.png 786w, https:\/\/miro.medium.com\/v2\/resize:fit:828\/format:webp\/1*cLzvP2vCU7HYWg6PK4dUzw.png 828w, https:\/\/miro.medium.com\/v2\/resize:fit:1100\/format:webp\/1*cLzvP2vCU7HYWg6PK4dUzw.png 1100w, https:\/\/miro.medium.com\/v2\/resize:fit:1400\/format:webp\/1*cLzvP2vCU7HYWg6PK4dUzw.png 1400w\" type=\"image\/webp\" sizes=\"(min-resolution: 4dppx) and (max-width: 700px) 50vw, (-webkit-min-device-pixel-ratio: 4) and (max-width: 700px) 50vw, (min-resolution: 3dppx) and (max-width: 700px) 67vw, (-webkit-min-device-pixel-ratio: 3) and (max-width: 700px) 65vw, (min-resolution: 2.5dppx) and (max-width: 700px) 80vw, (-webkit-min-device-pixel-ratio: 2.5) and (max-width: 700px) 80vw, (min-resolution: 2dppx) and (max-width: 700px) 100vw, (-webkit-min-device-pixel-ratio: 2) and (max-width: 700px) 100vw, 700px\"><source srcset=\"https:\/\/miro.medium.com\/v2\/resize:fit:640\/1*cLzvP2vCU7HYWg6PK4dUzw.png 640w, https:\/\/miro.medium.com\/v2\/resize:fit:720\/1*cLzvP2vCU7HYWg6PK4dUzw.png 720w, https:\/\/miro.medium.com\/v2\/resize:fit:750\/1*cLzvP2vCU7HYWg6PK4dUzw.png 750w, https:\/\/miro.medium.com\/v2\/resize:fit:786\/1*cLzvP2vCU7HYWg6PK4dUzw.png 786w, https:\/\/miro.medium.com\/v2\/resize:fit:828\/1*cLzvP2vCU7HYWg6PK4dUzw.png 828w, https:\/\/miro.medium.com\/v2\/resize:fit:1100\/1*cLzvP2vCU7HYWg6PK4dUzw.png 1100w, https:\/\/miro.medium.com\/v2\/resize:fit:1400\/1*cLzvP2vCU7HYWg6PK4dUzw.png 1400w\" sizes=\"(min-resolution: 4dppx) and (max-width: 700px) 50vw, (-webkit-min-device-pixel-ratio: 4) and (max-width: 700px) 50vw, (min-resolution: 3dppx) and (max-width: 700px) 67vw, (-webkit-min-device-pixel-ratio: 3) and (max-width: 700px) 65vw, (min-resolution: 2.5dppx) and (max-width: 700px) 80vw, (-webkit-min-device-pixel-ratio: 2.5) and (max-width: 700px) 80vw, (min-resolution: 2dppx) and (max-width: 700px) 100vw, (-webkit-min-device-pixel-ratio: 2) and (max-width: 700px) 100vw, 700px\" data-testid=\"og\"><\/picture><\/div>\n<\/div>\n<figcaption class=\"mu mv mw mf mg mx my be b bf z dw\" data-selectable-paragraph=\"\">Image By Author<\/figcaption>\n<\/figure>\n<pre class=\"mi mj mk ml mm pg ph pi pj ax pk bj\"><span id=\"2226\" class=\"mz na fp ph b ia pl pm l iq pn\" data-selectable-paragraph=\"\">experiment.log_figure(figure_name=\"Matplotlib Viz\", figure=fig1)experiment.log_figure(figure_name= \"Seaborn Viz\", figure=fig2)experiment.end()<\/span><\/pre>\n<p id=\"388b\" class=\"pw-post-body-paragraph nx ny fp be b gn op oa ob gq oq od oe nk pc og oh no pd oj ok ns pe om on oo fi bj\" data-selectable-paragraph=\"\">To log our visualization to the Comet Platform, use the two lines of code above. Seaborn Visualization and Matplotlib both use the<code class=\"cw qm qn qo ph b\">.log figure()<\/code>methods. Then we give our visualization a name.<\/p>\n<p id=\"1ae4\" class=\"pw-post-body-paragraph nx ny fp be b gn op oa ob gq oq od oe nk pc og oh no pd oj ok ns pe om on oo fi bj\" data-selectable-paragraph=\"\">Recall that we previously gave our visualizations the names fig1 and fig2, which we then pass to the figure parameter.<\/p>\n<p id=\"4254\" class=\"pw-post-body-paragraph nx ny fp be b gn op oa ob gq oq od oe nk pc og oh no pd oj ok ns pe om on oo fi bj\" data-selectable-paragraph=\"\">If you are using a notebook, such as Jupyter or Colab, you must type the <code class=\"cw qm qn qo ph b\">experiment.end ()<\/code> after your test.<\/p>\n<p id=\"f2a9\" class=\"pw-post-body-paragraph nx ny fp be b gn op oa ob gq oq od oe nk pc og oh no pd oj ok ns pe om on oo fi bj\" data-selectable-paragraph=\"\">We can now view our experiments on the project session on the <a href=\"https:\/\/drive.google.com\/file\/d\/1IlYj8JgqwzVdhG5ap_bQlP6vXIMPaTdm\/view?usp=sharing&amp;source=post_page-----2aeb14669c2e--------------------------------\">website<\/a>.<\/p>\n<h2 id=\"ff5f\" class=\"mz na fp be nb nc nd ne nf ng nh ni nj nk nl nm nn no np nq nr ns nt nu nv nw bj\" data-selectable-paragraph=\"\">Conclusion<\/h2>\n<p id=\"f3a2\" class=\"pw-post-body-paragraph nx ny fp be b gn nz oa ob gq oc od oe nk of og oh no oi oj ok ns ol om on oo fi bj\" data-selectable-paragraph=\"\">This article taught us how to incorporate our recommendation system into Comet. The majority of Python libraries for data science and machine learning are integrated with Comet. Check out some additional datasets that can be used to enhance the recommendation engine. The full code used in this tutorial can be found <a class=\"af pf\" href=\"https:\/\/github.com\/olujerry\/olujerry\/blob\/main\/Movie_Recommnedation_System.ipynb\" target=\"_blank\" rel=\"noopener ugc nofollow\">here.<\/a><\/p>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Photo Credit: Pexels.com Introduction Have you ever questioned how we can become so engrossed in watching videos on YouTube and how some of these posts end up on your Facebook or Instagram timeline? For those of us who are familiar with Netflix, we frequently receive recommendations for movies that are similar to the ones we [&hellip;]<\/p>\n","protected":false},"author":99,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"customer_name":"","customer_description":"","customer_industry":"","customer_technologies":"","customer_logo":"","footnotes":""},"categories":[9,7],"tags":[],"coauthors":[197],"class_list":["post-7842","post","type-post","status-publish","format-standard","hentry","category-product","category-tutorials"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v25.9 (Yoast SEO v25.9) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Logging Recommendation System Visualizations in Comet - Comet<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.comet.com\/site\/blog\/logging-recommendation-system-visualizations-in-comet\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Logging Recommendation System Visualizations in Comet\" \/>\n<meta property=\"og:description\" content=\"Photo Credit: Pexels.com Introduction Have you ever questioned how we can become so engrossed in watching videos on YouTube and how some of these posts end up on your Facebook or Instagram timeline? For those of us who are familiar with Netflix, we frequently receive recommendations for movies that are similar to the ones we [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.comet.com\/site\/blog\/logging-recommendation-system-visualizations-in-comet\/\" \/>\n<meta property=\"og:site_name\" content=\"Comet\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/cometdotml\" \/>\n<meta property=\"article:published_time\" content=\"2023-10-06T20:38:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-04-24T17:05:57+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/miro.medium.com\/v2\/resize:fit:700\/1*Pe6ibd8O4G225zvqGA1wNQ.jpeg\" \/>\n<meta name=\"author\" content=\"Jeremiah Oluseye\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@Cometml\" \/>\n<meta name=\"twitter:site\" content=\"@Cometml\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Jeremiah Oluseye\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"9 minutes\" \/>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Logging Recommendation System Visualizations in Comet - Comet","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.comet.com\/site\/blog\/logging-recommendation-system-visualizations-in-comet\/","og_locale":"en_US","og_type":"article","og_title":"Logging Recommendation System Visualizations in Comet","og_description":"Photo Credit: Pexels.com Introduction Have you ever questioned how we can become so engrossed in watching videos on YouTube and how some of these posts end up on your Facebook or Instagram timeline? For those of us who are familiar with Netflix, we frequently receive recommendations for movies that are similar to the ones we [&hellip;]","og_url":"https:\/\/www.comet.com\/site\/blog\/logging-recommendation-system-visualizations-in-comet\/","og_site_name":"Comet","article_publisher":"https:\/\/www.facebook.com\/cometdotml","article_published_time":"2023-10-06T20:38:00+00:00","article_modified_time":"2025-04-24T17:05:57+00:00","og_image":[{"url":"https:\/\/miro.medium.com\/v2\/resize:fit:700\/1*Pe6ibd8O4G225zvqGA1wNQ.jpeg","type":"","width":"","height":""}],"author":"Jeremiah Oluseye","twitter_card":"summary_large_image","twitter_creator":"@Cometml","twitter_site":"@Cometml","twitter_misc":{"Written by":"Jeremiah Oluseye","Est. reading time":"9 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.comet.com\/site\/blog\/logging-recommendation-system-visualizations-in-comet\/#article","isPartOf":{"@id":"https:\/\/www.comet.com\/site\/blog\/logging-recommendation-system-visualizations-in-comet\/"},"author":{"name":"Jeremiah Oluseye","@id":"https:\/\/www.comet.com\/site\/#\/schema\/person\/73f233b4e35ab400cb753ebd29e58621"},"headline":"Logging Recommendation System Visualizations in Comet","datePublished":"2023-10-06T20:38:00+00:00","dateModified":"2025-04-24T17:05:57+00:00","mainEntityOfPage":{"@id":"https:\/\/www.comet.com\/site\/blog\/logging-recommendation-system-visualizations-in-comet\/"},"wordCount":1503,"publisher":{"@id":"https:\/\/www.comet.com\/site\/#organization"},"image":{"@id":"https:\/\/www.comet.com\/site\/blog\/logging-recommendation-system-visualizations-in-comet\/#primaryimage"},"thumbnailUrl":"https:\/\/miro.medium.com\/v2\/resize:fit:700\/1*Pe6ibd8O4G225zvqGA1wNQ.jpeg","articleSection":["Product","Tutorials"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.comet.com\/site\/blog\/logging-recommendation-system-visualizations-in-comet\/","url":"https:\/\/www.comet.com\/site\/blog\/logging-recommendation-system-visualizations-in-comet\/","name":"Logging Recommendation System Visualizations in Comet - Comet","isPartOf":{"@id":"https:\/\/www.comet.com\/site\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.comet.com\/site\/blog\/logging-recommendation-system-visualizations-in-comet\/#primaryimage"},"image":{"@id":"https:\/\/www.comet.com\/site\/blog\/logging-recommendation-system-visualizations-in-comet\/#primaryimage"},"thumbnailUrl":"https:\/\/miro.medium.com\/v2\/resize:fit:700\/1*Pe6ibd8O4G225zvqGA1wNQ.jpeg","datePublished":"2023-10-06T20:38:00+00:00","dateModified":"2025-04-24T17:05:57+00:00","breadcrumb":{"@id":"https:\/\/www.comet.com\/site\/blog\/logging-recommendation-system-visualizations-in-comet\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.comet.com\/site\/blog\/logging-recommendation-system-visualizations-in-comet\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.comet.com\/site\/blog\/logging-recommendation-system-visualizations-in-comet\/#primaryimage","url":"https:\/\/miro.medium.com\/v2\/resize:fit:700\/1*Pe6ibd8O4G225zvqGA1wNQ.jpeg","contentUrl":"https:\/\/miro.medium.com\/v2\/resize:fit:700\/1*Pe6ibd8O4G225zvqGA1wNQ.jpeg"},{"@type":"BreadcrumbList","@id":"https:\/\/www.comet.com\/site\/blog\/logging-recommendation-system-visualizations-in-comet\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.comet.com\/site\/"},{"@type":"ListItem","position":2,"name":"Logging Recommendation System Visualizations in Comet"}]},{"@type":"WebSite","@id":"https:\/\/www.comet.com\/site\/#website","url":"https:\/\/www.comet.com\/site\/","name":"Comet","description":"Build Better Models Faster","publisher":{"@id":"https:\/\/www.comet.com\/site\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.comet.com\/site\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.comet.com\/site\/#organization","name":"Comet ML, Inc.","alternateName":"Comet","url":"https:\/\/www.comet.com\/site\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.comet.com\/site\/#\/schema\/logo\/image\/","url":"https:\/\/www.comet.com\/site\/wp-content\/uploads\/2025\/01\/logo_comet_square.png","contentUrl":"https:\/\/www.comet.com\/site\/wp-content\/uploads\/2025\/01\/logo_comet_square.png","width":310,"height":310,"caption":"Comet ML, Inc."},"image":{"@id":"https:\/\/www.comet.com\/site\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/cometdotml","https:\/\/x.com\/Cometml","https:\/\/www.youtube.com\/channel\/UCmN63HKvfXSCS-UwVwmK8Hw"]},{"@type":"Person","@id":"https:\/\/www.comet.com\/site\/#\/schema\/person\/73f233b4e35ab400cb753ebd29e58621","name":"Jeremiah Oluseye","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.comet.com\/site\/#\/schema\/person\/image\/5534a0faf067d6eb66a7f0c328629fbf","url":"https:\/\/www.comet.com\/site\/wp-content\/uploads\/2023\/10\/cropped-mBj9qH7g_400x400-96x96.jpg","contentUrl":"https:\/\/www.comet.com\/site\/wp-content\/uploads\/2023\/10\/cropped-mBj9qH7g_400x400-96x96.jpg","caption":"Jeremiah Oluseye"},"url":"https:\/\/www.comet.com\/site\/blog\/author\/oluseyejeremiahgmail-com\/"}]}},"_links":{"self":[{"href":"https:\/\/www.comet.com\/site\/wp-json\/wp\/v2\/posts\/7842","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.comet.com\/site\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.comet.com\/site\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.comet.com\/site\/wp-json\/wp\/v2\/users\/99"}],"replies":[{"embeddable":true,"href":"https:\/\/www.comet.com\/site\/wp-json\/wp\/v2\/comments?post=7842"}],"version-history":[{"count":1,"href":"https:\/\/www.comet.com\/site\/wp-json\/wp\/v2\/posts\/7842\/revisions"}],"predecessor-version":[{"id":15516,"href":"https:\/\/www.comet.com\/site\/wp-json\/wp\/v2\/posts\/7842\/revisions\/15516"}],"wp:attachment":[{"href":"https:\/\/www.comet.com\/site\/wp-json\/wp\/v2\/media?parent=7842"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.comet.com\/site\/wp-json\/wp\/v2\/categories?post=7842"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.comet.com\/site\/wp-json\/wp\/v2\/tags?post=7842"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.comet.com\/site\/wp-json\/wp\/v2\/coauthors?post=7842"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}