Spaces:
Runtime error
Runtime error
Commit
·
5bcbd08
1
Parent(s):
524a705
Update app.py
Browse files
app.py
CHANGED
|
@@ -9,12 +9,11 @@ Original file is located at
|
|
| 9 |
|
| 10 |
import pandas as pd
|
| 11 |
import numpy as np
|
| 12 |
-
!pip install fuzzywuzzy
|
| 13 |
from fuzzywuzzy import fuzz
|
| 14 |
from sklearn.feature_extraction.text import TfidfVectorizer
|
| 15 |
from sklearn.metrics.pairwise import cosine_similarity
|
| 16 |
|
| 17 |
-
df = pd.read_csv("
|
| 18 |
|
| 19 |
#Remove title from review
|
| 20 |
def remove_title(row):
|
|
@@ -48,18 +47,6 @@ cosine_similarity_array = cosine_similarity(tfidf_df)
|
|
| 48 |
# Create a DataFrame from the cosine_similarity_array with tfidf_df.index as its rows and columns.
|
| 49 |
cosine_similarity_df = pd.DataFrame(cosine_similarity_array, index=tfidf_df.index, columns=tfidf_df.index)
|
| 50 |
|
| 51 |
-
# Print the top 5 rows of the DataFrame
|
| 52 |
-
# cosine_similarity_df.head()
|
| 53 |
-
|
| 54 |
-
# # Find the values for the game Batman: Arkham City
|
| 55 |
-
# cosine_similarity_series = cosine_similarity_df.loc['Batman: Arkham City']
|
| 56 |
-
|
| 57 |
-
# # Sort these values highest to lowest
|
| 58 |
-
# ordered_similarities = cosine_similarity_series.sort_values(ascending=False)
|
| 59 |
-
|
| 60 |
-
# # Print the results
|
| 61 |
-
# print(ordered_similarities)
|
| 62 |
-
|
| 63 |
# create a function to find the closest title
|
| 64 |
def matching_score(a,b):
|
| 65 |
#fuzz.ratio(a,b) calculates the Levenshtein Distance between a and b, and returns the score for the distance
|
|
@@ -81,7 +68,7 @@ def find_closest_title(title):
|
|
| 81 |
return closest_title, distance_score
|
| 82 |
# Bejeweled Twist, 100
|
| 83 |
|
| 84 |
-
find_closest_title('Batman Arkham Knight')
|
| 85 |
|
| 86 |
"""# Build Recommender Function
|
| 87 |
|
|
@@ -139,9 +126,7 @@ def recommend_games(game1, game2, game3, keyword1, keyword2, keyword3, max_resul
|
|
| 139 |
continue
|
| 140 |
|
| 141 |
|
| 142 |
-
recommend_games('Mortal Kombat', 'Street Fighter', 'Overwatch', 'Kombat', 'Fighter', 'Overwatch', 5)
|
| 143 |
-
|
| 144 |
-
!pip install gradio
|
| 145 |
|
| 146 |
import gradio as gr
|
| 147 |
|
|
|
|
| 9 |
|
| 10 |
import pandas as pd
|
| 11 |
import numpy as np
|
|
|
|
| 12 |
from fuzzywuzzy import fuzz
|
| 13 |
from sklearn.feature_extraction.text import TfidfVectorizer
|
| 14 |
from sklearn.metrics.pairwise import cosine_similarity
|
| 15 |
|
| 16 |
+
df = pd.read_csv("Metacritic_Reviews_Only.csv", error_bad_lines=False, encoding='utf-8')
|
| 17 |
|
| 18 |
#Remove title from review
|
| 19 |
def remove_title(row):
|
|
|
|
| 47 |
# Create a DataFrame from the cosine_similarity_array with tfidf_df.index as its rows and columns.
|
| 48 |
cosine_similarity_df = pd.DataFrame(cosine_similarity_array, index=tfidf_df.index, columns=tfidf_df.index)
|
| 49 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
# create a function to find the closest title
|
| 51 |
def matching_score(a,b):
|
| 52 |
#fuzz.ratio(a,b) calculates the Levenshtein Distance between a and b, and returns the score for the distance
|
|
|
|
| 68 |
return closest_title, distance_score
|
| 69 |
# Bejeweled Twist, 100
|
| 70 |
|
| 71 |
+
#find_closest_title('Batman Arkham Knight')
|
| 72 |
|
| 73 |
"""# Build Recommender Function
|
| 74 |
|
|
|
|
| 126 |
continue
|
| 127 |
|
| 128 |
|
| 129 |
+
# recommend_games('Mortal Kombat', 'Street Fighter', 'Overwatch', 'Kombat', 'Fighter', 'Overwatch', 5)
|
|
|
|
|
|
|
| 130 |
|
| 131 |
import gradio as gr
|
| 132 |
|