Akshay commited on
Commit
c0e582d
·
1 Parent(s): 706bd5b

Added all input files and gradio app.py 2

Browse files
Files changed (1) hide show
  1. app.py +46 -0
app.py CHANGED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pickle as pkl
2
+ import plotly.express as px
3
+ import gradio as gr
4
+
5
+ # Load the job stack count data
6
+ with open("job_stack_count.pkl", "rb") as f:
7
+ job_stack_count = pkl.load(f)
8
+
9
+ # Load the user's stack data
10
+ with open("all_my_stacks.pkl", "rb") as f:
11
+ mynew_stacks = pkl.load(f)
12
+
13
+ def generate_treemap(category: str):
14
+ """Generate a treemap visualization for the selected category."""
15
+ if category not in job_stack_count:
16
+ return "Category not found"
17
+
18
+ stat_dict = job_stack_count[category]
19
+ stat_dict_keys = list(stat_dict.keys())
20
+ stat_dict_values = list(stat_dict.values())
21
+ total = len(mynew_stacks)
22
+
23
+ stat_dict_perc = [val / total * 100 for val in stat_dict_values]
24
+ hover_text = [f"{label}: Covers {p:.0f}% of Job Descriptions" for label, p in zip(stat_dict_keys, stat_dict_perc)]
25
+
26
+ fig = px.treemap(
27
+ names=stat_dict_keys,
28
+ parents=[""] * len(stat_dict_keys), # No parent categories
29
+ values=stat_dict_values,
30
+ hover_name=hover_text
31
+ )
32
+ fig.update_layout(title=category)
33
+ return fig
34
+
35
+ # Create a Gradio interface
36
+ categories = list(job_stack_count.keys())
37
+ demo = gr.Interface(
38
+ fn=generate_treemap,
39
+ inputs=gr.Dropdown(choices=categories, label="Select Category"),
40
+ outputs=gr.Plot(),
41
+ title="Tech Stack Treemap Visualization",
42
+ description="Select a category to visualize the distribution of job tech stacks."
43
+ )
44
+
45
+ # Launch the app
46
+ demo.launch(share=True)