"evalue": "cannot import name 'Constant' from 'constants' (/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/constants.py)",
"\u001b[0;31mImportError\u001b[0m: cannot import name 'Constant' from 'constants' (/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/constants.py)"
"name": "stdout",
"output_type": "stream",
"text": [
"Display The Movies : \n"
]
},
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>title</th>\n",
" <th>genres</th>\n",
" </tr>\n",
" <tr>\n",
" <th>movieId</th>\n",
" <th></th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>Grumpier Old Men (1995)</td>\n",
" <td>Comedy|Romance</td>\n",
" </tr>\n",
" <tr>\n",
" <th>15</th>\n",
" <td>Cutthroat Island (1995)</td>\n",
" <td>Action|Adventure|Romance</td>\n",
" </tr>\n",
" <tr>\n",
" <th>34</th>\n",
" <td>Babe (1995)</td>\n",
" <td>Children|Drama</td>\n",
" </tr>\n",
" <tr>\n",
" <th>59</th>\n",
" <td>Confessional, The (Confessionnal, Le) (1995)</td>\n",
" <td>Drama|Mystery</td>\n",
" </tr>\n",
" <tr>\n",
" <th>64</th>\n",
" <td>Two if by Sea (1996)</td>\n",
" <td>Comedy|Romance</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>148652</th>\n",
" <td>The Ridiculous 6 (2015)</td>\n",
" <td>Comedy|Western</td>\n",
" </tr>\n",
" <tr>\n",
" <th>151307</th>\n",
" <td>The Lovers and the Despot</td>\n",
" <td>(no genres listed)</td>\n",
" </tr>\n",
" <tr>\n",
" <th>152173</th>\n",
" <td>Michael Jackson's Thriller (1983)</td>\n",
" <td>Horror</td>\n",
" </tr>\n",
" <tr>\n",
" <th>160440</th>\n",
" <td>The Maid's Room (2014)</td>\n",
" <td>Thriller</td>\n",
" </tr>\n",
" <tr>\n",
" <th>160656</th>\n",
" <td>Tallulah (2016)</td>\n",
" <td>Drama</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>912 rows × 2 columns</p>\n",
"</div>"
],
"text/plain": [
" title \\\n",
"movieId \n",
"3 Grumpier Old Men (1995) \n",
"15 Cutthroat Island (1995) \n",
"34 Babe (1995) \n",
"59 Confessional, The (Confessionnal, Le) (1995) \n",
"64 Two if by Sea (1996) \n",
"... ... \n",
"148652 The Ridiculous 6 (2015) \n",
"151307 The Lovers and the Despot \n",
"152173 Michael Jackson's Thriller (1983) \n",
"160440 The Maid's Room (2014) \n",
"160656 Tallulah (2016) \n",
"\n",
" genres \n",
"movieId \n",
"3 Comedy|Romance \n",
"15 Action|Adventure|Romance \n",
"34 Children|Drama \n",
"59 Drama|Mystery \n",
"64 Comedy|Romance \n",
"... ... \n",
"148652 Comedy|Western \n",
"151307 (no genres listed) \n",
"152173 Horror \n",
"160440 Thriller \n",
"160656 Drama \n",
"\n",
"[912 rows x 2 columns]"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Display The Ratings : \n"
]
},
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>userId</th>\n",
" <th>movieId</th>\n",
" <th>rating</th>\n",
" <th>timestamp</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>15</td>\n",
" <td>34</td>\n",
" <td>3.0</td>\n",
" <td>997938310</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>15</td>\n",
" <td>95</td>\n",
" <td>1.5</td>\n",
" <td>1093028331</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>15</td>\n",
" <td>101</td>\n",
" <td>4.0</td>\n",
" <td>1134522072</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>15</td>\n",
" <td>123</td>\n",
" <td>4.0</td>\n",
" <td>997938358</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>15</td>\n",
" <td>125</td>\n",
" <td>3.5</td>\n",
" <td>1245362506</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5291</th>\n",
" <td>665</td>\n",
" <td>3908</td>\n",
" <td>1.0</td>\n",
" <td>1046967201</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5292</th>\n",
" <td>665</td>\n",
" <td>4052</td>\n",
" <td>4.0</td>\n",
" <td>992838277</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5293</th>\n",
" <td>665</td>\n",
" <td>4351</td>\n",
" <td>4.0</td>\n",
" <td>992837743</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5294</th>\n",
" <td>665</td>\n",
" <td>4643</td>\n",
" <td>4.0</td>\n",
" <td>997239207</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5295</th>\n",
" <td>665</td>\n",
" <td>5502</td>\n",
" <td>4.0</td>\n",
" <td>1046967596</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>5296 rows × 4 columns</p>\n",
"</div>"
],
"text/plain": [
" userId movieId rating timestamp\n",
"0 15 34 3.0 997938310\n",
"1 15 95 1.5 1093028331\n",
"2 15 101 4.0 1134522072\n",
"3 15 123 4.0 997938358\n",
"4 15 125 3.5 1245362506\n",
"... ... ... ... ...\n",
"5291 665 3908 1.0 1046967201\n",
"5292 665 4052 4.0 992838277\n",
"5293 665 4351 4.0 992837743\n",
"5294 665 4643 4.0 997239207\n",
"5295 665 5502 4.0 1046967596\n",
"\n",
"[5296 rows x 4 columns]"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
...
...
@@ -52,7 +311,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 2,
"metadata": {},
"outputs": [
{
...
...
@@ -71,7 +330,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 3,
"metadata": {},
"outputs": [
{
...
...
@@ -96,7 +355,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 4,
"metadata": {},
"outputs": [
{
...
...
@@ -148,7 +407,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 5,
"metadata": {},
"outputs": [
{
...
...
@@ -167,7 +426,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 6,
"metadata": {},
"outputs": [
{
...
...
@@ -186,7 +445,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 7,
"metadata": {},
"outputs": [
{
...
...
@@ -206,7 +465,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 8,
"metadata": {},
"outputs": [
{
...
...
@@ -229,7 +488,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 9,
"metadata": {},
"outputs": [
{
...
...
@@ -252,7 +511,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 10,
"metadata": {},
"outputs": [
{
...
...
@@ -286,7 +545,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 11,
"metadata": {},
"outputs": [
{
...
...
@@ -316,7 +575,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 12,
"metadata": {},
"outputs": [
{
...
...
@@ -349,7 +608,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 13,
"metadata": {},
"outputs": [],
"source": [
...
...
@@ -366,7 +625,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 14,
"metadata": {},
"outputs": [
{
...
...
@@ -429,7 +688,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 15,
"metadata": {},
"outputs": [
{
...
...
%% Cell type:code id: tags:
``` python
# Reload modules automatically before entering the execution of code
%load_extautoreload
%autoreload2
# Third-party imports
importnumpyasnp
importpandasaspd
importmatplotlib.pyplotasplt
fromscipy.sparseimportcsr_matrix
# Constants and functions
fromconstantsimportConstantasC
fromloadersimportload_ratings
fromloadersimportload_items
fromtabulateimporttabulate
# Call the load_items() function and create a variable df_items
df_movies=load_items()
# Display the DataFrame
print("Display The Movies : ")
display(df_movies)
# Call the load_ratings() function and create a variable df_ratings
ImportError: cannot import name 'Constant' from 'constants' (/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/constants.py)
"evalue": "cannot import name 'Constant' from 'constants' (/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/constants.py)",
"\u001b[0;31mImportError\u001b[0m: cannot import name 'Constant' from 'constants' (/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/constants.py)"
"name": "stdout",
"output_type": "stream",
"text": [
"The autoreload extension is already loaded. To reload it, use:\n",
8 from surprise.prediction_algorithms.predictions import PredictionImpossible
---> 10 from loaders import load_ratings
11 from loaders import load_items
12 from constants import Constant as C
File ~/vscodeworkspace/recomsys/loaders.py:7
3 import os
6 # Local imports
----> 7 from constants import Constant as C
8 from surprise import Reader, Dataset
10 def load_ratings(surprise_format=False):
ImportError: cannot import name 'Constant' from 'constants' (/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/constants.py)
The autoreload extension is already loaded. To reload it, use: