FDSRashid commited on
Commit
9bbd6fb
·
verified ·
1 Parent(s): a05efdf

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -2
app.py CHANGED
@@ -19,10 +19,16 @@ def plot_similarity_score(taraf_num):
19
  embed_taraf = taraf_df['embed'].to_list()
20
  cos_score = cosine_similarity(embed_taraf)
21
  fig = px.imshow(cos_score)
22
- return fig, taraf_df[['matn', 'Number']]
 
 
 
 
 
 
23
 
24
  with gr.Blocks() as demo:
25
  taraf_number = gr.Slider(1,taraf_max , value=10000, label="Taraf", info="Choose the Taraf to Input", step = 1)
26
  btn = gr.Button('Submit')
27
- btn.click(fn = plot_similarity_score, inputs = [taraf_number], outputs = [gr.Plot(), gr.DataFrame()])
28
  demo.launch()
 
19
  embed_taraf = taraf_df['embed'].to_list()
20
  cos_score = cosine_similarity(embed_taraf)
21
  fig = px.imshow(cos_score)
22
+ matr = cos_score
23
+ rows, cols = matr.shape
24
+ mask = np.tril(np.ones((rows, cols), dtype=bool), k=-1)
25
+ lower_triangle = matr[mask]
26
+ data = lower_triangle.flatten()
27
+ fig_dis = px.histogram(x = data, title = f'Similarity Distribution for Taraf {taraf_num} using ', labels = {'x': 'Similarity Score'}, nbins = 20, template = 'ggplot2' )
28
+ return fig, , fig_dis, taraf_df[['matn', 'Number']]
29
 
30
  with gr.Blocks() as demo:
31
  taraf_number = gr.Slider(1,taraf_max , value=10000, label="Taraf", info="Choose the Taraf to Input", step = 1)
32
  btn = gr.Button('Submit')
33
+ btn.click(fn = plot_similarity_score, inputs = [taraf_number], outputs = [gr.Plot(),gr.Plot(), gr.DataFrame()])
34
  demo.launch()