Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -19,25 +19,21 @@ def log_recommendation(employee_name, recommended_programs, feedback=None):
|
|
19 |
|
20 |
# ์ง์ ๋ฐ์ดํฐ๋ฅผ ๋ถ์ํ์ฌ ๊ต์ก ํ๋ก๊ทธ๋จ์ ์ถ์ฒํ๊ณ ๊ทธ๋ํ๋ฅผ ๊ทธ๋ฆฌ๋ ํจ์
|
21 |
def analyze_data(employee_file, program_file, feedback=None):
|
22 |
-
# ์ง์ ๋ฐ์ดํฐ์ ๊ต์ก ํ๋ก๊ทธ๋จ ๋ฐ์ดํฐ ๋ถ๋ฌ์ค๊ธฐ
|
23 |
employee_df = pd.read_csv(employee_file.name)
|
24 |
program_df = pd.read_csv(program_file.name)
|
25 |
|
26 |
-
# ์ง์ ์ญ๋๊ณผ ํ๋ก๊ทธ๋จ ํ์ต ๋ชฉํ๋ฅผ ๋ฒกํฐํ
|
27 |
employee_skills = employee_df['current_skills'].tolist()
|
28 |
program_skills = program_df['skills_acquired'].tolist()
|
29 |
employee_embeddings = model.encode(employee_skills)
|
30 |
program_embeddings = model.encode(program_skills)
|
31 |
|
32 |
-
# ์ ์ฌ๋ ๊ณ์ฐ
|
33 |
similarities = cosine_similarity(employee_embeddings, program_embeddings)
|
34 |
|
35 |
-
# ์ง์๋ณ ์ถ์ฒ ํ๋ก๊ทธ๋จ ๋ฆฌ์คํธ
|
36 |
recommendations = []
|
37 |
for i, employee in employee_df.iterrows():
|
38 |
recommended_programs = []
|
39 |
for j, program in program_df.iterrows():
|
40 |
-
if similarities[i][j] > 0.5:
|
41 |
recommended_programs.append(f"{program['program_name']} ({program['duration']})")
|
42 |
|
43 |
if recommended_programs:
|
@@ -45,15 +41,12 @@ def analyze_data(employee_file, program_file, feedback=None):
|
|
45 |
else:
|
46 |
recommendation = f"์ง์ {employee['employee_name']}์๊ฒ ์ ํฉํ ํ๋ก๊ทธ๋จ์ด ์์ต๋๋ค."
|
47 |
|
48 |
-
# ํผ๋๋ฐฑ ๋ก๊ทธ ๊ธฐ๋ก
|
49 |
log_recommendation(employee['employee_name'], recommended_programs, feedback)
|
50 |
|
51 |
recommendations.append(recommendation)
|
52 |
|
53 |
-
# ๊ฒฐ๊ณผ ํ
์คํธ
|
54 |
result_text = "\n".join(recommendations)
|
55 |
|
56 |
-
# ๋คํธ์ํฌ ๊ทธ๋ํ ์์ฑ
|
57 |
G = nx.Graph()
|
58 |
for employee in employee_df['employee_name']:
|
59 |
G.add_node(employee, type='employee')
|
@@ -63,10 +56,9 @@ def analyze_data(employee_file, program_file, feedback=None):
|
|
63 |
|
64 |
for i, employee in employee_df.iterrows():
|
65 |
for j, program in program_df.iterrows():
|
66 |
-
if similarities[i][j] > 0.5:
|
67 |
G.add_edge(employee['employee_name'], program['program_name'])
|
68 |
|
69 |
-
# ๊ทธ๋ํ ์๊ฐํ
|
70 |
plt.figure(figsize=(10, 8))
|
71 |
pos = nx.spring_layout(G)
|
72 |
nx.draw(G, pos, with_labels=True, node_color='skyblue', node_size=2000, font_size=10, font_weight='bold')
|
@@ -75,10 +67,6 @@ def analyze_data(employee_file, program_file, feedback=None):
|
|
75 |
|
76 |
return result_text, plt.gcf()
|
77 |
|
78 |
-
# Gradio ์ธํฐํ์ด์ค ์ ์
|
79 |
-
def main(employee_file, program_file, feedback):
|
80 |
-
return analyze_data(employee_file, program_file, feedback)
|
81 |
-
|
82 |
# ์์ ๋ฐ์ดํฐ๋ฅผ ๋ณด์ฌ์ฃผ๋ ํจ์
|
83 |
def show_example_data():
|
84 |
employee_example = pd.DataFrame({
|
@@ -108,13 +96,31 @@ with gr.Blocks() as demo:
|
|
108 |
with gr.Row():
|
109 |
with gr.Column(scale=1):
|
110 |
gr.Markdown("# HybridRAG ์์คํ
")
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
118 |
|
119 |
# ์์ ๋ฐ์ดํฐ๋ฅผ ๋ฏธ๋ฆฌ๋ณด๊ธฐ๋ก ์ ๊ณต
|
120 |
example_button = gr.Button("์์ ๋ฐ์ดํฐ ๋ณด๊ธฐ")
|
@@ -122,20 +128,5 @@ with gr.Blocks() as demo:
|
|
122 |
program_example_output = gr.DataFrame(label="๊ต์ก ํ๋ก๊ทธ๋จ ๋ฐ์ดํฐ ์์")
|
123 |
example_button.click(show_example_data, outputs=[employee_example_output, program_example_output])
|
124 |
|
125 |
-
analyze_button = gr.Button("๋ถ์ ์์")
|
126 |
-
output_text = gr.Textbox(label="๋ถ์ ๊ฒฐ๊ณผ")
|
127 |
-
|
128 |
-
analyze_button.click(main, inputs=[employee_file, program_file, feedback_input], outputs=[output_text])
|
129 |
-
|
130 |
-
with gr.Column(scale=2):
|
131 |
-
gr.Markdown("### ์ ๋ณด ํจ๋")
|
132 |
-
gr.Markdown("์
๋ก๋๋ ๋ฐ์ดํฐ์ ๋ํ ๋ถ์ ๋ฐ ๊ฒฐ๊ณผ๋ฅผ ์ฌ๊ธฐ์ ํ์ํฉ๋๋ค.")
|
133 |
-
|
134 |
-
# ์๊ฐํ ์ฐจํธ ์ถ๋ ฅ
|
135 |
-
chart_output = gr.Plot(label="์๊ฐํ ์ฐจํธ")
|
136 |
-
|
137 |
-
# ๋ถ์ ๋ฒํผ ํด๋ฆญ ์ ์ฐจํธ ์
๋ฐ์ดํธ
|
138 |
-
analyze_button.click(main, inputs=[employee_file, program_file, feedback_input], outputs=[output_text, chart_output])
|
139 |
-
|
140 |
# Gradio ์ธํฐํ์ด์ค ์คํ
|
141 |
demo.launch()
|
|
|
19 |
|
20 |
# ์ง์ ๋ฐ์ดํฐ๋ฅผ ๋ถ์ํ์ฌ ๊ต์ก ํ๋ก๊ทธ๋จ์ ์ถ์ฒํ๊ณ ๊ทธ๋ํ๋ฅผ ๊ทธ๋ฆฌ๋ ํจ์
|
21 |
def analyze_data(employee_file, program_file, feedback=None):
|
|
|
22 |
employee_df = pd.read_csv(employee_file.name)
|
23 |
program_df = pd.read_csv(program_file.name)
|
24 |
|
|
|
25 |
employee_skills = employee_df['current_skills'].tolist()
|
26 |
program_skills = program_df['skills_acquired'].tolist()
|
27 |
employee_embeddings = model.encode(employee_skills)
|
28 |
program_embeddings = model.encode(program_skills)
|
29 |
|
|
|
30 |
similarities = cosine_similarity(employee_embeddings, program_embeddings)
|
31 |
|
|
|
32 |
recommendations = []
|
33 |
for i, employee in employee_df.iterrows():
|
34 |
recommended_programs = []
|
35 |
for j, program in program_df.iterrows():
|
36 |
+
if similarities[i][j] > 0.5:
|
37 |
recommended_programs.append(f"{program['program_name']} ({program['duration']})")
|
38 |
|
39 |
if recommended_programs:
|
|
|
41 |
else:
|
42 |
recommendation = f"์ง์ {employee['employee_name']}์๊ฒ ์ ํฉํ ํ๋ก๊ทธ๋จ์ด ์์ต๋๋ค."
|
43 |
|
|
|
44 |
log_recommendation(employee['employee_name'], recommended_programs, feedback)
|
45 |
|
46 |
recommendations.append(recommendation)
|
47 |
|
|
|
48 |
result_text = "\n".join(recommendations)
|
49 |
|
|
|
50 |
G = nx.Graph()
|
51 |
for employee in employee_df['employee_name']:
|
52 |
G.add_node(employee, type='employee')
|
|
|
56 |
|
57 |
for i, employee in employee_df.iterrows():
|
58 |
for j, program in program_df.iterrows():
|
59 |
+
if similarities[i][j] > 0.5:
|
60 |
G.add_edge(employee['employee_name'], program['program_name'])
|
61 |
|
|
|
62 |
plt.figure(figsize=(10, 8))
|
63 |
pos = nx.spring_layout(G)
|
64 |
nx.draw(G, pos, with_labels=True, node_color='skyblue', node_size=2000, font_size=10, font_weight='bold')
|
|
|
67 |
|
68 |
return result_text, plt.gcf()
|
69 |
|
|
|
|
|
|
|
|
|
70 |
# ์์ ๋ฐ์ดํฐ๋ฅผ ๋ณด์ฌ์ฃผ๋ ํจ์
|
71 |
def show_example_data():
|
72 |
employee_example = pd.DataFrame({
|
|
|
96 |
with gr.Row():
|
97 |
with gr.Column(scale=1):
|
98 |
gr.Markdown("# HybridRAG ์์คํ
")
|
99 |
+
|
100 |
+
# ์ญํ ์ ํ (HR vs ์ง์)
|
101 |
+
role = gr.Radio(["HR ๊ด๋ฆฌ์", "์ง์"], label="์ญํ ์ ์ ํํ์ธ์")
|
102 |
+
|
103 |
+
# ์ญํ ์ ๋ฐ๋ฅธ ์กฐ๊ฑด ๋ถ๊ธฐ
|
104 |
+
with gr.Tabs() as tabs:
|
105 |
+
with gr.Tab("HR ๊ด๋ฆฌ์"):
|
106 |
+
with gr.Box(visible=True) as hr_admin_box:
|
107 |
+
gr.Markdown("## HR ๊ด๋ฆฌ์ ์ธํฐํ์ด์ค")
|
108 |
+
employee_file = gr.File(label="์ง์ ๋ฐ์ดํฐ ์
๋ก๋")
|
109 |
+
program_file = gr.File(label="๊ต์ก ํ๋ก๊ทธ๋จ ๋ฐ์ดํฐ ์
๋ก๋")
|
110 |
+
analyze_button = gr.Button("๋ถ์ ์์")
|
111 |
+
output_text = gr.Textbox(label="๋ถ์ ๊ฒฐ๊ณผ")
|
112 |
+
|
113 |
+
# HR ๊ด๋ฆฌ์๋ง ์ฌ์ฉํ ์ ์๋ ๊ธฐ๋ฅ์ ์ถ๊ฐ
|
114 |
+
feedback_input = gr.Radio(choices=["๋ง์กฑ", "๋ถ๋ง์กฑ"], label="์ง์ ํผ๋๋ฐฑ ๊ธฐ๋ก")
|
115 |
+
|
116 |
+
analyze_button.click(analyze_data, inputs=[employee_file, program_file, feedback_input], outputs=[output_text])
|
117 |
+
|
118 |
+
with gr.Tab("์ง์"):
|
119 |
+
with gr.Box(visible=True) as employee_box:
|
120 |
+
gr.Markdown("## ์ง์ ์ธํฐํ์ด์ค")
|
121 |
+
gr.Markdown("์ง์์๊ฒ ๋ง์ถคํ ๊ต์ก ํ๋ก๊ทธ๋จ ์ถ์ฒ์ ์ ๊ณตํฉ๋๋ค.")
|
122 |
+
employee_data = gr.DataFrame(label="์ง์ ๊ฐ์ธ ๋ฐ์ดํฐ ์์")
|
123 |
+
gr.Button("ํ๋ก๊ทธ๋จ ์ถ์ฒ ์์")
|
124 |
|
125 |
# ์์ ๋ฐ์ดํฐ๋ฅผ ๋ฏธ๋ฆฌ๋ณด๊ธฐ๋ก ์ ๊ณต
|
126 |
example_button = gr.Button("์์ ๋ฐ์ดํฐ ๋ณด๊ธฐ")
|
|
|
128 |
program_example_output = gr.DataFrame(label="๊ต์ก ํ๋ก๊ทธ๋จ ๋ฐ์ดํฐ ์์")
|
129 |
example_button.click(show_example_data, outputs=[employee_example_output, program_example_output])
|
130 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
131 |
# Gradio ์ธํฐํ์ด์ค ์คํ
|
132 |
demo.launch()
|