Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -37,17 +37,10 @@ def generate_graphs(new_story):
|
|
37 |
# Find the indices of the 5 most similar stories
|
38 |
top_5_indices = np.argsort(similarities[0])[::-1][:5] # Sort similarities and get top 5
|
39 |
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
# Create a bar graph for the distribution of the 5 most similar stories
|
45 |
-
plt.figure(figsize=(10, 6))
|
46 |
-
sns.barplot(x=[f"Story {i+1}" for i in range(5)], y=likes_distribution, palette="viridis")
|
47 |
-
plt.title("LikesCount Distribution for the 5 Most Similar Stories", fontsize=14)
|
48 |
-
plt.xlabel("Story Similarity (Most Similar to Least)", fontsize=12)
|
49 |
-
plt.ylabel("LikesCount", fontsize=12)
|
50 |
-
likes_dist_plot = plt.gcf()
|
51 |
|
52 |
# Plot the similarity distribution for the 5 most similar stories
|
53 |
plt.figure(figsize=(10, 6))
|
@@ -62,6 +55,17 @@ def generate_graphs(new_story):
|
|
62 |
plt.ylabel("Density", fontsize=12)
|
63 |
plt.legend(title="Stories")
|
64 |
sim_dist_plot = plt.gcf()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
|
66 |
return sim_dist_plot,likes_dist_plot
|
67 |
|
|
|
37 |
# Find the indices of the 5 most similar stories
|
38 |
top_5_indices = np.argsort(similarities[0])[::-1][:5] # Sort similarities and get top 5
|
39 |
|
40 |
+
likes_distribution=[]
|
41 |
+
for i in top_5_indices:
|
42 |
+
print(f"Row {i+1}: Similarity = {similarities[0][i]:.4f}, LikesCount = {encoded_df.iloc[i]['likesCount']}")
|
43 |
+
likes_distribution.append(encoded_df.iloc[i]['likesCount'].astype(int))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
|
45 |
# Plot the similarity distribution for the 5 most similar stories
|
46 |
plt.figure(figsize=(10, 6))
|
|
|
55 |
plt.ylabel("Density", fontsize=12)
|
56 |
plt.legend(title="Stories")
|
57 |
sim_dist_plot = plt.gcf()
|
58 |
+
|
59 |
+
# Create a bar graph for the distribution of the 5 most similar stories
|
60 |
+
# top_5_stories = [0,1,2,3,4]
|
61 |
+
plt.figure(figsize=(10, 6))
|
62 |
+
sns.barplot(x=[f"Story {i+1}" for i in range(5)], y=likes_distribution, palette="viridis")
|
63 |
+
plt.title("LikesCount Distribution for the 5 Most Similar Stories", fontsize=14)
|
64 |
+
plt.xlabel("Story Similarity (Most Similar to Least)", fontsize=12)
|
65 |
+
plt.ylabel("LikesCount", fontsize=12)
|
66 |
+
likes_dist_plot = plt.gcf()
|
67 |
+
|
68 |
+
|
69 |
|
70 |
return sim_dist_plot,likes_dist_plot
|
71 |
|