Spaces:
Sleeping
Sleeping
soojeongcrystal
commited on
Commit
β’
1ec6c27
1
Parent(s):
31d6108
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import pandas as pd
|
3 |
+
import matplotlib.pyplot as plt
|
4 |
+
|
5 |
+
# μ§μ λ°μ΄ν°λ₯Ό λΆμνμ¬ κ΅μ‘ νλ‘κ·Έλ¨μ μΆμ²νκ³ κ²°κ³Όλ₯Ό μκ°ννλ ν¨μ
|
6 |
+
def analyze_data(employee_file, program_file):
|
7 |
+
# μ§μ λ°μ΄ν°μ κ΅μ‘ νλ‘κ·Έλ¨ λ°μ΄ν° λΆλ¬μ€κΈ°
|
8 |
+
employee_df = pd.read_csv(employee_file.name)
|
9 |
+
program_df = pd.read_csv(program_file.name)
|
10 |
+
|
11 |
+
# μ§μλ³ μΆμ² νλ‘κ·Έλ¨ λ¦¬μ€νΈ
|
12 |
+
recommendations = []
|
13 |
+
|
14 |
+
for _, employee in employee_df.iterrows():
|
15 |
+
recommended_programs = []
|
16 |
+
|
17 |
+
for _, program in program_df.iterrows():
|
18 |
+
# μ§μμ νμ¬ μλκ³Ό νμ΅ λͺ©νλ₯Ό κΈ°λ°μΌλ‘ μ ν©ν νλ‘κ·Έλ¨μ μΆμ²
|
19 |
+
if any(skill in program['skills_acquired'] for skill in employee['current_skills'].split(',')) or \
|
20 |
+
employee['learning_goal'] in program['learning_objectives']:
|
21 |
+
recommended_programs.append(f"{program['program_name']} ({program['duration']})")
|
22 |
+
|
23 |
+
if recommended_programs:
|
24 |
+
recommendation = f"μ§μ {employee['employee_name']}μ μΆμ² νλ‘κ·Έλ¨: {', '.join(recommended_programs)}"
|
25 |
+
else:
|
26 |
+
recommendation = f"μ§μ {employee['employee_name']}μκ² μ ν©ν νλ‘κ·Έλ¨μ΄ μμ΅λλ€."
|
27 |
+
|
28 |
+
recommendations.append(recommendation)
|
29 |
+
|
30 |
+
# κ²°κ³Όλ₯Ό ν
μ€νΈλ‘ λ°ν
|
31 |
+
result_text = "\n".join(recommendations)
|
32 |
+
|
33 |
+
# μκ°νμ© μ°¨νΈ μμ±
|
34 |
+
plt.figure(figsize=(8, 4))
|
35 |
+
employee_roles = employee_df['current_role'].value_counts()
|
36 |
+
employee_roles.plot(kind='bar', color='skyblue')
|
37 |
+
plt.title('μ§μλ³ νμ¬ μ§λ¬΄ λΆν¬')
|
38 |
+
plt.xlabel('μ§λ¬΄')
|
39 |
+
plt.ylabel('μ§μ μ')
|
40 |
+
|
41 |
+
# μ°¨νΈλ₯Ό λ°ν
|
42 |
+
plt.tight_layout()
|
43 |
+
return result_text, plt.gcf()
|
44 |
+
|
45 |
+
# Gradio μΈν°νμ΄μ€ μ μ
|
46 |
+
def main(employee_file, program_file):
|
47 |
+
return analyze_data(employee_file, program_file)
|
48 |
+
|
49 |
+
# μ¬μ΄λλ°μμ νμΌ μ
λ‘λ κΈ°λ₯ ꡬν
|
50 |
+
with gr.Blocks() as demo:
|
51 |
+
with gr.Row():
|
52 |
+
with gr.Column(scale=1):
|
53 |
+
gr.Markdown("# HybridRAG μμ€ν
")
|
54 |
+
gr.Markdown("λ κ°μ CSV νμΌμ μ
λ‘λνμ¬ λΆμμ μ§ννμΈμ.")
|
55 |
+
|
56 |
+
employee_file = gr.File(label="μ§μ λ°μ΄ν° μ
λ‘λ")
|
57 |
+
program_file = gr.File(label="κ΅μ‘ νλ‘κ·Έλ¨ λ°μ΄ν° μ
λ‘λ")
|
58 |
+
analyze_button = gr.Button("λΆμ μμ")
|
59 |
+
output_text = gr.Textbox(label="λΆμ κ²°κ³Ό")
|
60 |
+
|
61 |
+
analyze_button.click(main, inputs=[employee_file, program_file], outputs=[output_text])
|
62 |
+
|
63 |
+
with gr.Column(scale=2):
|
64 |
+
gr.Markdown("### μ 보 ν¨λ")
|
65 |
+
gr.Markdown("μ
λ‘λλ λ°μ΄ν°μ λν λΆμ λ° κ²°κ³Όλ₯Ό μ¬κΈ°μ νμν©λλ€.")
|
66 |
+
|
67 |
+
# μκ°ν μ°¨νΈ μΆλ ₯
|
68 |
+
chart_output = gr.Plot(label="μκ°ν μ°¨νΈ")
|
69 |
+
|
70 |
+
# λΆμ λ²νΌ ν΄λ¦ μ μ°¨νΈ μ
λ°μ΄νΈ
|
71 |
+
analyze_button.click(main, inputs=[employee_file, program_file], outputs=[output_text, chart_output])
|
72 |
+
|
73 |
+
# Gradio μΈν°νμ΄μ€ μ€ν
|
74 |
+
demo.launch()
|