experiments'
This commit is contained in:
parent
9dce034cf2
commit
9ebdb89332
|
@ -12,7 +12,7 @@
|
||||||
"console": "integratedTerminal",
|
"console": "integratedTerminal",
|
||||||
"justMyCode": true,
|
"justMyCode": true,
|
||||||
"args": [
|
"args": [
|
||||||
"--exp", "without_exp",
|
"--exp", "with_exp",
|
||||||
"--reset_db", "True",
|
"--reset_db", "True",
|
||||||
"--job", "24"
|
"--job", "24"
|
||||||
]
|
]
|
||||||
|
|
|
@ -1,19 +1,15 @@
|
||||||
select count(*) from iiabmdb.without_exp_sample;
|
select e_id, n_disrupt_sample, total_n_disrupt_firm_prod_experiment, dct_lst_init_disrupt_firm_prod from iiabmdb.without_exp_experiment as experiment
|
||||||
|
inner join (
|
||||||
select distinct s_id from iiabmdb.without_exp_result where ts > 0;
|
select e_id, count(id) as n_disrupt_sample, sum(n_disrupt_firm_prod_sample) as total_n_disrupt_firm_prod_experiment from iiabmdb.without_exp_sample as sample
|
||||||
select s_id, max(ts) as max_ts from iiabmdb.without_exp_result where ts > 0 group by s_id order by max_ts;
|
inner join (
|
||||||
select e_id, count(id) as count, max(max_ts) as max_max_ts from iiabmdb.without_exp_sample as a
|
select * from
|
||||||
inner join (select s_id, max(ts) as max_ts from iiabmdb.without_exp_result where ts > 0 group by s_id) as b
|
(select s_id, COUNT(DISTINCT id_firm, id_product) as n_disrupt_firm_prod_sample from iiabmdb.without_exp_result group by s_id
|
||||||
on a.id = b.s_id
|
) as count_disrupt_firm_prod_sample
|
||||||
|
where n_disrupt_firm_prod_sample > 1
|
||||||
|
) as disrupt_sample
|
||||||
|
on sample.id = disrupt_sample.s_id
|
||||||
group by e_id
|
group by e_id
|
||||||
order by count desc;
|
) as disrupt_experiment
|
||||||
|
on experiment.id = disrupt_experiment.e_id
|
||||||
select e_id, count, max_max_ts, dct_lst_init_remove_firm_prod from iiabmdb.without_exp_experiment as a
|
order by n_disrupt_sample desc, total_n_disrupt_firm_prod_experiment desc
|
||||||
inner join
|
limit 0, 95;
|
||||||
(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
|
|
||||||
where count > 10
|
|
||||||
order by count desc;
|
|
|
@ -0,0 +1,44 @@
|
||||||
|
select max(ts_done) from iiabmdb.without_exp_sample;
|
||||||
|
select min(ts_done) from iiabmdb.without_exp_sample;
|
||||||
|
select count(*) from iiabmdb.without_exp_sample;
|
||||||
|
|
||||||
|
select distinct s_id from iiabmdb.without_exp_result where ts > 0;
|
||||||
|
select s_id, max(ts) as max_ts from iiabmdb.without_exp_result where ts > 0 group by s_id order by max_ts;
|
||||||
|
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
|
||||||
|
order by count desc;
|
||||||
|
|
||||||
|
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
|
||||||
|
where count > 10
|
||||||
|
order by count desc;
|
||||||
|
|
||||||
|
select s_id, max(ts) as max_ts from iiabmdb.without_exp_result where ts > 0 group by s_id;
|
||||||
|
select * from iiabmdb.without_exp_result order by s_id limit 0,50;
|
||||||
|
select s_id, COUNT(DISTINCT id_firm, id_product) as n_disrupt_firm_prod from iiabmdb.without_exp_result group by s_id;
|
||||||
|
select * from
|
||||||
|
(select s_id, COUNT(DISTINCT id_firm, id_product) as n_disrupt_firm_prod_sample from iiabmdb.without_exp_result group by s_id) as count_disrupt_firm_prod_sample
|
||||||
|
where n_disrupt_firm_prod_sample > 1;
|
||||||
|
|
||||||
|
select e_id, n_disrupt_sample, total_n_disrupt_firm_prod_experiment, dct_lst_init_disrupt_firm_prod from iiabmdb.without_exp_experiment as experiment
|
||||||
|
inner join (
|
||||||
|
select e_id, count(id) as n_disrupt_sample, sum(n_disrupt_firm_prod_sample) as total_n_disrupt_firm_prod_experiment from iiabmdb.without_exp_sample as sample
|
||||||
|
inner join (
|
||||||
|
select * from
|
||||||
|
(select s_id, COUNT(DISTINCT id_firm, id_product) as n_disrupt_firm_prod_sample from iiabmdb.without_exp_result group by s_id
|
||||||
|
) as count_disrupt_firm_prod_sample
|
||||||
|
where n_disrupt_firm_prod_sample > 1
|
||||||
|
) as disrupt_sample
|
||||||
|
on sample.id = disrupt_sample.s_id
|
||||||
|
group by e_id
|
||||||
|
) as disrupt_experiment
|
||||||
|
on experiment.id = disrupt_experiment.e_id
|
||||||
|
order by n_disrupt_sample desc, total_n_disrupt_firm_prod_experiment desc
|
||||||
|
limit 0, 95; # 20% of 475 experiment
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -54,18 +54,8 @@ class ControllerDB:
|
||||||
# fill dct_lst_init_disrupt_firm_prod
|
# fill dct_lst_init_disrupt_firm_prod
|
||||||
list_dct = []
|
list_dct = []
|
||||||
if self.is_with_exp:
|
if self.is_with_exp:
|
||||||
str_sql = "select e_id, count, max_max_ts, " \
|
with open('SQL_export_high_risk_setting.sql', 'r') as f:
|
||||||
"dct_lst_init_disrupt_firm_prod from " \
|
str_sql = f.read()
|
||||||
"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 = pd.read_sql(sql=str_sql, con=engine)
|
||||||
result['dct_lst_init_disrupt_firm_prod'] = \
|
result['dct_lst_init_disrupt_firm_prod'] = \
|
||||||
result['dct_lst_init_disrupt_firm_prod'].apply(
|
result['dct_lst_init_disrupt_firm_prod'].apply(
|
||||||
|
|
BIN
oa_with_exp.xlsx
BIN
oa_with_exp.xlsx
Binary file not shown.
160
test.ipynb
160
test.ipynb
|
@ -357,6 +357,166 @@
|
||||||
"\n",
|
"\n",
|
||||||
"lst[-5:]"
|
"lst[-5:]"
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 7,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"data": {
|
||||||
|
"text/html": [
|
||||||
|
"<div>\n",
|
||||||
|
"<style scoped>\n",
|
||||||
|
" .dataframe tbody tr th:only-of-type {\n",
|
||||||
|
" vertical-align: middle;\n",
|
||||||
|
" }\n",
|
||||||
|
"\n",
|
||||||
|
" .dataframe tbody tr th {\n",
|
||||||
|
" vertical-align: top;\n",
|
||||||
|
" }\n",
|
||||||
|
"\n",
|
||||||
|
" .dataframe thead th {\n",
|
||||||
|
" text-align: right;\n",
|
||||||
|
" }\n",
|
||||||
|
"</style>\n",
|
||||||
|
"<table border=\"1\" class=\"dataframe\">\n",
|
||||||
|
" <thead>\n",
|
||||||
|
" <tr style=\"text-align: right;\">\n",
|
||||||
|
" <th></th>\n",
|
||||||
|
" <th>e_id</th>\n",
|
||||||
|
" <th>n_disrupt_sample</th>\n",
|
||||||
|
" <th>total_n_disrupt_firm_prod_experiment</th>\n",
|
||||||
|
" <th>dct_lst_init_disrupt_firm_prod</th>\n",
|
||||||
|
" </tr>\n",
|
||||||
|
" </thead>\n",
|
||||||
|
" <tbody>\n",
|
||||||
|
" <tr>\n",
|
||||||
|
" <th>0</th>\n",
|
||||||
|
" <td>383</td>\n",
|
||||||
|
" <td>50</td>\n",
|
||||||
|
" <td>300.0</td>\n",
|
||||||
|
" <td>b'\\x80\\x05\\x95\\x17\\x00\\x00\\x00\\x00\\x00\\x00\\x00...</td>\n",
|
||||||
|
" </tr>\n",
|
||||||
|
" <tr>\n",
|
||||||
|
" <th>1</th>\n",
|
||||||
|
" <td>227</td>\n",
|
||||||
|
" <td>50</td>\n",
|
||||||
|
" <td>250.0</td>\n",
|
||||||
|
" <td>b'\\x80\\x05\\x95\\x16\\x00\\x00\\x00\\x00\\x00\\x00\\x00...</td>\n",
|
||||||
|
" </tr>\n",
|
||||||
|
" <tr>\n",
|
||||||
|
" <th>2</th>\n",
|
||||||
|
" <td>83</td>\n",
|
||||||
|
" <td>50</td>\n",
|
||||||
|
" <td>200.0</td>\n",
|
||||||
|
" <td>b'\\x80\\x05\\x95\\x16\\x00\\x00\\x00\\x00\\x00\\x00\\x00...</td>\n",
|
||||||
|
" </tr>\n",
|
||||||
|
" <tr>\n",
|
||||||
|
" <th>3</th>\n",
|
||||||
|
" <td>135</td>\n",
|
||||||
|
" <td>50</td>\n",
|
||||||
|
" <td>200.0</td>\n",
|
||||||
|
" <td>b'\\x80\\x05\\x95\\x16\\x00\\x00\\x00\\x00\\x00\\x00\\x00...</td>\n",
|
||||||
|
" </tr>\n",
|
||||||
|
" <tr>\n",
|
||||||
|
" <th>4</th>\n",
|
||||||
|
" <td>179</td>\n",
|
||||||
|
" <td>50</td>\n",
|
||||||
|
" <td>200.0</td>\n",
|
||||||
|
" <td>b'\\x80\\x05\\x95\\x16\\x00\\x00\\x00\\x00\\x00\\x00\\x00...</td>\n",
|
||||||
|
" </tr>\n",
|
||||||
|
" <tr>\n",
|
||||||
|
" <th>...</th>\n",
|
||||||
|
" <td>...</td>\n",
|
||||||
|
" <td>...</td>\n",
|
||||||
|
" <td>...</td>\n",
|
||||||
|
" <td>...</td>\n",
|
||||||
|
" </tr>\n",
|
||||||
|
" <tr>\n",
|
||||||
|
" <th>90</th>\n",
|
||||||
|
" <td>76</td>\n",
|
||||||
|
" <td>24</td>\n",
|
||||||
|
" <td>56.0</td>\n",
|
||||||
|
" <td>b'\\x80\\x05\\x95\\x14\\x00\\x00\\x00\\x00\\x00\\x00\\x00...</td>\n",
|
||||||
|
" </tr>\n",
|
||||||
|
" <tr>\n",
|
||||||
|
" <th>91</th>\n",
|
||||||
|
" <td>89</td>\n",
|
||||||
|
" <td>24</td>\n",
|
||||||
|
" <td>54.0</td>\n",
|
||||||
|
" <td>b'\\x80\\x05\\x95\\x16\\x00\\x00\\x00\\x00\\x00\\x00\\x00...</td>\n",
|
||||||
|
" </tr>\n",
|
||||||
|
" <tr>\n",
|
||||||
|
" <th>92</th>\n",
|
||||||
|
" <td>90</td>\n",
|
||||||
|
" <td>24</td>\n",
|
||||||
|
" <td>54.0</td>\n",
|
||||||
|
" <td>b'\\x80\\x05\\x95\\x16\\x00\\x00\\x00\\x00\\x00\\x00\\x00...</td>\n",
|
||||||
|
" </tr>\n",
|
||||||
|
" <tr>\n",
|
||||||
|
" <th>93</th>\n",
|
||||||
|
" <td>335</td>\n",
|
||||||
|
" <td>24</td>\n",
|
||||||
|
" <td>54.0</td>\n",
|
||||||
|
" <td>b'\\x80\\x05\\x95\\x17\\x00\\x00\\x00\\x00\\x00\\x00\\x00...</td>\n",
|
||||||
|
" </tr>\n",
|
||||||
|
" <tr>\n",
|
||||||
|
" <th>94</th>\n",
|
||||||
|
" <td>449</td>\n",
|
||||||
|
" <td>24</td>\n",
|
||||||
|
" <td>53.0</td>\n",
|
||||||
|
" <td>b'\\x80\\x05\\x95\\x15\\x00\\x00\\x00\\x00\\x00\\x00\\x00...</td>\n",
|
||||||
|
" </tr>\n",
|
||||||
|
" </tbody>\n",
|
||||||
|
"</table>\n",
|
||||||
|
"<p>95 rows × 4 columns</p>\n",
|
||||||
|
"</div>"
|
||||||
|
],
|
||||||
|
"text/plain": [
|
||||||
|
" e_id n_disrupt_sample total_n_disrupt_firm_prod_experiment \\\n",
|
||||||
|
"0 383 50 300.0 \n",
|
||||||
|
"1 227 50 250.0 \n",
|
||||||
|
"2 83 50 200.0 \n",
|
||||||
|
"3 135 50 200.0 \n",
|
||||||
|
"4 179 50 200.0 \n",
|
||||||
|
".. ... ... ... \n",
|
||||||
|
"90 76 24 56.0 \n",
|
||||||
|
"91 89 24 54.0 \n",
|
||||||
|
"92 90 24 54.0 \n",
|
||||||
|
"93 335 24 54.0 \n",
|
||||||
|
"94 449 24 53.0 \n",
|
||||||
|
"\n",
|
||||||
|
" dct_lst_init_disrupt_firm_prod \n",
|
||||||
|
"0 b'\\x80\\x05\\x95\\x17\\x00\\x00\\x00\\x00\\x00\\x00\\x00... \n",
|
||||||
|
"1 b'\\x80\\x05\\x95\\x16\\x00\\x00\\x00\\x00\\x00\\x00\\x00... \n",
|
||||||
|
"2 b'\\x80\\x05\\x95\\x16\\x00\\x00\\x00\\x00\\x00\\x00\\x00... \n",
|
||||||
|
"3 b'\\x80\\x05\\x95\\x16\\x00\\x00\\x00\\x00\\x00\\x00\\x00... \n",
|
||||||
|
"4 b'\\x80\\x05\\x95\\x16\\x00\\x00\\x00\\x00\\x00\\x00\\x00... \n",
|
||||||
|
".. ... \n",
|
||||||
|
"90 b'\\x80\\x05\\x95\\x14\\x00\\x00\\x00\\x00\\x00\\x00\\x00... \n",
|
||||||
|
"91 b'\\x80\\x05\\x95\\x16\\x00\\x00\\x00\\x00\\x00\\x00\\x00... \n",
|
||||||
|
"92 b'\\x80\\x05\\x95\\x16\\x00\\x00\\x00\\x00\\x00\\x00\\x00... \n",
|
||||||
|
"93 b'\\x80\\x05\\x95\\x17\\x00\\x00\\x00\\x00\\x00\\x00\\x00... \n",
|
||||||
|
"94 b'\\x80\\x05\\x95\\x15\\x00\\x00\\x00\\x00\\x00\\x00\\x00... \n",
|
||||||
|
"\n",
|
||||||
|
"[95 rows x 4 columns]"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"execution_count": 7,
|
||||||
|
"metadata": {},
|
||||||
|
"output_type": "execute_result"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"with open('SQL_export_high_risk_setting.sql', 'r') as f:\n",
|
||||||
|
" contents = f.read()\n",
|
||||||
|
"\n",
|
||||||
|
"import pandas as pd\n",
|
||||||
|
"from orm import engine\n",
|
||||||
|
"result = pd.read_sql(sql=contents, con=engine)\n",
|
||||||
|
"result"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"metadata": {
|
"metadata": {
|
||||||
|
|
Loading…
Reference in New Issue