subashdvorak commited on
Commit
be6e9e4
·
verified ·
1 Parent(s): b27faf2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -2
app.py CHANGED
@@ -29,7 +29,7 @@ def generate_graphs(new_story):
29
  new_story_vector = model.encode([new_story])[0]
30
 
31
  # Calculate the similarity with all existing stories in the knowledge base
32
- knowledge_base_vectors = encoded_df.iloc[:, :-1].values # Exclude 'likesCount'
33
  print(f"New Story Vector Shape: {new_story_vector.shape}")
34
  print(f"Knowledge Base Vector Shape: {knowledge_base_vectors.shape}")
35
  similarities = cosine_similarity([new_story_vector], knowledge_base_vectors)
@@ -47,7 +47,7 @@ def generate_graphs(new_story):
47
  sns.kdeplot([new_story_vector], shade=False, label="New Story", color='blue')
48
 
49
  for i in top_5_indices:
50
- most_similar_vector = encoded_df.iloc[i, :-1].values
51
  sns.kdeplot(most_similar_vector, shade=False, label=f"Most Similar Story: {top_5_indices.tolist().index(i)+1}", alpha=0.5)
52
 
53
  plt.title("Similarity Distribution of New Story and Top 5 Similar Stories", fontsize=14)
 
29
  new_story_vector = model.encode([new_story])[0]
30
 
31
  # Calculate the similarity with all existing stories in the knowledge base
32
+ knowledge_base_vectors = encoded_df.iloc[:, :-7].values # Exclude 'likesCount'
33
  print(f"New Story Vector Shape: {new_story_vector.shape}")
34
  print(f"Knowledge Base Vector Shape: {knowledge_base_vectors.shape}")
35
  similarities = cosine_similarity([new_story_vector], knowledge_base_vectors)
 
47
  sns.kdeplot([new_story_vector], shade=False, label="New Story", color='blue')
48
 
49
  for i in top_5_indices:
50
+ most_similar_vector = encoded_df.iloc[i, :-7].values
51
  sns.kdeplot(most_similar_vector, shade=False, label=f"Most Similar Story: {top_5_indices.tolist().index(i)+1}", alpha=0.5)
52
 
53
  plt.title("Similarity Distribution of New Story and Top 5 Similar Stories", fontsize=14)