db_name_prefix with or without exp

This commit is contained in:
HaoYizhi 2023-06-11 20:28:51 +08:00
parent dbbdbc935a
commit c367252da2
9 changed files with 36 additions and 31 deletions

2
.vscode/launch.json vendored
View File

@ -14,7 +14,7 @@
"args": [
"--exp", "without_exp",
"--reset_db", "True",
"--job", "30"
"--job", "24"
]
}
]

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1 +1 @@
db_name_prefix: test
db_name_prefix: without_exp

View File

@ -46,31 +46,36 @@ class ControllerDB:
Firm.fillna(0, inplace=True)
# fill dct_lst_init_remove_firm_prod
# list_dct = []
# for _, row in Firm.iterrows():
# code = row['Code']
# row = row['1':]
# for product_code in row.index[row == 1].to_list():
# dct = {code: [product_code]}
# list_dct.append(dct)
str_sql = "select e_id, count, max_max_ts, " \
"dct_lst_init_remove_firm_prod from " \
"iiabmdb.without_exp_experiment as a " \
"inner join " \
"(select e_id, count(id) as count, max(max_ts) as max_max_ts " \
"from iiabmdb.without_exp_sample as a " \
"inner join (select s_id, max(ts) as max_ts from " \
"iiabmdb.without_exp_result where ts > 0 group by s_id) as b " \
"on a.id = b.s_id " \
"group by e_id) as b " \
"on a.id = b.e_id " \
"order by count desc;"
result = pd.read_sql(sql=str_sql, con=engine)
result['dct_lst_init_remove_firm_prod'] = \
result['dct_lst_init_remove_firm_prod'].apply(
lambda x: pickle.loads(x))
list_dct = result.loc[result['count'] >= 9,
'dct_lst_init_remove_firm_prod'].to_list()
assert self.db_name_prefix in ['test', 'without_exp', 'with_exp'], \
"db name not in test, without_exp, with_exp"
list_dct = []
if self.db_name_prefix in ['test', 'without_exp']:
for _, row in Firm.iterrows():
code = row['Code']
row = row['1':]
for product_code in row.index[row == 1].to_list():
dct = {code: [product_code]}
list_dct.append(dct)
elif self.db_name_prefix in ['with_exp']:
str_sql = "select e_id, count, max_max_ts, " \
"dct_lst_init_remove_firm_prod from " \
"iiabmdb.without_exp_experiment as a " \
"inner join " \
"(select e_id, count(id) as count, max(max_ts) as max_max_ts "\
"from iiabmdb.without_exp_sample as a " \
"inner join (select s_id, max(ts) as max_ts from " \
"iiabmdb.without_exp_result where ts > 0 group by s_id) as b "\
"on a.id = b.s_id " \
"group by e_id) as b " \
"on a.id = b.e_id " \
"order by count desc;"
result = pd.read_sql(sql=str_sql, con=engine)
result['dct_lst_init_remove_firm_prod'] = \
result['dct_lst_init_remove_firm_prod'].apply(
lambda x: pickle.loads(x))
list_dct = result.loc[result['count'] >= 9,
'dct_lst_init_remove_firm_prod'].to_list()
# list_dct = [{'140': ['1.4.5.1']}]
# list_dct = [{'133': ['1.4.4.1']}]
# list_dct = [{'2': ['1.1.3']}]

View File

@ -1,4 +1,4 @@
n_max_trial,firm_req_prf_size,firm_req_prf_conn,cap_limit_prob_type,cap_limit_level,firm_acc_prf_size,firm_acc_prf_conn,diff_new_conn,crit_supplier,diff_remove,proactive_ratio,netw_sply_prf_n,netw_sply_prf_size,netw_cust_prf_n,netw_cust_prf_size
15,TRUE,TRUE,uniform,5,TRUE,TRUE,0.3,2,0.5,0.4,3,TRUE,3,TRUE
10,FALSE,FALSE,normal,10,FALSE,FALSE,0.5,1,1,0.6,2,FALSE,2,FALSE
5,,,,15,,,0.7,0.5,2,0.8,1,,1,
15,TRUE,TRUE,uniform,5,TRUE,TRUE,0.3,2,0.5,0.3,3,TRUE,3,TRUE
10,FALSE,FALSE,normal,10,FALSE,FALSE,0.5,1,1,0.5,2,FALSE,2,FALSE
5,,,,15,,,0.7,0.5,2,0.7,1,,1,

1 n_max_trial firm_req_prf_size firm_req_prf_conn cap_limit_prob_type cap_limit_level firm_acc_prf_size firm_acc_prf_conn diff_new_conn crit_supplier diff_remove proactive_ratio netw_sply_prf_n netw_sply_prf_size netw_cust_prf_n netw_cust_prf_size
2 15 TRUE TRUE uniform 5 TRUE TRUE 0.3 2 0.5 0.4 0.3 3 TRUE 3 TRUE
3 10 FALSE FALSE normal 10 FALSE FALSE 0.5 1 1 0.6 0.5 2 FALSE 2 FALSE
4 5 15 0.7 0.5 2 0.8 0.7 1 1

View File

@ -1,2 +1,2 @@
n_max_trial,firm_req_prf_size,firm_req_prf_conn,cap_limit_prob_type,cap_limit_level,firm_acc_prf_size,firm_acc_prf_conn,diff_new_conn,crit_supplier,diff_remove,proactive_ratio,netw_sply_prf_n,netw_sply_prf_size,netw_cust_prf_n,netw_cust_prf_size
10,TRUE,TRUE,uniform,10,TRUE,TRUE,0.7,1,1,0.9,2,TRUE,2,TRUE
10,TRUE,TRUE,uniform,10,TRUE,TRUE,0.5,1,1,0,2,TRUE,2,TRUE

1 n_max_trial firm_req_prf_size firm_req_prf_conn cap_limit_prob_type cap_limit_level firm_acc_prf_size firm_acc_prf_conn diff_new_conn crit_supplier diff_remove proactive_ratio netw_sply_prf_n netw_sply_prf_size netw_cust_prf_n netw_cust_prf_size
2 10 TRUE TRUE uniform 10 TRUE TRUE 0.7 0.5 1 1 0.9 0 2 TRUE 2 TRUE