| import pandas as pd |
| from scipy.spatial.distance import euclidean |
| import gradio as gr |
|
|
| def rank_candidates(candidates, ideal_scores): |
| |
| ranked = sorted(candidates, key=lambda x: euclidean(x["スコア"], ideal_scores)) |
| return pd.DataFrame(ranked) |
|
|
| |
| candidates = [ |
| {"候補者ID": "candidate1", "名前": "伊藤 卓郎", "スコア": [8, 7, 9]}, |
| {"候補者ID": "candidate2", "名前": "上川 一郎", "スコア": [9, 8, 9]}, |
| {"候補者ID": "candidate3", "名前": "佐久間 孝彦", "スコア": [7, 6, 8]}, |
| {"候補者ID": "candidate4", "名前": "寺田 智", "スコア": [8, 8, 8]}, |
| {"候補者ID": "candidate5", "名前": "佐藤 和人", "スコア": [6, 9, 7]}, |
| {"候補者ID": "candidate6", "名前": "本間 武", "スコア": [7, 6, 9]}, |
| {"候補者ID": "candidate7", "名前": "坂本 吾郎", "スコア": [8, 7, 5]}, |
| {"候補者ID": "candidate8", "名前": "広川 裕子", "スコア": [7, 9, 7]}, |
| {"候補者ID": "candidate9", "名前": "小沢 茂美", "スコア": [7, 6, 5]}, |
| {"候補者ID": "candidate10", "名前": "小暮 琢磨", "スコア": [8, 7, 7]}, |
| {"候補者ID": "candidate11", "名前": "川上 伸介", "スコア": [8, 6, 8]}, |
| {"候補者ID": "candidate12", "名前": "野沢 百合子", "スコア": [7, 6, 8]}, |
| {"候補者ID": "candidate13", "名前": "広沢 啓介", "スコア": [4, 9, 5]}, |
| {"候補者ID": "candidate14", "名前": "野口 琢磨", "スコア": [7, 5, 5]}, |
| {"候補者ID": "candidate15", "名前": "進藤 洋二", "スコア": [7, 8, 6]} |
| ] |
|
|
| models = ['モデル1(信頼性の高さ、計画性のある進行)', 'モデル2(積極的な姿勢、データドリブンアプローチ)', 'モデル3(高度なプレゼン力、結果志向の行動)'] |
| model_scores = {'モデル1(信頼性の高さ、計画性のある進行)': [9, 10, 9], 'モデル2(積極的な姿勢、データドリブンアプローチ)': [9, 8, 8], 'モデル3(高度なプレゼン力、結果志向の行動)': [8, 9, 9]} |
|
|
|
|
| |
| ideal_scores = [10, 9, 10] |
|
|
| def return_model_scores(rs): |
| |
| scores = model_scores.get(rs, [None, None, None]) |
| return scores[0], scores[1], scores[2] |
|
|
| def display_ranked_df(continuity, decision, hypo): |
| |
| dynamic_ideal_scores = [int(continuity), int(decision), int(hypo)] |
| ranked_df = rank_candidates(candidates, dynamic_ideal_scores) |
|
|
| |
| styled_html = f""" |
| <div style="display: flex; justify-content: center; flex-direction: column; align-items: center;"> |
| {ranked_df.to_html(index=False, show_dimensions=True)} |
| </div> |
| """ |
| return styled_html |
| |
|
|
| |
| with gr.Blocks(css="footer {visibility: hidden;}",theme=gr.themes.Glass(),title="Candidate Evaluation") as app: |
| gr.Markdown("### 候補者ランキングツール") |
| rs = gr.Dropdown(label="モデル", choices=models, value='モデル1') |
|
|
| continuity = gr.Number(label="継続力スコア") |
| decision = gr.Number(label="投資判断スコア") |
| hypo = gr.Number(label="仮説構築力スコア") |
| result = gr.HTML(label="ランク付け結果") |
| button = gr.Button("ランキングを表示") |
|
|
| rs.change(fn=return_model_scores, inputs=[rs], outputs=[continuity,decision,hypo]) |
| |
| button.click( |
| display_ranked_df, |
| inputs=[continuity, decision, hypo], |
| outputs=[result] |
| ) |
|
|
| app.launch(favicon_path="favicon.ico") |
|
|