diff --git a/.DS_Store b/.DS_Store
index 65ed2bfe4e0b291c8f2ddbbf10a1035dcacd3dad..476cff3271cdbbab862a81ad2a8e56af759ca6b7 100644
Binary files a/.DS_Store and b/.DS_Store differ
diff --git a/Data_Base.xlsx b/Data_Base.xlsx
deleted file mode 100644
index a0bff13121b7287921df9bffebf55b07e2a27c6d..0000000000000000000000000000000000000000
Binary files a/Data_Base.xlsx and /dev/null differ
diff --git a/projet_en_groupe/.DS_Store b/projet_en_groupe/.DS_Store
index 72b0ce1e438fdd2638258e185d10e0b3b8b707a5..cee0b65dddcd5835972253a55dd2037bd4548c61 100644
Binary files a/projet_en_groupe/.DS_Store and b/projet_en_groupe/.DS_Store differ
diff --git a/projet_en_groupe/algorithme_netflix.py b/projet_en_groupe/algorithme_netflix.py
index e395b93b34a3066ab724df54c00782b586eefb09..a1dfdc15e5d426f822eac5a4cc104d8cce503bcd 100644
--- a/projet_en_groupe/algorithme_netflix.py
+++ b/projet_en_groupe/algorithme_netflix.py
@@ -3,6 +3,7 @@
 import pandas as pd
 import tabulate
 import os
+import csv
 
 #display(data_2)
 
@@ -473,7 +474,7 @@ def save_to_csv(data, default_filename='output.csv'):
 # début de l'algorithme de recommandation 
 
 # Load the CSV file
-
+"""
 def print_matrix(data_1):
     # Initialize the category matrix with zeros
     unique_categories = set(category for categories in data_1['listed_in'].str.split(', ') for category in categories)
@@ -492,70 +493,71 @@ def print_matrix(data_1):
     category_df.to_excel(output_file, index_label='Categories')
 
     print(f"Category matrix saved to {output_file}")
-    return category_matrix
-
-
-def recommend_movies(user_ratings, category_matrix, unique_categories, num_recommendations=5):
-    # Calculate the weighted sum of category matrix based on user ratings
-    weighted_sum = {category: 0 for category in unique_categories}
-    for category, rating in user_ratings.items():
-        if category != 'title':
-            for other_category in unique_categories:
-                weighted_sum[other_category] += rating * category_matrix[category][other_category]
-
-    # Find top N categories
-    top_categories = sorted(weighted_sum, key=weighted_sum.get, reverse=True)[:num_recommendations]
-
-    # Find movies in top categories not rated by the user
-    recommended_movies = []
-    for category in top_categories:
-        for i, row in user_ratings.iterrows():
-            if row['title'] not in user_ratings['title'] and category in row.values:
-                recommended_movies.append(row['title'])
-
-    return recommended_movies[:num_recommendations]
-
-
-def print_user_matrix(data_1, data_2, user_id_to_recommend, category_matrix=None, num_recommendations=5):
-    # Load the category matrix if not provided
-    if category_matrix is None:
-        category_matrix = print_matrix(data_1)
-
-    linked_base = pd.merge(data_1, data_2, on='show_id')
-    
-    data_of_users = data_2.drop(['show_id', 'appreciation (%)'], axis=1)
-    titles = linked_base['title']
-    data_of_users.insert(0, 'title', titles)
-
-    # Pivot the DataFrame
-    user_item_matrix = data_of_users.set_index('title').transpose()
-
-    unique_categories = set(category for categories in data_1['listed_in'].str.split(', ') for category in categories)
-
-    # Get user ID from the user_id_to_recommend variable
-    user_id = linked_base.loc[linked_base['user_id'] == user_id_to_recommend, 'show_id'].values[0]
+    return category_matrix"""
+
+
+
+def read_movie_series_info(file_path_1):
+    catalog = {}
+    with open(file_path_1, 'r') as info_file:
+        info_reader = csv.reader(info_file)
+        next(info_reader)  # Skip header row
+        for row in info_reader:
+            show_id, show_type, title, director, cast, country, date_added, release_year, rating, duration, listed_in, description = row
+            catalog[show_id] = [title, listed_in.split(', ')]
+    return catalog
+
+def read_user_ratings(file_path_2):
+    ratings = {}
+    user_ids = []  # Assurez-vous d'initialiser la liste user_ids
+    with open(file_path_2, 'r') as ratings_file:
+        ratings_reader = csv.reader(ratings_file)
+        header = next(ratings_reader)  # Lire la première ligne pour obtenir les ID des utilisateurs
+        user_ids = header[1:]  # Les ID des utilisateurs sont dans la première ligne, sauf la première colonne (show_id)
+        for row in ratings_reader:
+            show_id = row[0]
+            user_ratings = list(map(int, row[1:]))
+            ratings[show_id] = user_ratings
+    return ratings, user_ids  
+
+def create_category_matrix(catalog, ratings, categories):
+    category_matrix = [[0 for _ in range(len(categories))] for _ in range(len(categories))]
+
+    for show_id, movie_categories in catalog.items():
+        for i in range(len(categories)):
+            if categories[i] in movie_categories[1]:
+                for j in range(len(categories)):
+                    if categories[j] in movie_categories[1]:
+                        category_matrix[i][j] += ratings[show_id][j]
 
