Spaces:
Running
Running
v0.10.9
#31
by DmitryRyumin - opened
- app/event_handlers/calculate_practical_tasks.py +27 -77
- app/event_handlers/practical_subtasks.py +1 -8
- app/event_handlers/practical_task_sorted.py +1 -7
- app/utils.py +24 -9
- config.toml +8 -9
- practical_tasks_en.yaml +0 -1
- practical_tasks_ru.yaml +0 -1
- requirements.txt +1 -1
app/event_handlers/calculate_practical_tasks.py
CHANGED
|
@@ -576,12 +576,8 @@ def event_handler_calculate_practical_task_blocks(
|
|
| 576 |
elif practical_subtasks.lower() == "professional skills":
|
| 577 |
df_professional_skills = read_csv_file(config_data.Links_PROFESSIONAL_SKILLS)
|
| 578 |
|
| 579 |
-
pt_scores_copy = pt_scores.iloc[:, 1:].copy()
|
| 580 |
-
|
| 581 |
-
preprocess_scores_df(pt_scores_copy, config_data.Dataframes_PT_SCORES[0][0])
|
| 582 |
-
|
| 583 |
b5._priority_skill_calculation(
|
| 584 |
-
df_files=
|
| 585 |
correlation_coefficients=df_professional_skills,
|
| 586 |
threshold=threshold_professional_skills,
|
| 587 |
out=False,
|
|
@@ -611,13 +607,13 @@ def event_handler_calculate_practical_task_blocks(
|
|
| 611 |
df_hidden = df_hidden.sort_values(
|
| 612 |
by=[dropdown_professional_skills], ascending=False
|
| 613 |
)
|
| 614 |
-
df_hidden.reset_index(inplace=True)
|
| 615 |
elif type_modes == config_data.Settings_TYPE_MODES[1]:
|
| 616 |
df_hidden = df_hidden.melt(
|
| 617 |
var_name="Professional Skill", value_name="Summary Score"
|
| 618 |
)
|
| 619 |
df_hidden = df_hidden.sort_values(by=["Summary Score"], ascending=False)
|
| 620 |
-
|
|
|
|
| 621 |
|
| 622 |
df_hidden.to_csv(config_data.Filenames_PT_SKILLS_SCORES)
|
| 623 |
|
|
@@ -666,83 +662,37 @@ def event_handler_calculate_practical_task_blocks(
|
|
| 666 |
elif (
|
| 667 |
practical_subtasks.lower() == "finding a suitable junior colleague"
|
| 668 |
or practical_subtasks.lower() == "finding a suitable senior colleague"
|
| 669 |
-
or practical_subtasks.lower()
|
| 670 |
-
== "finding a suitable colleague by personality types"
|
| 671 |
):
|
| 672 |
-
|
| 673 |
-
|
| 674 |
-
|
| 675 |
-
|
| 676 |
-
if (
|
| 677 |
-
practical_subtasks.lower()
|
| 678 |
-
!= "finding a suitable colleague by personality types"
|
| 679 |
-
):
|
| 680 |
-
df_correlation_coefficients = read_csv_file(
|
| 681 |
-
config_data.Links_FINDING_COLLEAGUE, ["ID"]
|
| 682 |
-
)
|
| 683 |
-
|
| 684 |
-
b5._colleague_ranking(
|
| 685 |
-
df_files=pt_scores_copy,
|
| 686 |
-
correlation_coefficients=df_correlation_coefficients,
|
| 687 |
-
target_scores=[
|
| 688 |
-
target_score_ope,
|
| 689 |
-
target_score_con,
|
| 690 |
-
target_score_ext,
|
| 691 |
-
target_score_agr,
|
| 692 |
-
target_score_nneu,
|
| 693 |
-
],
|
| 694 |
-
colleague=colleague_type(practical_subtasks),
|
| 695 |
-
equal_coefficients=equal_coefficient,
|
| 696 |
-
out=False,
|
| 697 |
-
)
|
| 698 |
-
df = apply_rounding_and_rename_columns(b5.df_files_colleague_)
|
| 699 |
|
| 700 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 701 |
|
| 702 |
-
|
| 703 |
-
colleague_type(practical_subtasks)
|
| 704 |
-
+ config_data.Filenames_COLLEAGUE_RANKING
|
| 705 |
-
)
|
| 706 |
-
else:
|
| 707 |
-
b5._colleague_personality_type_match(
|
| 708 |
-
df_files=pt_scores_copy,
|
| 709 |
-
correlation_coefficients=None,
|
| 710 |
-
target_scores=[
|
| 711 |
-
target_score_ope,
|
| 712 |
-
target_score_con,
|
| 713 |
-
target_score_ext,
|
| 714 |
-
target_score_agr,
|
| 715 |
-
target_score_nneu,
|
| 716 |
-
],
|
| 717 |
-
threshold=equal_coefficient,
|
| 718 |
-
out=False,
|
| 719 |
-
)
|
| 720 |
-
df = b5.df_files_MBTI_colleague_match_.rename(
|
| 721 |
-
columns={
|
| 722 |
-
"MBTI": "Personality Type",
|
| 723 |
-
"MBTI_Score": "Personality Type Score",
|
| 724 |
-
}
|
| 725 |
-
)
|
| 726 |
|
| 727 |
-
|
| 728 |
|
| 729 |
-
|
|
|
|
|
|
|
| 730 |
|
| 731 |
df_hidden.reset_index(inplace=True)
|
| 732 |
|
| 733 |
-
person_id = (
|
| 734 |
-
int(
|
| 735 |
-
df_hidden.iloc[
|
| 736 |
-
(
|
| 737 |
-
0
|
| 738 |
-
if practical_subtasks.lower()
|
| 739 |
-
!= "finding a suitable colleague by personality types"
|
| 740 |
-
else 1
|
| 741 |
-
)
|
| 742 |
-
][config_data.Dataframes_PT_SCORES[0][0]]
|
| 743 |
-
)
|
| 744 |
-
- 1
|
| 745 |
-
)
|
| 746 |
|
| 747 |
person_metadata = create_person_metadata(person_id, files, video_metadata)
|
| 748 |
|
|
@@ -838,7 +788,7 @@ def event_handler_calculate_practical_task_blocks(
|
|
| 838 |
|
| 839 |
df_hidden = df_hidden.reset_index()
|
| 840 |
|
| 841 |
-
df_hidden.columns = ["
|
| 842 |
|
| 843 |
df_hidden.to_csv(consumer_preferences(practical_subtasks))
|
| 844 |
|
|
|
|
| 576 |
elif practical_subtasks.lower() == "professional skills":
|
| 577 |
df_professional_skills = read_csv_file(config_data.Links_PROFESSIONAL_SKILLS)
|
| 578 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 579 |
b5._priority_skill_calculation(
|
| 580 |
+
df_files=pt_scores.iloc[:, 1:],
|
| 581 |
correlation_coefficients=df_professional_skills,
|
| 582 |
threshold=threshold_professional_skills,
|
| 583 |
out=False,
|
|
|
|
| 607 |
df_hidden = df_hidden.sort_values(
|
| 608 |
by=[dropdown_professional_skills], ascending=False
|
| 609 |
)
|
|
|
|
| 610 |
elif type_modes == config_data.Settings_TYPE_MODES[1]:
|
| 611 |
df_hidden = df_hidden.melt(
|
| 612 |
var_name="Professional Skill", value_name="Summary Score"
|
| 613 |
)
|
| 614 |
df_hidden = df_hidden.sort_values(by=["Summary Score"], ascending=False)
|
| 615 |
+
|
| 616 |
+
df_hidden.reset_index(drop=True, inplace=True)
|
| 617 |
|
| 618 |
df_hidden.to_csv(config_data.Filenames_PT_SKILLS_SCORES)
|
| 619 |
|
|
|
|
| 662 |
elif (
|
| 663 |
practical_subtasks.lower() == "finding a suitable junior colleague"
|
| 664 |
or practical_subtasks.lower() == "finding a suitable senior colleague"
|
|
|
|
|
|
|
| 665 |
):
|
| 666 |
+
df_correlation_coefficients = read_csv_file(
|
| 667 |
+
config_data.Links_FINDING_COLLEAGUE, ["ID"]
|
| 668 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 669 |
|
| 670 |
+
b5._colleague_ranking(
|
| 671 |
+
df_files=pt_scores.iloc[:, 1:],
|
| 672 |
+
correlation_coefficients=df_correlation_coefficients,
|
| 673 |
+
target_scores=[
|
| 674 |
+
target_score_ope,
|
| 675 |
+
target_score_con,
|
| 676 |
+
target_score_ext,
|
| 677 |
+
target_score_agr,
|
| 678 |
+
target_score_nneu,
|
| 679 |
+
],
|
| 680 |
+
colleague=colleague_type(practical_subtasks),
|
| 681 |
+
equal_coefficients=equal_coefficient,
|
| 682 |
+
out=False,
|
| 683 |
+
)
|
| 684 |
|
| 685 |
+
df = apply_rounding_and_rename_columns(b5.df_files_colleague_)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 686 |
|
| 687 |
+
df_hidden = df.drop(columns=config_data.Settings_SHORT_PROFESSIONAL_SKILLS)
|
| 688 |
|
| 689 |
+
df_hidden.to_csv(
|
| 690 |
+
colleague_type(practical_subtasks) + config_data.Filenames_COLLEAGUE_RANKING
|
| 691 |
+
)
|
| 692 |
|
| 693 |
df_hidden.reset_index(inplace=True)
|
| 694 |
|
| 695 |
+
person_id = int(df_hidden.iloc[0][config_data.Dataframes_PT_SCORES[0][0]]) - 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 696 |
|
| 697 |
person_metadata = create_person_metadata(person_id, files, video_metadata)
|
| 698 |
|
|
|
|
| 788 |
|
| 789 |
df_hidden = df_hidden.reset_index()
|
| 790 |
|
| 791 |
+
df_hidden.columns = ["Category", "Priority"]
|
| 792 |
|
| 793 |
df_hidden.to_csv(consumer_preferences(practical_subtasks))
|
| 794 |
|
app/event_handlers/practical_subtasks.py
CHANGED
|
@@ -219,8 +219,6 @@ def event_handler_practical_subtasks(
|
|
| 219 |
elif (
|
| 220 |
practical_subtasks.lower() == "finding a suitable junior colleague"
|
| 221 |
or practical_subtasks.lower() == "finding a suitable senior colleague"
|
| 222 |
-
or practical_subtasks.lower()
|
| 223 |
-
== "finding a suitable colleague by personality types"
|
| 224 |
):
|
| 225 |
return (
|
| 226 |
practical_subtasks_selected,
|
|
@@ -299,12 +297,7 @@ def event_handler_practical_subtasks(
|
|
| 299 |
minimum=0.0,
|
| 300 |
maximum=1.0,
|
| 301 |
step=0.01,
|
| 302 |
-
label=
|
| 303 |
-
config_data.Labels_THRESHOLD_TARGET_SCORE_LABEL
|
| 304 |
-
if practical_subtasks.lower()
|
| 305 |
-
== "finding a suitable colleague by personality types"
|
| 306 |
-
else config_data.Labels_EQUAL_COEFFICIENT_LABEL
|
| 307 |
-
),
|
| 308 |
info=config_data.InformationMessages_VALUE_FROM_TO_INFO.format(0, 1.0),
|
| 309 |
show_label=True,
|
| 310 |
interactive=True,
|
|
|
|
| 219 |
elif (
|
| 220 |
practical_subtasks.lower() == "finding a suitable junior colleague"
|
| 221 |
or practical_subtasks.lower() == "finding a suitable senior colleague"
|
|
|
|
|
|
|
| 222 |
):
|
| 223 |
return (
|
| 224 |
practical_subtasks_selected,
|
|
|
|
| 297 |
minimum=0.0,
|
| 298 |
maximum=1.0,
|
| 299 |
step=0.01,
|
| 300 |
+
label=config_data.Labels_EQUAL_COEFFICIENT_LABEL,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 301 |
info=config_data.InformationMessages_VALUE_FROM_TO_INFO.format(0, 1.0),
|
| 302 |
show_label=True,
|
| 303 |
interactive=True,
|
app/event_handlers/practical_task_sorted.py
CHANGED
|
@@ -37,13 +37,7 @@ def event_handler_practical_task_sorted(
|
|
| 37 |
label = ""
|
| 38 |
label += " " + config_data.Dataframes_PT_SCORES[0][0]
|
| 39 |
|
| 40 |
-
|
| 41 |
-
is_filename = Path(files[person_id]).name in video_metadata
|
| 42 |
-
except IndexError:
|
| 43 |
-
is_filename = False
|
| 44 |
-
person_id = 0
|
| 45 |
-
|
| 46 |
-
if is_filename:
|
| 47 |
person_metadata_list = video_metadata[Path(files[person_id]).name]
|
| 48 |
|
| 49 |
person_metadata = (
|
|
|
|
| 37 |
label = ""
|
| 38 |
label += " " + config_data.Dataframes_PT_SCORES[0][0]
|
| 39 |
|
| 40 |
+
if Path(files[person_id]).name in video_metadata:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
person_metadata_list = video_metadata[Path(files[person_id]).name]
|
| 42 |
|
| 43 |
person_metadata = (
|
app/utils.py
CHANGED
|
@@ -7,7 +7,7 @@ License: MIT License
|
|
| 7 |
|
| 8 |
import pandas as pd
|
| 9 |
import subprocess
|
| 10 |
-
import
|
| 11 |
|
| 12 |
# Importing necessary components for the Gradio app
|
| 13 |
from app.config import config_data
|
|
@@ -49,7 +49,7 @@ def read_csv_file(file_path, drop_columns=[]):
|
|
| 49 |
|
| 50 |
def round_numeric_values(x):
|
| 51 |
if isinstance(x, (int, float)):
|
| 52 |
-
return round(x,
|
| 53 |
|
| 54 |
return x
|
| 55 |
|
|
@@ -87,11 +87,26 @@ def extract_profession_weights(df, dropdown_candidates):
|
|
| 87 |
|
| 88 |
return weights_professions, interactive_professions
|
| 89 |
|
| 90 |
-
def webm2mp4(input_file: str) -> str:
|
| 91 |
-
path_save = os.path.splitext(input_file)[0] + ".mp4"
|
| 92 |
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
import pandas as pd
|
| 9 |
import subprocess
|
| 10 |
+
from pathlib import Path
|
| 11 |
|
| 12 |
# Importing necessary components for the Gradio app
|
| 13 |
from app.config import config_data
|
|
|
|
| 49 |
|
| 50 |
def round_numeric_values(x):
|
| 51 |
if isinstance(x, (int, float)):
|
| 52 |
+
return round(x, 3)
|
| 53 |
|
| 54 |
return x
|
| 55 |
|
|
|
|
| 87 |
|
| 88 |
return weights_professions, interactive_professions
|
| 89 |
|
|
|
|
|
|
|
| 90 |
|
| 91 |
+
def webm2mp4(input_file):
|
| 92 |
+
input_path = Path(input_file)
|
| 93 |
+
output_path = input_path.with_suffix(".mp4")
|
| 94 |
+
|
| 95 |
+
if not output_path.exists():
|
| 96 |
+
subprocess.run(
|
| 97 |
+
[
|
| 98 |
+
"ffmpeg",
|
| 99 |
+
"-i",
|
| 100 |
+
str(input_path),
|
| 101 |
+
"-c:v",
|
| 102 |
+
"copy",
|
| 103 |
+
"-c:a",
|
| 104 |
+
"aac",
|
| 105 |
+
"-strict",
|
| 106 |
+
"experimental",
|
| 107 |
+
str(output_path),
|
| 108 |
+
],
|
| 109 |
+
check=True,
|
| 110 |
+
)
|
| 111 |
+
|
| 112 |
+
return str(output_path)
|
config.toml
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
[AppSettings]
|
| 2 |
-
APP_VERSION = "0.
|
| 3 |
SERVER_NAME = "127.0.0.1"
|
| 4 |
PORT = 7860
|
| 5 |
CSS_PATH = "app.css"
|
|
@@ -72,7 +72,6 @@ TARGET_SCORE_EXT_LABEL = "Extraversion target score"
|
|
| 72 |
TARGET_SCORE_AGR_LABEL = "Agreeableness target score"
|
| 73 |
TARGET_SCORE_NNEU_LABEL = "Non-Neuroticism target score"
|
| 74 |
EQUAL_COEFFICIENT_LABEL = "Equal coefficient"
|
| 75 |
-
THRESHOLD_TARGET_SCORE_LABEL = "Polarity traits threshold"
|
| 76 |
NUMBER_PRIORITY_LABEL = "Priority number"
|
| 77 |
NUMBER_IMPORTANCE_TRAITS_LABEL = "Importance traits number"
|
| 78 |
NUMBER_IMPORTANCE_OPE_LABEL = "Openness weight"
|
|
@@ -160,10 +159,10 @@ TARGET_SCORES = [0.527886, 0.522337, 0.458468, 0.51761, 0.444649]
|
|
| 160 |
0_100 = [0, 100]
|
| 161 |
|
| 162 |
[Links]
|
| 163 |
-
PROFESSIONAL_SKILLS = "https://
|
| 164 |
-
FINDING_COLLEAGUE = "https://
|
| 165 |
-
CAR_CHARACTERISTICS = "https://
|
| 166 |
-
MDA_CATEGORIES = "https://
|
| 167 |
-
CLOTHING_SC = "https://
|
| 168 |
-
PROFESSIONS = "https://
|
| 169 |
-
MBTI = "https://
|
|
|
|
| 1 |
[AppSettings]
|
| 2 |
+
APP_VERSION = "0.10.8"
|
| 3 |
SERVER_NAME = "127.0.0.1"
|
| 4 |
PORT = 7860
|
| 5 |
CSS_PATH = "app.css"
|
|
|
|
| 72 |
TARGET_SCORE_AGR_LABEL = "Agreeableness target score"
|
| 73 |
TARGET_SCORE_NNEU_LABEL = "Non-Neuroticism target score"
|
| 74 |
EQUAL_COEFFICIENT_LABEL = "Equal coefficient"
|
|
|
|
| 75 |
NUMBER_PRIORITY_LABEL = "Priority number"
|
| 76 |
NUMBER_IMPORTANCE_TRAITS_LABEL = "Importance traits number"
|
| 77 |
NUMBER_IMPORTANCE_OPE_LABEL = "Openness weight"
|
|
|
|
| 159 |
0_100 = [0, 100]
|
| 160 |
|
| 161 |
[Links]
|
| 162 |
+
PROFESSIONAL_SKILLS = "https://download.sberdisk.ru/download/file/478678231?token=0qiZwliLtHWWYMv&filename=professional_skills.csv"
|
| 163 |
+
FINDING_COLLEAGUE = "https://download.sberdisk.ru/download/file/478675819?token=LuB7L1QsEY0UuSs&filename=colleague_ranking.csv"
|
| 164 |
+
CAR_CHARACTERISTICS = "https://download.sberdisk.ru/download/file/478675818?token=EjfLMqOeK8cfnOu&filename=auto_characteristics.csv"
|
| 165 |
+
MDA_CATEGORIES = "https://download.sberdisk.ru/download/file/478676690?token=7KcAxPqMpWiYQnx&filename=divice_characteristics.csv"
|
| 166 |
+
CLOTHING_SC = "https://download.sberdisk.ru/download/file/493644097?token=KGtSGMxjZtWXmBz&filename=df_%D1%81lothing_style_correlation.csv"
|
| 167 |
+
PROFESSIONS = "https://download.sberdisk.ru/download/file/478675798?token=fF5fNZVpthQlEV0&filename=traits_priority_for_professions.csv"
|
| 168 |
+
MBTI = "https://download.sberdisk.ru/download/file/493644095?token=EX7hFxNJhMoLumI&filename=df_mbti_correlation.csv"
|
practical_tasks_en.yaml
CHANGED
|
@@ -7,7 +7,6 @@
|
|
| 7 |
subtasks:
|
| 8 |
- "Finding a suitable junior colleague"
|
| 9 |
- "Finding a suitable senior colleague"
|
| 10 |
-
- "Finding a suitable colleague by personality types"
|
| 11 |
- task: "Predicting consumer preferences for industrial goods"
|
| 12 |
subtasks:
|
| 13 |
- "Car characteristics"
|
|
|
|
| 7 |
subtasks:
|
| 8 |
- "Finding a suitable junior colleague"
|
| 9 |
- "Finding a suitable senior colleague"
|
|
|
|
| 10 |
- task: "Predicting consumer preferences for industrial goods"
|
| 11 |
subtasks:
|
| 12 |
- "Car characteristics"
|
practical_tasks_ru.yaml
CHANGED
|
@@ -7,7 +7,6 @@
|
|
| 7 |
subtasks:
|
| 8 |
- "Поиск подходящего младшего коллеги"
|
| 9 |
- "Поиск подходящего старшего коллеги"
|
| 10 |
-
- "Поиск подходящего коллеги по типам личности"
|
| 11 |
- task: "Прогнозирование потребительских предпочтений в отношении промышленных товаров"
|
| 12 |
subtasks:
|
| 13 |
- "Характеристики автомобиля"
|
|
|
|
| 7 |
subtasks:
|
| 8 |
- "Поиск подходящего младшего коллеги"
|
| 9 |
- "Поиск подходящего старшего коллеги"
|
|
|
|
| 10 |
- task: "Прогнозирование потребительских предпочтений в отношении промышленных товаров"
|
| 11 |
subtasks:
|
| 12 |
- "Характеристики автомобиля"
|
requirements.txt
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
gradio==5.8.0
|
| 2 |
PyYAML==6.0.2
|
| 3 |
toml==0.10.2
|
| 4 |
-
oceanai==1.0.
|
| 5 |
torch==2.2.2
|
| 6 |
psutil==6.1.0
|
| 7 |
beautifulsoup4==4.12.3
|
|
|
|
| 1 |
gradio==5.8.0
|
| 2 |
PyYAML==6.0.2
|
| 3 |
toml==0.10.2
|
| 4 |
+
oceanai==1.0.0a46
|
| 5 |
torch==2.2.2
|
| 6 |
psutil==6.1.0
|
| 7 |
beautifulsoup4==4.12.3
|