-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrecheck.py
137 lines (114 loc) · 3.25 KB
/
recheck.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
# %%
import json
import pickle
from copy import deepcopy
from pathlib import Path
from pprint import pprint
import polars as pl
from sklearn.model_selection import ParameterGrid
from tqdm import tqdm
from src.utils.logging import read_and_process, read_logs
pl.Config.set_fmt_str_lengths(150)
pl.Config.set_tbl_rows(30)
# %%
df_overall = pl.read_csv("results/master_list.csv")
all_configurations = {
"source_table": [
"company_employees",
"housing_prices",
"us_elections",
"us_accidents_2021",
"schools",
"us_county_population",
],
"target_dl": [
"binary_update",
"wordnet_vldb_10",
"wordnet_vldb_50",
"wordnet_full",
"open_data_us",
],
"jd_method": ["minhash", "minhash_hybrid", "exact_matching", "starmie"],
"chosen_model": ["catboost", "ridgecv", "realmlp", "resnet"],
"aggregation": ["first", "mean", "dfs"],
"estimator": [
"full_join",
"nojoin",
"highest_containment",
"best_single_join",
"stepwise_greedy_join",
],
}
def prepare_config(config_dict):
pars = ParameterGrid(config_dict)
df_config = pl.from_dicts(list(pars))
return df_config
df_all_config = prepare_config(all_configurations)
keys = df_all_config.columns
# preparing impossible configurations
# impossible configurations are combinations that do not exist because the methods could not be run
impossible_starmie = df_all_config.filter(
(pl.col("jd_method") == "starmie")
& (pl.col("target_dl").is_in(["open_data_us", "wordnet_vldb_50"]))
)
impossible_internal_tables = df_all_config.filter(
((pl.col("source_table") == "schools") & (~(pl.col("target_dl") == "open_data_us")))
| (
(pl.col("source_table") == "us_county_population")
& ((pl.col("target_dl") == "open_data_us"))
)
)
df_cleaned = df_all_config.join(impossible_starmie, on=keys, how="anti").join(
impossible_internal_tables, on=keys, how="anti"
)
# %%
# Configurations I need for different plots
# Compare retrieval methods
runs_starmie = df_cleaned.filter(
(pl.col("aggregation") == "first")
& ~(pl.col("target_dl").is_in(["open_data_us", "wordnet_vldb_50"]))
)
# Compare methods across all data lakes/tables
runs_general = df_cleaned.filter(
(pl.col("aggregation") == "first") & (pl.col("jd_method") != "starmie")
)
runs_aggr_1 = df_cleaned.filter(
((pl.col("jd_method") != "starmie"))
& (
(
pl.col("estimator").is_in(
["nojoin", "best_single_join", "highest_containment"]
)
)
)
)
runs_aggr_2 = df_cleaned.filter(
(~pl.col("target_dl").is_in(["open_data_us", "wordnet_vldb_50"]))
& (
(
pl.col("estimator").is_in(
["nojoin", "best_single_join", "highest_containment"]
)
)
)
)
# %%
(
runs_aggr_1.join(df_overall, on=keys, how="left")
.filter(~pl.col("status").is_null())
.group_by(keys)
.agg(pl.len())
.filter(pl.col("len") < 10)
.sort("target_dl")
)
# .write_csv("incomplete.csv")
# %%
(
runs_aggr_1.join(df_overall, on=keys, how="left")
.filter(pl.col("status").is_null())
.group_by(keys)
.agg(pl.len())
.sort("target_dl")
)
# .write_csv("incomplete.csv")
# %%