Skip to content
Extraits de code Groupes Projets
Valider a7d53d16 rédigé par Adrien Payen's avatar Adrien Payen
Parcourir les fichiers

commit fin de reu

parent e0316f41
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Pipeline #47679 en échec
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
#reloads modules automatically before entering the execution of code #reloads modules automatically before entering the execution of code
# %load_ext autoreload %load_ext autoreload
# %autoreload 2 %autoreload 2
# third parties imports # third parties imports
import numpy as np import numpy as np
import pandas as pd import pandas as pd
import re import re
from constants import Constant as C from constants import Constant as C
from loaders import load_ratings from loaders import load_ratings
from loaders import load_items from loaders import load_items
load_items()
load_ratings()
``` ```
%% Output
Display the ratings
---------------------------------------------------------------------------
FileNotFoundError Traceback (most recent call last)
Cell In[1], line 10
8 import re
9 from constants import Constant as C
---> 10 from loaders import load_ratings
11 from loaders import load_items
13 load_items()
File ~/vscodeworkspace/recomsys/Analytics_UI/loaders.py:41
39 print("\n")
40 print("Display the ratings")
---> 41 pp(load_ratings())
42 print("\n\n")
43 print("Display the movie data")
File ~/vscodeworkspace/recomsys/Analytics_UI/loaders.py:12, in load_ratings(surprise_format)
11 def load_ratings(surprise_format=False):
---> 12 df_ratings = pd.read_csv(C.EVIDENCE_PATH / C.RATINGS_FILENAME)
13 if surprise_format:
14 pass
File /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/pandas/io/parsers/readers.py:948, in read_csv(filepath_or_buffer, sep, delimiter, header, names, index_col, usecols, dtype, engine, converters, true_values, false_values, skipinitialspace, skiprows, skipfooter, nrows, na_values, keep_default_na, na_filter, verbose, skip_blank_lines, parse_dates, infer_datetime_format, keep_date_col, date_parser, date_format, dayfirst, cache_dates, iterator, chunksize, compression, thousands, decimal, lineterminator, quotechar, quoting, doublequote, escapechar, comment, encoding, encoding_errors, dialect, on_bad_lines, delim_whitespace, low_memory, memory_map, float_precision, storage_options, dtype_backend)
935 kwds_defaults = _refine_defaults_read(
936 dialect,
937 delimiter,
(...)
944 dtype_backend=dtype_backend,
945 )
946 kwds.update(kwds_defaults)
--> 948 return _read(filepath_or_buffer, kwds)
File /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/pandas/io/parsers/readers.py:611, in _read(filepath_or_buffer, kwds)
608 _validate_names(kwds.get("names", None))
610 # Create the parser.
--> 611 parser = TextFileReader(filepath_or_buffer, **kwds)
613 if chunksize or iterator:
614 return parser
File /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/pandas/io/parsers/readers.py:1448, in TextFileReader.__init__(self, f, engine, **kwds)
1445 self.options["has_index_names"] = kwds["has_index_names"]
1447 self.handles: IOHandles | None = None
-> 1448 self._engine = self._make_engine(f, self.engine)
File /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/pandas/io/parsers/readers.py:1705, in TextFileReader._make_engine(self, f, engine)
1703 if "b" not in mode:
1704 mode += "b"
-> 1705 self.handles = get_handle(
1706 f,
1707 mode,
1708 encoding=self.options.get("encoding", None),
1709 compression=self.options.get("compression", None),
1710 memory_map=self.options.get("memory_map", False),
1711 is_text=is_text,
1712 errors=self.options.get("encoding_errors", "strict"),
1713 storage_options=self.options.get("storage_options", None),
1714 )
1715 assert self.handles is not None
1716 f = self.handles.handle
File /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/pandas/io/common.py:863, in get_handle(path_or_buf, mode, encoding, compression, memory_map, is_text, errors, storage_options)
858 elif isinstance(handle, str):
859 # Check whether the filename is to be opened in binary mode.
860 # Binary mode does not support 'encoding' and 'newline'.
861 if ioargs.encoding and "b" not in ioargs.mode:
862 # Encoding
--> 863 handle = open(
864 handle,
865 ioargs.mode,
866 encoding=ioargs.encoding,
867 errors=errors,
868 newline="",
869 )
870 else:
871 # Binary mode
872 handle = open(handle, ioargs.mode)
FileNotFoundError: [Errno 2] No such file or directory: 'data/small/evidence/ratings.csv'
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
# NUMBER OF MOVIES # NUMBER OF MOVIES
df_movies = pd.read_csv("data/small/content/movies.csv") df_movies = pd.read_csv("data/small/content/movies.csv")
n_movies = df_movies['title'].nunique() n_movies = df_movies['title'].nunique()
print("\n") print("\n")
print(f"Number of movies: {n_movies}") print(f"Number of movies: {n_movies}")
``` ```
%% Output
---------------------------------------------------------------------------
FileNotFoundError Traceback (most recent call last)
Cell In[10], line 2
1 # NUMBER OF MOVIES
----> 2 df_movies = pd.read_csv("data/small/content/movies.csv")
3 n_movies = df_movies['title'].nunique()
5 print("\n")
File /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/pandas/io/parsers/readers.py:948, in read_csv(filepath_or_buffer, sep, delimiter, header, names, index_col, usecols, dtype, engine, converters, true_values, false_values, skipinitialspace, skiprows, skipfooter, nrows, na_values, keep_default_na, na_filter, verbose, skip_blank_lines, parse_dates, infer_datetime_format, keep_date_col, date_parser, date_format, dayfirst, cache_dates, iterator, chunksize, compression, thousands, decimal, lineterminator, quotechar, quoting, doublequote, escapechar, comment, encoding, encoding_errors, dialect, on_bad_lines, delim_whitespace, low_memory, memory_map, float_precision, storage_options, dtype_backend)
935 kwds_defaults = _refine_defaults_read(
936 dialect,
937 delimiter,
(...)
944 dtype_backend=dtype_backend,
945 )
946 kwds.update(kwds_defaults)
--> 948 return _read(filepath_or_buffer, kwds)
File /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/pandas/io/parsers/readers.py:611, in _read(filepath_or_buffer, kwds)
608 _validate_names(kwds.get("names", None))
610 # Create the parser.
--> 611 parser = TextFileReader(filepath_or_buffer, **kwds)
613 if chunksize or iterator:
614 return parser
File /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/pandas/io/parsers/readers.py:1448, in TextFileReader.__init__(self, f, engine, **kwds)
1445 self.options["has_index_names"] = kwds["has_index_names"]
1447 self.handles: IOHandles | None = None
-> 1448 self._engine = self._make_engine(f, self.engine)
File /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/pandas/io/parsers/readers.py:1705, in TextFileReader._make_engine(self, f, engine)
1703 if "b" not in mode:
1704 mode += "b"
-> 1705 self.handles = get_handle(
1706 f,
1707 mode,
1708 encoding=self.options.get("encoding", None),
1709 compression=self.options.get("compression", None),
1710 memory_map=self.options.get("memory_map", False),
1711 is_text=is_text,
1712 errors=self.options.get("encoding_errors", "strict"),
1713 storage_options=self.options.get("storage_options", None),
1714 )
1715 assert self.handles is not None
1716 f = self.handles.handle
File /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/pandas/io/common.py:863, in get_handle(path_or_buf, mode, encoding, compression, memory_map, is_text, errors, storage_options)
858 elif isinstance(handle, str):
859 # Check whether the filename is to be opened in binary mode.
860 # Binary mode does not support 'encoding' and 'newline'.
861 if ioargs.encoding and "b" not in ioargs.mode:
862 # Encoding
--> 863 handle = open(
864 handle,
865 ioargs.mode,
866 encoding=ioargs.encoding,
867 errors=errors,
868 newline="",
869 )
870 else:
871 # Binary mode
872 handle = open(handle, ioargs.mode)
FileNotFoundError: [Errno 2] No such file or directory: 'data/small/content/movies.csv'
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
# THE YEAR RANGE # THE YEAR RANGE
df_movies['annee'] = df_movies['title'].str.extract(r'\((.{4})\)') df_movies['annee'] = df_movies['title'].str.extract(r'\((.{4})\)')
df_movies['annee'] = pd.to_numeric(df_movies['annee'], errors='coerce') df_movies['annee'] = pd.to_numeric(df_movies['annee'], errors='coerce')
# Trouver le range minimum et maximum # Trouver le range minimum et maximum
min_range = int(df_movies['annee'].min()) min_range = int(df_movies['annee'].min())
max_range = int(df_movies['annee'].max()) max_range = int(df_movies['annee'].max())
# Afficher le range minimum et maximum # Afficher le range minimum et maximum
print("\n") print("\n")
print(f"Minimum range: {min_range}") print(f"Minimum range: {min_range}")
print(f"Maximum range: {max_range}") print(f"Maximum range: {max_range}")
``` ```
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
# LIST OF MOVIE GENRES # LIST OF MOVIE GENRES
df_movies['genres'] = df_movies['genres'].str.split('|') df_movies['genres'] = df_movies['genres'].str.split('|')
df_movies = df_movies.explode('genres') df_movies = df_movies.explode('genres')
# Afficher tous les genres uniques # Afficher tous les genres uniques
unique_genres = sorted(df_movies['genres'].unique()) unique_genres = sorted(df_movies['genres'].unique())
print("List of all genres:") print("List of all genres:")
for genre in unique_genres: for genre in unique_genres:
print(genre, "|", end = " ") print(genre, "|", end = " ")
``` ```
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
# THE TOTAL NUMBER OF RATINGS # THE TOTAL NUMBER OF RATINGS
df_ratings = pd.read_csv("data/small/evidence/ratings.csv") df_ratings = pd.read_csv("data/small/evidence/ratings.csv")
n_ratings = df_ratings['rating'].count() n_ratings = df_ratings['rating'].count()
print(f"Number of ratings: {n_ratings}") print(f"Number of ratings: {n_ratings}")
``` ```
%% Output %% Output
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
FileNotFoundError Traceback (most recent call last) FileNotFoundError Traceback (most recent call last)
Cell In[2], line 2 Cell In[2], line 2
1 # THE TOTAL NUMBER OF RATINGS 1 # THE TOTAL NUMBER OF RATINGS
----> 2 df_ratings = pd.read_csv("data/small/evidence/ratings.csv") ----> 2 df_ratings = pd.read_csv("data/small/evidence/ratings.csv")
3 n_ratings = df_ratings['rating'].count() 3 n_ratings = df_ratings['rating'].count()
4 print(f"Number of ratings: {n_ratings}") 4 print(f"Number of ratings: {n_ratings}")
File /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/pandas/io/parsers/readers.py:948, in read_csv(filepath_or_buffer, sep, delimiter, header, names, index_col, usecols, dtype, engine, converters, true_values, false_values, skipinitialspace, skiprows, skipfooter, nrows, na_values, keep_default_na, na_filter, verbose, skip_blank_lines, parse_dates, infer_datetime_format, keep_date_col, date_parser, date_format, dayfirst, cache_dates, iterator, chunksize, compression, thousands, decimal, lineterminator, quotechar, quoting, doublequote, escapechar, comment, encoding, encoding_errors, dialect, on_bad_lines, delim_whitespace, low_memory, memory_map, float_precision, storage_options, dtype_backend) File /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/pandas/io/parsers/readers.py:948, in read_csv(filepath_or_buffer, sep, delimiter, header, names, index_col, usecols, dtype, engine, converters, true_values, false_values, skipinitialspace, skiprows, skipfooter, nrows, na_values, keep_default_na, na_filter, verbose, skip_blank_lines, parse_dates, infer_datetime_format, keep_date_col, date_parser, date_format, dayfirst, cache_dates, iterator, chunksize, compression, thousands, decimal, lineterminator, quotechar, quoting, doublequote, escapechar, comment, encoding, encoding_errors, dialect, on_bad_lines, delim_whitespace, low_memory, memory_map, float_precision, storage_options, dtype_backend)
935 kwds_defaults = _refine_defaults_read( 935 kwds_defaults = _refine_defaults_read(
936 dialect, 936 dialect,
937 delimiter, 937 delimiter,
(...) (...)
944 dtype_backend=dtype_backend, 944 dtype_backend=dtype_backend,
945 ) 945 )
946 kwds.update(kwds_defaults) 946 kwds.update(kwds_defaults)
--> 948 return _read(filepath_or_buffer, kwds) --> 948 return _read(filepath_or_buffer, kwds)
File /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/pandas/io/parsers/readers.py:611, in _read(filepath_or_buffer, kwds) File /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/pandas/io/parsers/readers.py:611, in _read(filepath_or_buffer, kwds)
608 _validate_names(kwds.get("names", None)) 608 _validate_names(kwds.get("names", None))
610 # Create the parser. 610 # Create the parser.
--> 611 parser = TextFileReader(filepath_or_buffer, **kwds) --> 611 parser = TextFileReader(filepath_or_buffer, **kwds)
613 if chunksize or iterator: 613 if chunksize or iterator:
614 return parser 614 return parser
File /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/pandas/io/parsers/readers.py:1448, in TextFileReader.__init__(self, f, engine, **kwds) File /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/pandas/io/parsers/readers.py:1448, in TextFileReader.__init__(self, f, engine, **kwds)
1445 self.options["has_index_names"] = kwds["has_index_names"] 1445 self.options["has_index_names"] = kwds["has_index_names"]
1447 self.handles: IOHandles | None = None 1447 self.handles: IOHandles | None = None
-> 1448 self._engine = self._make_engine(f, self.engine) -> 1448 self._engine = self._make_engine(f, self.engine)
File /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/pandas/io/parsers/readers.py:1705, in TextFileReader._make_engine(self, f, engine) File /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/pandas/io/parsers/readers.py:1705, in TextFileReader._make_engine(self, f, engine)
1703 if "b" not in mode: 1703 if "b" not in mode:
1704 mode += "b" 1704 mode += "b"
-> 1705 self.handles = get_handle( -> 1705 self.handles = get_handle(
1706 f, 1706 f,
1707 mode, 1707 mode,
1708 encoding=self.options.get("encoding", None), 1708 encoding=self.options.get("encoding", None),
1709 compression=self.options.get("compression", None), 1709 compression=self.options.get("compression", None),
1710 memory_map=self.options.get("memory_map", False), 1710 memory_map=self.options.get("memory_map", False),
1711 is_text=is_text, 1711 is_text=is_text,
1712 errors=self.options.get("encoding_errors", "strict"), 1712 errors=self.options.get("encoding_errors", "strict"),
1713 storage_options=self.options.get("storage_options", None), 1713 storage_options=self.options.get("storage_options", None),
1714 ) 1714 )
1715 assert self.handles is not None 1715 assert self.handles is not None
1716 f = self.handles.handle 1716 f = self.handles.handle
File /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/pandas/io/common.py:863, in get_handle(path_or_buf, mode, encoding, compression, memory_map, is_text, errors, storage_options) File /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/pandas/io/common.py:863, in get_handle(path_or_buf, mode, encoding, compression, memory_map, is_text, errors, storage_options)
858 elif isinstance(handle, str): 858 elif isinstance(handle, str):
859 # Check whether the filename is to be opened in binary mode. 859 # Check whether the filename is to be opened in binary mode.
860 # Binary mode does not support 'encoding' and 'newline'. 860 # Binary mode does not support 'encoding' and 'newline'.
861 if ioargs.encoding and "b" not in ioargs.mode: 861 if ioargs.encoding and "b" not in ioargs.mode:
862 # Encoding 862 # Encoding
--> 863 handle = open( --> 863 handle = open(
864 handle, 864 handle,
865 ioargs.mode, 865 ioargs.mode,
866 encoding=ioargs.encoding, 866 encoding=ioargs.encoding,
867 errors=errors, 867 errors=errors,
868 newline="", 868 newline="",
869 ) 869 )
870 else: 870 else:
871 # Binary mode 871 # Binary mode
872 handle = open(handle, ioargs.mode) 872 handle = open(handle, ioargs.mode)
FileNotFoundError: [Errno 2] No such file or directory: 'data/small/evidence/ratings.csv' FileNotFoundError: [Errno 2] No such file or directory: 'data/small/evidence/ratings.csv'
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
# THE NUMBER OF UNIQUE USERS # THE NUMBER OF UNIQUE USERS
df_ratings = pd.read_csv("data/small/evidence/ratings.csv") df_ratings = pd.read_csv("data/small/evidence/ratings.csv")
n_users = df_ratings['userId'].nunique() n_users = df_ratings['userId'].nunique()
print(f"Number of users: {n_users}") print(f"Number of users: {n_users}")
``` ```
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
# THE NUMBER OF UNIQUE MOVIES (IN THE RATING MATRIX) # THE NUMBER OF UNIQUE MOVIES (IN THE RATING MATRIX)
``` ```
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
# THE NUMBER OF RATINGS OF THE MOST RATED MOVIES # THE NUMBER OF RATINGS OF THE MOST RATED MOVIES
def most_rated_movies_ratings_count(csv_file): def most_rated_movies_ratings_count(csv_file):
# Charger le DataFrame des évaluations à partir du fichier CSV # Charger le DataFrame des évaluations à partir du fichier CSV
df_ratings = pd.read_csv(csv_file) df_ratings = pd.read_csv(csv_file)
# Grouper les évaluations par 'movieId' et compter le nombre de notes pour chaque film # Grouper les évaluations par 'movieId' et compter le nombre de notes pour chaque film
movie_ratings_count = df_ratings.groupby('movieId')['rating'].count() movie_ratings_count = df_ratings.groupby('movieId')['rating'].count()
# Trouver le(s) film(s) le(s) plus évalué(s) # Trouver le(s) film(s) le(s) plus évalué(s)
most_rated_movies = movie_ratings_count[movie_ratings_count == movie_ratings_count.max()] most_rated_movies = movie_ratings_count[movie_ratings_count == movie_ratings_count.max()]
# Afficher le nombre de notes du film (ou des films) le(s) plus évalué(s) # Afficher le nombre de notes du film (ou des films) le(s) plus évalué(s)
print("Number of ratings of the most rated movie(s):", most_rated_movies.max()) print("Number of ratings of the most rated movie(s):", most_rated_movies.max())
# Exemple d'utilisation de la fonction avec le chemin du fichier CSV # Exemple d'utilisation de la fonction avec le chemin du fichier CSV
most_rated_movies_ratings_count("data/small/evidence/ratings.csv") most_rated_movies_ratings_count("data/small/evidence/ratings.csv")
``` ```
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
# THE NUMBER OF RATINGS OF THE LESS RATED MOVIES # THE NUMBER OF RATINGS OF THE LESS RATED MOVIES
def least_rated_movies_ratings_count(csv_file): def least_rated_movies_ratings_count(csv_file):
# Charger le DataFrame des évaluations à partir du fichier CSV # Charger le DataFrame des évaluations à partir du fichier CSV
df_ratings = pd.read_csv(csv_file) df_ratings = pd.read_csv(csv_file)
# Grouper les évaluations par 'movieId' et compter le nombre de notes pour chaque film # Grouper les évaluations par 'movieId' et compter le nombre de notes pour chaque film
movie_ratings_count = df_ratings.groupby('movieId')['rating'].count() movie_ratings_count = df_ratings.groupby('movieId')['rating'].count()
# Trouver le(s) film(s) le(s) moins évalué(s) # Trouver le(s) film(s) le(s) moins évalué(s)
least_rated_movies = movie_ratings_count[movie_ratings_count == movie_ratings_count.min()] least_rated_movies = movie_ratings_count[movie_ratings_count == movie_ratings_count.min()]
# Afficher le nombre de notes du film (ou des films) le(s) moins évalué(s) # Afficher le nombre de notes du film (ou des films) le(s) moins évalué(s)
print("Number of ratings of the least rated movie(s):", least_rated_movies.min()) print("Number of ratings of the least rated movie(s):", least_rated_movies.min())
# Exemple d'utilisation de la fonction avec le chemin du fichier CSV # Exemple d'utilisation de la fonction avec le chemin du fichier CSV
least_rated_movies_ratings_count("data/small/evidence/ratings.csv") least_rated_movies_ratings_count("data/small/evidence/ratings.csv")
``` ```
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
# ALL THE POSSIBLE RATING VALUES; FROM THE SMALLEST VALUE TO THE VALUE HIGHEST # ALL THE POSSIBLE RATING VALUES; FROM THE SMALLEST VALUE TO THE VALUE HIGHEST
def all_possible_ratings(csv_file): def all_possible_ratings(csv_file):
# Charger le DataFrame des évaluations à partir du fichier CSV # Charger le DataFrame des évaluations à partir du fichier CSV
df_ratings = pd.read_csv(csv_file) df_ratings = pd.read_csv(csv_file)
# Obtenir toutes les valeurs de notation uniques # Obtenir toutes les valeurs de notation uniques
rating_values = sorted(df_ratings['rating'].unique()) rating_values = sorted(df_ratings['rating'].unique())
# Afficher toutes les valeurs de notation possibles # Afficher toutes les valeurs de notation possibles
print("All possible rating values, from smallest to highest:") print("All possible rating values, from smallest to highest:")
for rating in rating_values: for rating in rating_values:
print(rating) print(rating)
# Exemple d'utilisation de la fonction avec le chemin du fichier CSV # Exemple d'utilisation de la fonction avec le chemin du fichier CSV
all_possible_ratings("data/small/evidence/ratings.csv") all_possible_ratings("data/small/evidence/ratings.csv")
``` ```
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
# THE NUMBER OF MOVIES THAT WERE NOT RATED AT ALL # THE NUMBER OF MOVIES THAT WERE NOT RATED AT ALL
def unrated_movies_count(ratings_csv, movies_csv): def unrated_movies_count(ratings_csv, movies_csv):
# Charger les DataFrames des évaluations et des films à partir des fichiers CSV # Charger les DataFrames des évaluations et des films à partir des fichiers CSV
df_ratings = pd.read_csv(ratings_csv) df_ratings = pd.read_csv(ratings_csv)
df_movies = pd.read_csv(movies_csv) df_movies = pd.read_csv(movies_csv)
# Obtenir la liste de tous les films présents dans le fichier de notation # Obtenir la liste de tous les films présents dans le fichier de notation
rated_movies = df_ratings['movieId'].unique() rated_movies = df_ratings['movieId'].unique()
# Comparer la liste des films notés à la liste complète des films pour obtenir les films non notés # Comparer la liste des films notés à la liste complète des films pour obtenir les films non notés
unrated_movies_count = df_movies[~df_movies['movieId'].isin(rated_movies)].shape[0] unrated_movies_count = df_movies[~df_movies['movieId'].isin(rated_movies)].shape[0]
# Afficher le nombre de films non notés # Afficher le nombre de films non notés
print("Number of movies that were not rated at all:", unrated_movies_count) print("Number of movies that were not rated at all:", unrated_movies_count)
# Exemple d'utilisation de la fonction avec les chemins des fichiers CSV des évaluations et des films # Exemple d'utilisation de la fonction avec les chemins des fichiers CSV des évaluations et des films
unrated_movies_count("data/small/evidence/ratings.csv", "data/small/content/movies.csv") unrated_movies_count("data/small/evidence/ratings.csv", "data/small/content/movies.csv")
``` ```
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter