yashgupta1512 commited on
Commit
0979eae
·
verified ·
1 Parent(s): 7b41a1a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -0
app.py CHANGED
@@ -9,6 +9,7 @@ from transformers import AutoTokenizer, AutoModel
9
  from sklearn.metrics.pairwise import cosine_similarity
10
  import numpy as np
11
  import os
 
12
 
13
  # Load the BioBERT model and tokenizer
14
  @st.cache_resource
@@ -136,7 +137,32 @@ def main():
136
  similar_trials.to_excel(output_file, index=False)
137
  with open(output_file, "rb") as f:
138
  st.download_button("Download Results as Excel", f, file_name="similar_trials_results.xlsx")
 
139
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
140
 
141
  if __name__ == "__main__":
142
  main()
 
9
  from sklearn.metrics.pairwise import cosine_similarity
10
  import numpy as np
11
  import os
12
+ from PIL import Image
13
 
14
  # Load the BioBERT model and tokenizer
15
  @st.cache_resource
 
137
  similar_trials.to_excel(output_file, index=False)
138
  with open(output_file, "rb") as f:
139
  st.download_button("Download Results as Excel", f, file_name="similar_trials_results.xlsx")
140
+ st.title("Visualizations")
141
 
142
+ # t-SNE Plot Section
143
+ st.subheader("t-SNE Plot")
144
+ st.write(
145
+ "t-SNE (t-Distributed Stochastic Neighbor Embedding) is used to visualize high-dimensional embeddings in a lower-dimensional space, helping to identify clusters or patterns in the data."
146
+ )
147
+ tsne_image_path = "model/tsne_visualization.png" # Replace with the actual path to your t-SNE plot image
148
+ tsne_image = Image.open(tsne_image_path)
149
+ st.image(tsne_image, caption="t-SNE Plot")
150
+
151
+ st.markdown("---")
152
+
153
+ # Cosine Similarity Matrix Section
154
+ st.subheader("Cosine Similarity Matrix")
155
+ st.write(
156
+ "The cosine similarity matrix shows the similarity scores between different clinical trial embeddings, where higher scores indicate more similar trials."
157
+ )
158
+ cosine_matrix_image_path = "model/cosine_similarity.png" # Replace with the actual path to your cosine similarity matrix image
159
+ cosine_matrix_image = Image.open(cosine_matrix_image_path)
160
+ st.image(cosine_matrix_image, caption="Cosine Similarity Matrix")
161
+
162
+ st.markdown(
163
+ "### Reference\n"
164
+ "For more information, visit the [code files uploaded on Hugging Face](https://huggingface.co/spaces/yashgupta1512/nest/tree/main/model)."
165
+ )
166
 
167
  if __name__ == "__main__":
168
  main()