Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,23 +1,34 @@
|
|
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 |
-
|
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:
|
@@ -27,26 +38,36 @@ def analyze_data(employee_file, program_file):
|
|
27 |
|
28 |
recommendations.append(recommendation)
|
29 |
|
30 |
-
#
|
31 |
result_text = "\n".join(recommendations)
|
32 |
|
33 |
-
#
|
34 |
-
|
35 |
-
|
36 |
-
|
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):
|
|
|
1 |
import gradio as gr
|
2 |
import pandas as pd
|
3 |
+
from sentence_transformers import SentenceTransformer
|
4 |
+
from sklearn.metrics.pairwise import cosine_similarity
|
5 |
+
import networkx as nx
|
6 |
import matplotlib.pyplot as plt
|
7 |
|
8 |
+
# Sentence-BERT ๋ชจ๋ธ ๋ก๋
|
9 |
+
model = SentenceTransformer('all-MiniLM-L6-v2')
|
10 |
+
|
11 |
+
# ์ง์ ๋ฐ์ดํฐ๋ฅผ ๋ถ์ํ์ฌ ๊ต์ก ํ๋ก๊ทธ๋จ์ ์ถ์ฒํ๊ณ ๊ทธ๋ํ๋ฅผ ๊ทธ๋ฆฌ๋ ํจ์
|
12 |
def analyze_data(employee_file, program_file):
|
13 |
# ์ง์ ๋ฐ์ดํฐ์ ๊ต์ก ํ๋ก๊ทธ๋จ ๋ฐ์ดํฐ ๋ถ๋ฌ์ค๊ธฐ
|
14 |
employee_df = pd.read_csv(employee_file.name)
|
15 |
program_df = pd.read_csv(program_file.name)
|
16 |
|
17 |
+
# ์ง์ ์ญ๋๊ณผ ํ๋ก๊ทธ๋จ ํ์ต ๋ชฉํ๋ฅผ ๋ฒกํฐํ
|
18 |
+
employee_skills = employee_df['current_skills'].tolist()
|
19 |
+
program_skills = program_df['skills_acquired'].tolist()
|
20 |
+
employee_embeddings = model.encode(employee_skills)
|
21 |
+
program_embeddings = model.encode(program_skills)
|
22 |
+
|
23 |
+
# ์ ์ฌ๋ ๊ณ์ฐ
|
24 |
+
similarities = cosine_similarity(employee_embeddings, program_embeddings)
|
25 |
+
|
26 |
# ์ง์๋ณ ์ถ์ฒ ํ๋ก๊ทธ๋จ ๋ฆฌ์คํธ
|
27 |
recommendations = []
|
28 |
+
for i, employee in employee_df.iterrows():
|
|
|
29 |
recommended_programs = []
|
30 |
+
for j, program in program_df.iterrows():
|
31 |
+
if similarities[i][j] > 0.5: # ์ ์ฌ๋ ์๊ณ๊ฐ ๊ธฐ์ค
|
|
|
|
|
|
|
32 |
recommended_programs.append(f"{program['program_name']} ({program['duration']})")
|
33 |
|
34 |
if recommended_programs:
|
|
|
38 |
|
39 |
recommendations.append(recommendation)
|
40 |
|
41 |
+
# ๊ฒฐ๊ณผ ํ
์คํธ
|
42 |
result_text = "\n".join(recommendations)
|
43 |
|
44 |
+
# ๋คํธ์ํฌ ๊ทธ๋ํ ์์ฑ
|
45 |
+
G = nx.Graph()
|
46 |
+
for employee in employee_df['employee_name']:
|
47 |
+
G.add_node(employee, type='employee')
|
|
|
|
|
|
|
48 |
|
49 |
+
for program in program_df['program_name']:
|
50 |
+
G.add_node(program, type='program')
|
51 |
+
|
52 |
+
for i, employee in employee_df.iterrows():
|
53 |
+
for j, program in program_df.iterrows():
|
54 |
+
if similarities[i][j] > 0.5: # ์ ์ฌ๋ ์๊ณ๊ฐ
|
55 |
+
G.add_edge(employee['employee_name'], program['program_name'])
|
56 |
+
|
57 |
+
# ๊ทธ๋ํ ์๊ฐํ
|
58 |
+
plt.figure(figsize=(10, 8))
|
59 |
+
pos = nx.spring_layout(G)
|
60 |
+
nx.draw(G, pos, with_labels=True, node_color='skyblue', node_size=2000, font_size=10, font_weight='bold')
|
61 |
+
plt.title("์ง์๊ณผ ํ๋ก๊ทธ๋จ ๊ฐ์ ๊ด๊ณ")
|
62 |
plt.tight_layout()
|
63 |
+
|
64 |
return result_text, plt.gcf()
|
65 |
|
66 |
# Gradio ์ธํฐํ์ด์ค ์ ์
|
67 |
def main(employee_file, program_file):
|
68 |
return analyze_data(employee_file, program_file)
|
69 |
|
70 |
+
# Gradio ๋ธ๋ก
|
71 |
with gr.Blocks() as demo:
|
72 |
with gr.Row():
|
73 |
with gr.Column(scale=1):
|