-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcombined_preparation.py
49 lines (44 loc) · 1.32 KB
/
combined_preparation.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import datetime
from pathlib import Path
from cv_preparation import cv_evaluation_preparation
from nlp_preparation import nlp_evaluation_preparation
from src.eval import summarize_cv_predictions
def all_evaluation_preparation(
cv_batch_size,
cv_model_name,
cv_model_path,
cv_coef,
nlp_batch_size,
nlp_model_name,
nlp_max_seq_len,
nlp_model_path,
nlp_coef,
n_classes,
device
):
submissions = Path("submissions") / "combined"
model_name = "combined"
_, cv_probs = cv_evaluation_preparation(
cv_batch_size,
cv_model_name,
cv_model_path,
n_classes,
device
)
cv_probs[[0, 1, 3, 4, 5, 6]] *= cv_coef
_, nlp_probs = nlp_evaluation_preparation(
nlp_batch_size,
nlp_model_name,
nlp_model_path,
nlp_max_seq_len,
n_classes,
device
)
nlp_probs[[0, 1, 3, 4, 5, 6]] *= nlp_coef
final_df = cv_probs.groupby('Id').sum().add(nlp_probs.groupby('Id').sum(), fill_value=0).reset_index()
# final_df = cv_probs.append(nlp_probs)
final_df = summarize_cv_predictions(final_df)
final_df = final_df[["Id", "Predicted"]]
final_df.to_csv(
submissions / f"{model_name}-{int(datetime.datetime.now().timestamp())}.csv",
index=False)