From f20b5b8393cbaf5b29ed14724e73b55cb1247d74 Mon Sep 17 00:00:00 2001 From: Adrienucl <adrien.payen@student.uclouvain.be> Date: Tue, 26 Dec 2023 11:52:08 +0100 Subject: [PATCH] last update --- .DS_Store | Bin 6148 -> 6148 bytes Dramas.csv | 3 - projet_en_groupe/.DS_Store | Bin 6148 -> 6148 bytes projet_en_groupe/algorithme_netflix.py | 102 ++++++++++++++----------- 4 files changed, 59 insertions(+), 46 deletions(-) delete mode 100644 Dramas.csv diff --git a/.DS_Store b/.DS_Store index 9216513466f8ff22ac018f9a3316854345c7df53..8cdf8e4b7ca3b1bf1dcfe086c4c07c192600439a 100644 GIT binary patch delta 48 zcmZoMXffEp%F4KNavWPBk7RYVp@pfAf}ydw!Q@+P(v01c=dsE&_H5qA>cO;`o#QV* E0AQ02p8x;= delta 25 hcmZoMXffEp$~rlY?abtrEP|UKv#Ky{X5;wB4*+!m2*v;a diff --git a/Dramas.csv b/Dramas.csv deleted file mode 100644 index 0e95f87..0000000 --- a/Dramas.csv +++ /dev/null @@ -1,3 +0,0 @@ -show_id,type,title,director,cast,country,date_added,release_year,rating,duration,listed_in,description -s1237,Movie,Sentinelle,Julien Leclercq,"Olga Kurylenko, Marilyn Lima, Michel Nabokoff, Martin Swabey, Carole Weyers, Andrey Gorlenko, Antonia Malinova, Gabriel Almaer, Blaise Afonso, Guillaume Duhesme, Michel Biel",France,"March 5, 2021",2021,TV-MA,81 min,"Action & Adventure, Dramas, International Movies","Transferred home after a traumatizing combat mission, a highly trained French soldier uses her lethal skills to hunt down the man who hurt her sister." -s2669,Movie,Earth and Blood,Julien Leclercq,"Sami Bouajila, Eriq Ebouaney, Samy Seghir, Sofia Lesaffre","France, Belgium","April 17, 2020",2020,TV-MA,81 min,"Dramas, International Movies, Thrillers",A sawmill owner and his teenage daughter become tangled in a deadly feud when a drug dealer stashes stolen cocaine on their remote property. diff --git a/projet_en_groupe/.DS_Store b/projet_en_groupe/.DS_Store index 0bebdd61ccf544d5f88a54eb3b651bfcf9fc1fef..7497e4708f6e1681ff033c1a5e38ccb73901f431 100644 GIT binary patch delta 70 zcmZoMXffEZm4$KV<ZUd48j{u3h8Cte3Wmn!2DLg0)s{vEItnJnX0^4P9HPql)<N;v aIk|cH-IM)T<r#Z6=dsRU+RV=JmmdK378NJ} delta 69 zcmZoMXffEZm4$J~<ZUd4>Jrt}M&_nE3dUx}wK@vbmPQ6T3MR&8wY8iaqRRT#LGjr+ Zxq10rll@uc8M`;<v(8}J%*OGL9{}Ye6!riB diff --git a/projet_en_groupe/algorithme_netflix.py b/projet_en_groupe/algorithme_netflix.py index 95acc01..9947d80 100644 --- a/projet_en_groupe/algorithme_netflix.py +++ b/projet_en_groupe/algorithme_netflix.py @@ -1,5 +1,4 @@ -# afficher le premier document - +# ALL the imports import pandas as pd import tabulate import os @@ -27,7 +26,7 @@ def catalog(data_1): # Be careful, you need to ask each time if they want to save the list to a .csv -def movies(data_1): # enregistrement +def movies(data_1): # register films = data_1[data_1['type'] == 'Movie'] # Filter the data to include only movies movie_titles = films['title'].tolist() # Extract movie titles @@ -129,8 +128,6 @@ def by_country(data_1): # Be careful, you need to ask each time if they want to save the list to a .csv - - def genre(data_1): filtered_data = filter_media_type(data_1) @@ -174,8 +171,6 @@ def genre(data_1): return -from fuzzywuzzy import process - def duration(data_1): filtered_data = filter_media_type(data_1) @@ -254,7 +249,9 @@ def director(data_1): if director_name not in director_list and director_name != '': director_list.append(director_name) + # Sort the director_list in alphabetical order print("List of all possible directors: ") + director_list = sorted(director_list) print(director_list) while True: @@ -298,6 +295,7 @@ def actor(data_1): if actor_name not in actor_list and actor_name != '': actor_list.append(actor_name) + actor_list = sorted(actor_list) print("List of all possible actors: ") print(actor_list) @@ -340,7 +338,10 @@ def specific_genre_director(data_1): unique_directors = filtered_data['director'].unique() # Convert elements to strings to handle potential float values unique_directors = [str(director) for director in unique_directors] - + + # Sort the unique_directors in alphabetical order + unique_directors = sorted(unique_directors) + print("List of all available directors:") print(', '.join(unique_directors)) @@ -366,6 +367,9 @@ def specific_genre_director(data_1): # Get a list of all available types without duplicates unique_types = filtered_data['listed_in'].str.split(', ').explode().unique() + # Sort the unique_types in alphabetical order + unique_types = sorted(unique_types) + print("\nList of all available types:") print(', '.join(unique_types)) @@ -412,7 +416,10 @@ def specific_genre_actor(data_1): # Get a list of unique actors unique_actors = filtered_data['cast'].str.split(', ').explode().unique() unique_actors = [str(actor) for actor in unique_actors] - + + # Sort the unique_actors in alphabetical order + unique_actors = sorted(unique_actors) + print("List of all available actors:") print(', '.join(unique_actors)) @@ -436,6 +443,9 @@ def specific_genre_actor(data_1): # Get a list of all available types without duplicates unique_types = filtered_data['listed_in'].str.split(', ').explode().unique() + # Sort the unique_types in alphabetical order + unique_types = sorted(unique_types) + print("\nList of all available types:") print(', '.join(unique_types)) @@ -674,39 +684,50 @@ def basic_statistics(data_1): # attention il faut demander à chaque fois, s'il désire enregistrer la liste sur un .csv def save_to_csv(data, default_filename='output.csv'): - # Ask if the user wants to save to a CSV file - save_choice = input("Do you want to save the data to a CSV file? (YES/NO): ").upper() - - if save_choice == 'YES': - # Prompt for a file name - file_name = input("Enter the file name (DO NOT include .csv extension, or press Enter for the default): ") - file_name = file_name + ".csv" - if not file_name: - file_name = default_filename - - # Check if the file already exists - if os.path.exists(file_name): - # Ask if the user wants to overwrite or create a new file - overwrite_choice = input(f"The file '{file_name}' already exists. Do you want to overwrite it? (YES/NO): ").upper() - - if overwrite_choice == 'YES': - # Overwrite the existing file + while True: + # Ask if the user wants to save to a CSV file + save_choice = input("Do you want to save the data to a CSV file? (YES/NO): ").upper() + + if save_choice == 'YES': + # Prompt for a file name + file_name = input("Enter the file name (DO NOT include .csv extension, or press Enter for the default): ") + file_name = file_name + ".csv" + if not file_name: + file_name = default_filename + + # Check if the file already exists + if os.path.exists(file_name): + while True: + # Ask if the user wants to overwrite or create a new file + overwrite_choice = input(f"The file '{file_name}' already exists. Do you want to overwrite it? (YES/NO): ").upper() + + if overwrite_choice == 'YES': + # Overwrite the existing file + data.to_csv(file_name, index=False) + print(f"Data saved to {file_name}") + break + elif overwrite_choice == 'NO': + # Prompt for a new file name + new_filename = input("Enter a new file name (DO NOT include .csv extension): ") + new_filename = new_filename + ".csv" + data.to_csv(new_filename, index=False) + print(f"Data saved to {new_filename}") + break + else: + print("Invalid choice. Please enter either 'YES' or 'NO'.") + + else: + # Save to a new file data.to_csv(file_name, index=False) print(f"Data saved to {file_name}") + break - else: - # Prompt for a new file name - new_filename = input("Enter a new file name (DO NOT include .csv extension): ") - new_filename = new_filename + ".csv" - data.to_csv(new_filename, index=False) - print(f"Data saved to {new_filename}") - else: - # Save to a new file - data.to_csv(file_name, index=False) - print(f"Data saved to {file_name}") + elif save_choice == 'NO': + print("Data not saved.") + break - else: - print("Data not saved.") + else: + print("Invalid choice. Please enter either 'YES' or 'NO.'") @@ -802,11 +823,6 @@ def recommend_movies(user_id, catalog, user_ratings, category_matrix, threshold= return sorted_suggestions[:5] - - -# Ajout d'impression pour déboguer -print("User categories:", categories) - def recommandation_algorithm() : # Replace file_path_1 and file_path_2 with the actual file paths -- GitLab