-    # Get user ratings
-    user_ratings = data_of_users.loc[user_id]
-
-    # Recommend movies for the specified user
-    recommendations = recommend_movies(user_ratings, category_matrix, unique_categories, num_recommendations)
-
-    print(f"Top {num_recommendations} recommendations for user {user_id_to_recommend}:")
-    for movie_title in recommendations:
-        print(movie_title)
+    return category_matrix
 
-    # Save the transposed user-item matrix to an Excel file
-    user_item_matrix.to_excel("user_item_matrix.xlsx", index_label='user_id')
+def calculate_user_preferences(category_matrix, user_preferences, categories):
+    user_vector = []
 
-    print("Transposed User-item matrix saved to user_item_matrix.xlsx")
-    return
+    print("Length of user_preferences:", len(user_preferences))
+    print("Length of categories:", len(categories))
 
+    # Check if user_preferences is not empty and has the same length as categories
+    if len(user_preferences) != len(categories) or not user_preferences:
+        print("Error: Invalid user preferences")
+        return []
 
+    for i in range(len(categories)):
+        user_vector.append(sum(category_matrix[i][j] * user_preferences[j] for j in range(len(categories))))
 
+    return user_vector
 
+def recommend_movies(catalog, ratings, category_matrix, user_preferences, categories):
+    recommended_movies = []
 
+    for show_id, (title, movie_categories) in catalog.items():
+        if show_id not in ratings:
+            movie_score = sum(category_matrix[i][j] * user_preferences[j] for i, j in enumerate(categories) if categories[i] in movie_categories[1])
+            recommended_movies.append((title, movie_score))
 
+    recommended_movies.sort(key=lambda x: x[1], reverse=True)
+    return recommended_movies[:5]
 
 
 # Création du menu
@@ -578,6 +580,7 @@ def action() :
   print("15. Display movies and series based on parental control code")
   print("16. Display the nationalities of directors and sort the list based on the number of movies and series directed")
   print("17. Display basic statistics")
+  print("18. Get Personalized Recommendations")
   print("... Enter STOP to stop")
   command = input("Enter the number of what you want to do: ")
 
@@ -615,11 +618,55 @@ def action() :
     directors_nationality(data_1)
   elif command == "17" :
     basic_statistics(data_1)
