Wintersmith commited on
Commit
a388efc
1 Parent(s): a6b5d9e

Upload recommender_system.py

Browse files
Files changed (1) hide show
  1. recommender_system.py +5 -1
recommender_system.py CHANGED
@@ -63,7 +63,7 @@ def recommend_books(df: pd.DataFrame, book_to_be_recommended: str) -> pd.DataFra
63
  # Create DataFrame with correlations
64
  correlations_df = pd.DataFrame({
65
  'Book-Title': correlations.index,
66
- 'Correlation': correlations.values,
67
  })
68
 
69
  # Merge correlations_df with average_ratings
@@ -73,6 +73,10 @@ def recommend_books(df: pd.DataFrame, book_to_be_recommended: str) -> pd.DataFra
73
  # Sort by correlation value
74
  correlations_df = correlations_df.sort_values('Correlation', ascending=False)
75
 
 
 
 
 
76
  # Remove the book being recommended from the list
77
  correlations_df = correlations_df[correlations_df['Book-Title'] != book_to_be_recommended]
78
  correlations_df = correlations_df.head(10)
 
63
  # Create DataFrame with correlations
64
  correlations_df = pd.DataFrame({
65
  'Book-Title': correlations.index,
66
+ 'Correlation [%]': correlations.values,
67
  })
68
 
69
  # Merge correlations_df with average_ratings
 
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]
82
  correlations_df = correlations_df.head(10)