Spaces:
Runtime error
Runtime error
Upload recommender_system.py
Browse files- recommender_system.py +3 -3
recommender_system.py
CHANGED
@@ -71,11 +71,11 @@ def recommend_books(df: pd.DataFrame, book_to_be_recommended: str) -> pd.DataFra
|
|
71 |
correlations_df = correlations_df.rename(columns={'Book-Rating': 'Average ratings'})
|
72 |
|
73 |
# Sort by correlation value
|
74 |
-
correlations_df = correlations_df.sort_values('Correlation', ascending=False)
|
75 |
|
76 |
# convert correlation column to percentage and limit to two decimals
|
77 |
-
correlations_df['Correlation'] = correlations_df['Correlation'] * 100
|
78 |
-
correlations_df['Correlation'] = correlations_df['Correlation'].round(2)
|
79 |
|
80 |
# Remove the book being recommended from the list
|
81 |
correlations_df = correlations_df[correlations_df['Book-Title'] != book_to_be_recommended]
|
|
|
71 |
correlations_df = correlations_df.rename(columns={'Book-Rating': 'Average ratings'})
|
72 |
|
73 |
# Sort by correlation value
|
74 |
+
correlations_df = correlations_df.sort_values('Correlation [%]', ascending=False)
|
75 |
|
76 |
# convert correlation column to percentage and limit to two decimals
|
77 |
+
correlations_df['Correlation [%]'] = correlations_df['Correlation [%]'] * 100
|
78 |
+
correlations_df['Correlation [%]'] = correlations_df['Correlation [%]'].round(2)
|
79 |
|
80 |
# Remove the book being recommended from the list
|
81 |
correlations_df = correlations_df[correlations_df['Book-Title'] != book_to_be_recommended]
|