-  elif command == "A" :
-      print_matrix(data_1)
-  elif command == "B" :
-      user_id_to_recommend = str(input("Quel utilisateur es-tu ? "))
-      print_user_matrix(data_1,data_2, user_id_to_recommend)
+  elif command == "test" :
+    # Read data from CSV files
+    catalog = read_movie_series_info(file_path_1)
+    ratings, user_ids = read_user_ratings(file_path_2)
+
+    transposed_ratings = {user_id: {} for user_id in user_ids}
+    for show_id, user_ratings in ratings.items():
+        for i, user_id in enumerate(user_ids):
+            transposed_ratings[user_id][show_id] = user_ratings[i]
+
+    print("User IDs in ratings:", transposed_ratings.keys())
+    # Check if the user ID exists in the ratings dictionary
+    user_id_to_recommend = input("Enter your user ID: ")
+    user_id_to_recommend = str(user_id_to_recommend)
+
+    # Check if the user ID exists in the ratings dictionary
+    if user_id_to_recommend not in transposed_ratings:
+        print(f"User with ID '{user_id_to_recommend}' not found in ratings.")
+    else:
+        # Get categories that exist in both catalog and user ratings
+        unique_types = file_path_1['listed_in'].unique()
+
+        print("Common Categories:", unique_types)
+
+        # Create category matrix
+        categories = list(common_categories)
+        print("Categories:", categories)
+
+        category_matrix = create_category_matrix(catalog, transposed_ratings, categories)
+
+
+        # Use user ratings as preferences
+        user_preferences = [transposed_ratings[user_id_to_recommend][category] for category in categories]
+        print("User Preferences:", user_preferences)
+
+        # Calculate user preferences
+        user_vector = calculate_user_preferences(category_matrix, user_preferences, categories)
+
+        # Recommend movies
+        recommended_movies = recommend_movies(catalog, transposed_ratings, category_matrix, user_vector, categories)
+
+        # Display top 5 recommendations
+        print(recommended_movies)
+
+  elif command == "18" :
+    user_id_to_recommend = input("Enter your user ID: ")
+    # Assuming 'catalog', 'ratings', 'category_matrix', 'categories' are available from your data loading
+    recommended_movies = recommend_movies(catalog, ratings, category_matrix, user_preferences, categories)
+    print(recommended_movies)
   elif command == "..." :
     return False
 
