Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -34,7 +34,12 @@ if len(data) > 0:
|
|
| 34 |
|
| 35 |
# Add derived features for better recommendations
|
| 36 |
if 'positive_ratings' in data.columns and 'negative_ratings' in data.columns:
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
data['rating_ratio'] = data['positive_ratings'] / (data['positive_ratings'] + data['negative_ratings'] + 1)
|
|
|
|
| 38 |
else:
|
| 39 |
data['rating_ratio'] = 0.5 # Default neutral rating
|
| 40 |
|
|
|
|
| 34 |
|
| 35 |
# Add derived features for better recommendations
|
| 36 |
if 'positive_ratings' in data.columns and 'negative_ratings' in data.columns:
|
| 37 |
+
data['positive_ratings'] = pd.to_numeric(data['positive_ratings'], errors='coerce')
|
| 38 |
+
data['negative_ratings'] = pd.to_numeric(data['negative_ratings'], errors='coerce')
|
| 39 |
+
data.dropna(subset=['positive_ratings', 'negative_ratings'], inplace=True)
|
| 40 |
+
|
| 41 |
data['rating_ratio'] = data['positive_ratings'] / (data['positive_ratings'] + data['negative_ratings'] + 1)
|
| 42 |
+
|
| 43 |
else:
|
| 44 |
data['rating_ratio'] = 0.5 # Default neutral rating
|
| 45 |
|