soojeongcrystal commited on
Commit
1ec6c27
β€’
1 Parent(s): 31d6108

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +74 -0
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()