diff --git a/projet_en_groupe/category_matrix.xlsx b/projet_en_groupe/category_matrix.xlsx
deleted file mode 100644
index 0e3828c53cc2b42adbbe085683e1bfd2a8a16f4c..0000000000000000000000000000000000000000
Binary files a/projet_en_groupe/category_matrix.xlsx and /dev/null differ
diff --git a/projet_en_groupe/data_cp_2023/.DS_Store b/projet_en_groupe/data_cp_2023/.DS_Store
new file mode 100644
index 0000000000000000000000000000000000000000..6b6fc7b130660c0bc13873ea384704e3a8e92313
Binary files /dev/null and b/projet_en_groupe/data_cp_2023/.DS_Store differ
diff --git a/projet_en_groupe/excel_filename.xlsx b/projet_en_groupe/excel_filename.xlsx
deleted file mode 100644
index 56a3d8fa3d278a792946f2b9932f6fc7e9b9a832..0000000000000000000000000000000000000000
Binary files a/projet_en_groupe/excel_filename.xlsx and /dev/null differ
diff --git a/projet_en_groupe/recom_sys.py b/projet_en_groupe/recom_sys.py
new file mode 100644
index 0000000000000000000000000000000000000000..f61d2a2d742f4a0f599285328ba22d2b3bb9edf4
--- /dev/null
+++ b/projet_en_groupe/recom_sys.py
@@ -0,0 +1,114 @@
+import csv
+
+# Déclarer categories en tant que variable globale
+categories = []
+
+def read_movie_series_info(file_path):
+    catalog = {}
+    with open(file_path, 'r', encoding='utf-8') as info_file:
+        info_reader = csv.reader(info_file)
+        next(info_reader)  # Skip header row
+        for row in info_reader:
+            show_id, show_type, title, director, cast, country, date_added, release_year, rating, duration, listed_in, description = row
+            catalog[show_id] = [title, listed_in.split(', ')]
+    return catalog
+
+def read_user_ratings(file_path):
+    ratings = {}
+    with open(file_path, 'r', encoding='utf-8') as ratings_file:
+        ratings_reader = csv.reader(ratings_file)
+        header = next(ratings_reader)  # Skip header row
+        user_ids = list(map(int, header[1:]))
+        
+        for row in ratings_reader:
+            show_id = row[0]
+            user_ratings = list(map(int, row[1:]))
+            ratings[show_id] = dict(zip(user_ids, user_ratings))
+            
+    return ratings
+
+def create_category_matrix(catalog, categories):
+    # Créez la matrice avec une rangée et une colonne supplémentaires pour les noms de catégories
+    category_matrix = [[0 for _ in range(len(categories) + 1)] for _ in range(len(categories) + 1)]
+
+    # Ajoutez les noms de catégories à la première ligne et à la première colonne
+    for i in range(len(categories)):
+        category_matrix[0][i + 1] = categories[i]  # Ajoutez les noms de catégories à la première ligne
+        category_matrix[i + 1][0] = categories[i]  # Ajoutez les noms de catégories à la première colonne
+    
+    # Remplissez la matrice avec les données
+    for show_id, movie_categories in catalog.items():
+        for i in range(len(categories)):
+            if categories[i] in movie_categories[1]:
+                for j in range(len(categories)):
+                    if categories[j] in movie_categories[1]:
+                        category_matrix[i + 1][j + 1] += 1  # Commencez à remplir à partir de la deuxième ligne et de la deuxième colonne
+    # Ajoutez les noms de catégories à la première colonne et les données de la matrice
+    return category_matrix
+
+
+def recommend_movies(user_id, catalog, user_ratings, category_matrix, threshold=0.5):
+    global categories  # Déclarer categories en tant que variable globale
+
+    user_id = int(user_id)  # Convertir user_id en entier
+
+    suggestions = {}
+
+    # Créer le dictionnaire pour stocker les indices des catégories
+    category_index = {category: i + 1 for i, category in enumerate(categories)}
+
+    for show_id, categories in catalog.items():
+        # Check if the user has rated the show
+        if show_id in user_ratings and user_id in user_ratings[show_id] and user_ratings[show_id][user_id] == 0:
+            # Liste des catégories communes entre le film/série et les films/séries notés par l'utilisateur
+            common_categories = [category for category in categories[1] if category in catalog[show_id][1]]
+            if common_categories:
+                # Calculez la similarité entre le film/série et les films/séries notés par l'utilisateur
+                similarity = sum(
+                    min(category_matrix[category_index[category]][category_index[user_category]] for user_category in common_categories)
+                    for category in categories[1]
+                )
+
+                # Ne recommandez que des films/séries dont la similarité dépasse le seuil spécifié
+                if similarity > threshold:
+                    suggestions[show_id] = {'title': catalog[show_id][0], 'similarity': similarity}
+
+    # Triez les suggestions par similarité décroissante
+    sorted_suggestions = sorted(suggestions.items(), key=lambda x: x[1]['similarity'], reverse=True)
+
+    return sorted_suggestions[:5]
+
+if __name__ == "__main__":
+
+    # Replace file_path_1 and file_path_2 with the actual file paths
+    file_path_1 = "/Users/adrien/vscodeworkspace/coding-project/projet_en_groupe/data_cp_2023/netflix_titles-2.csv"
+    file_path_2 = "/Users/adrien/vscodeworkspace/coding-project/projet_en_groupe/data_cp_2023/ratings.csv"
+
+    user_id = input("quel est ton user ? ")
+
+    try:
+        user_id = int(user_id)
+    except ValueError:
+        print("Veuillez entrer un identifiant d'utilisateur valide.")
+        exit()
+
+    # Read data from CSV files
+    catalog = read_movie_series_info(file_path_1)
+    ratings = read_user_ratings(file_path_2)
+    # Create category matrix
+    categories = list(set(category for _, movie_info in catalog.items() for category in movie_info[1]))
+    category_matrix = create_category_matrix(catalog, categories)
+
+    # Display movies already viewed by the user
+    print("Films déjà vus par l'utilisateur:")
+    for show_id, user_rating in ratings.items():
+        if user_id in user_rating and user_rating[user_id] > 0:
+            print(f"- {catalog[show_id][0]}")
+
+    # Recommend movies
+    recommended_movies = recommend_movies(user_id, catalog, ratings, category_matrix, threshold=0.5)
+
+    # Display top 5 recommendations
+    print("\nTop 5 recommandations:")
+    for show_id, info in recommended_movies:
+        print(f"Title: {info['title']}, Similarity: {info['similarity']}")
\ No newline at end of file