before proactive
This commit is contained in:
parent
228a066cf6
commit
af0d1dd2c3
|
@ -12,8 +12,8 @@
|
||||||
"console": "integratedTerminal",
|
"console": "integratedTerminal",
|
||||||
"justMyCode": true,
|
"justMyCode": true,
|
||||||
"args": [
|
"args": [
|
||||||
"--exp", "with_exp",
|
"--exp", "test",
|
||||||
"--job", "24",
|
"--reset_db", "True"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
Binary file not shown.
Binary file not shown.
After Width: | Height: | Size: 531 KiB |
Binary file not shown.
After Width: | Height: | Size: 2.7 MiB |
|
@ -1,7 +1,6 @@
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
import matplotlib.pyplot as plt
|
import matplotlib.pyplot as plt
|
||||||
import networkx as nx
|
import networkx as nx
|
||||||
import math
|
|
||||||
|
|
||||||
plt.rcParams['font.sans-serif'] = 'SimHei'
|
plt.rcParams['font.sans-serif'] = 'SimHei'
|
||||||
|
|
||||||
|
@ -65,9 +64,11 @@ for _, row in count_dcp.iterrows():
|
||||||
pos = nx.nx_agraph.graphviz_layout(G_firm, prog="dot", args="")
|
pos = nx.nx_agraph.graphviz_layout(G_firm, prog="dot", args="")
|
||||||
node_label = nx.get_node_attributes(G_firm, 'Name')
|
node_label = nx.get_node_attributes(G_firm, 'Name')
|
||||||
# node_degree = dict(G_firm.out_degree())
|
# node_degree = dict(G_firm.out_degree())
|
||||||
|
# desensitize
|
||||||
node_label = {
|
node_label = {
|
||||||
# key: f"{node_label[key]} {node_degree[key]}"
|
# key: f"{node_label[key]} {node_degree[key]}"
|
||||||
key: f"{node_label[key]}"
|
# key: f"{node_label[key]}"
|
||||||
|
key: key
|
||||||
for key in node_label.keys()
|
for key in node_label.keys()
|
||||||
}
|
}
|
||||||
node_size = list(nx.get_node_attributes(G_firm, 'Revenue_Log').values())
|
node_size = list(nx.get_node_attributes(G_firm, 'Revenue_Log').values())
|
||||||
|
@ -87,7 +88,7 @@ nx.draw(G_firm,
|
||||||
node_size=node_size,
|
node_size=node_size,
|
||||||
labels=node_label,
|
labels=node_label,
|
||||||
font_size=6,
|
font_size=6,
|
||||||
width = 3,
|
width=3,
|
||||||
edge_color=colors,
|
edge_color=colors,
|
||||||
edge_cmap=cmap,
|
edge_cmap=cmap,
|
||||||
edge_vmin=vmin,
|
edge_vmin=vmin,
|
||||||
|
@ -95,7 +96,7 @@ nx.draw(G_firm,
|
||||||
nx.draw_networkx_edge_labels(G_firm, pos, edge_label, font_size=6)
|
nx.draw_networkx_edge_labels(G_firm, pos, edge_label, font_size=6)
|
||||||
sm = plt.cm.ScalarMappable(cmap=cmap, norm=plt.Normalize(vmin=vmin, vmax=vmax))
|
sm = plt.cm.ScalarMappable(cmap=cmap, norm=plt.Normalize(vmin=vmin, vmax=vmax))
|
||||||
sm._A = []
|
sm._A = []
|
||||||
position=fig.add_axes([0.9, 0.05, 0.01, 0.3])
|
position = fig.add_axes([0.9, 0.05, 0.01, 0.3])
|
||||||
plt.colorbar(sm, fraction=0.01, cax=position)
|
plt.colorbar(sm, fraction=0.01, cax=position)
|
||||||
# plt.savefig("analysis\\count_dcp_network")
|
plt.savefig("analysis\\count_dcp_network20230526_de")
|
||||||
plt.close()
|
plt.close()
|
||||||
|
|
BIN
anova.xlsx
BIN
anova.xlsx
Binary file not shown.
|
@ -1 +1 @@
|
||||||
db_name_prefix: with_exp
|
db_name_prefix: test
|
||||||
|
|
|
@ -75,7 +75,7 @@ class ControllerDB:
|
||||||
# list_dct = [{'133': ['1.4.4.1']}]
|
# list_dct = [{'133': ['1.4.4.1']}]
|
||||||
# list_dct = [{'2': ['1.1.3']}]
|
# list_dct = [{'2': ['1.1.3']}]
|
||||||
# list_dct = [{'135': ['1.3.2.1']}]
|
# list_dct = [{'135': ['1.3.2.1']}]
|
||||||
# list_dct = [{'79': ['2.1.3.4']}]
|
list_dct = [{'79': ['2.1.3.4']}]
|
||||||
|
|
||||||
# fill g_bom
|
# fill g_bom
|
||||||
BomNodes = pd.read_csv('BomNodes.csv', index_col=0)
|
BomNodes = pd.read_csv('BomNodes.csv', index_col=0)
|
||||||
|
|
|
@ -10,21 +10,20 @@ Firm['Code'] = Firm['Code'].astype('string')
|
||||||
Firm.fillna(0, inplace=True)
|
Firm.fillna(0, inplace=True)
|
||||||
BomNodes = pd.read_csv('BomNodes.csv', index_col=0)
|
BomNodes = pd.read_csv('BomNodes.csv', index_col=0)
|
||||||
|
|
||||||
result = pd.read_sql(sql='select * from iiabmdb.not_test_result where ts > 0;',
|
result = pd.read_sql(sql='select * from iiabmdb_dissertation.not_test_result where ts > 0;',
|
||||||
con=engine)
|
con=engine)
|
||||||
lst_s_id = list(set(result['s_id'].to_list()))
|
lst_s_id = list(set(result['s_id'].to_list()))
|
||||||
for s_id in lst_s_id:
|
for s_id in lst_s_id:
|
||||||
query = pd.read_sql(
|
query = pd.read_sql(
|
||||||
sql=
|
sql=f'select * from iiabmdb_dissertation.not_test_result where ts = 0 and s_id = {s_id};',
|
||||||
f'select * from iiabmdb.not_test_result where ts = 0 and s_id = {s_id};',
|
|
||||||
con=engine)
|
con=engine)
|
||||||
result = pd.concat([result, query])
|
result = pd.concat([result, query])
|
||||||
result.set_index('id', inplace=True)
|
result.set_index('id', inplace=True)
|
||||||
result.sort_index(inplace=True)
|
result.sort_index(inplace=True)
|
||||||
result['id_firm'] = result['id_firm'].astype('string')
|
result['id_firm'] = result['id_firm'].astype('string')
|
||||||
result.to_csv('analysis\\count.csv',
|
# result.to_csv('analysis\\count.csv',
|
||||||
index=False,
|
# index=False,
|
||||||
encoding='utf-8-sig')
|
# encoding='utf-8-sig')
|
||||||
print(result)
|
print(result)
|
||||||
|
|
||||||
# G bom
|
# G bom
|
||||||
|
@ -32,7 +31,7 @@ plt.rcParams['font.sans-serif'] = 'SimHei'
|
||||||
|
|
||||||
exp_id = 1
|
exp_id = 1
|
||||||
G_bom_str = pd.read_sql(
|
G_bom_str = pd.read_sql(
|
||||||
sql=f'select g_bom from iiabmdb.not_test_experiment where id = {exp_id};',
|
sql=f'select g_bom from iiabmdb_dissertation.not_test_experiment where id = {exp_id};',
|
||||||
con=engine)['g_bom'].tolist()[0]
|
con=engine)['g_bom'].tolist()[0]
|
||||||
G_bom = nx.adjacency_graph(json.loads(G_bom_str))
|
G_bom = nx.adjacency_graph(json.loads(G_bom_str))
|
||||||
pos = nx.nx_agraph.graphviz_layout(G_bom, prog="twopi", args="")
|
pos = nx.nx_agraph.graphviz_layout(G_bom, prog="twopi", args="")
|
||||||
|
@ -41,7 +40,8 @@ plt.figure(figsize=(12, 12), dpi=300)
|
||||||
nx.draw_networkx_nodes(G_bom, pos)
|
nx.draw_networkx_nodes(G_bom, pos)
|
||||||
nx.draw_networkx_edges(G_bom, pos)
|
nx.draw_networkx_edges(G_bom, pos)
|
||||||
nx.draw_networkx_labels(G_bom, pos, labels=node_labels, font_size=6)
|
nx.draw_networkx_labels(G_bom, pos, labels=node_labels, font_size=6)
|
||||||
plt.savefig(f"analysis\\g_bom_exp_id_{exp_id}.png")
|
# plt.show()
|
||||||
|
# plt.savefig(f"analysis\\g_bom_exp_id_{exp_id}.png")
|
||||||
plt.close()
|
plt.close()
|
||||||
|
|
||||||
# G firm
|
# G firm
|
||||||
|
@ -49,14 +49,14 @@ plt.rcParams['font.sans-serif'] = 'SimHei'
|
||||||
|
|
||||||
sample_id = 1
|
sample_id = 1
|
||||||
G_firm_str = pd.read_sql(
|
G_firm_str = pd.read_sql(
|
||||||
sql=f'select g_firm from iiabmdb.not_test_sample where id = {exp_id};',
|
sql=f'select g_firm from iiabmdb_dissertation.not_test_sample where id = {exp_id};',
|
||||||
con=engine)['g_firm'].tolist()[0]
|
con=engine)['g_firm'].tolist()[0]
|
||||||
G_firm = nx.adjacency_graph(json.loads(G_firm_str))
|
G_firm = nx.adjacency_graph(json.loads(G_firm_str))
|
||||||
pos = nx.nx_agraph.graphviz_layout(G_firm, prog="twopi", args="")
|
pos = nx.nx_agraph.graphviz_layout(G_firm, prog="twopi", args="")
|
||||||
node_label = nx.get_node_attributes(G_firm, 'Name')
|
node_label = nx.get_node_attributes(G_firm, 'Name')
|
||||||
node_degree = dict(G_firm.out_degree())
|
# desensitize
|
||||||
node_label = {
|
node_label = {
|
||||||
key: f"{node_label[key]} {node_degree[key]}"
|
key: key
|
||||||
for key in node_label.keys()
|
for key in node_label.keys()
|
||||||
}
|
}
|
||||||
node_size = list(nx.get_node_attributes(G_firm, 'Revenue_Log').values())
|
node_size = list(nx.get_node_attributes(G_firm, 'Revenue_Log').values())
|
||||||
|
@ -66,7 +66,8 @@ edge_label = {(n1, n2): label for (n1, n2, _), label in edge_label.items()}
|
||||||
plt.figure(figsize=(12, 12), dpi=300)
|
plt.figure(figsize=(12, 12), dpi=300)
|
||||||
nx.draw(G_firm, pos, node_size=node_size, labels=node_label, font_size=6)
|
nx.draw(G_firm, pos, node_size=node_size, labels=node_label, font_size=6)
|
||||||
nx.draw_networkx_edge_labels(G_firm, pos, edge_label, font_size=4)
|
nx.draw_networkx_edge_labels(G_firm, pos, edge_label, font_size=4)
|
||||||
plt.savefig(f"analysis\\g_firm_sample_id_{exp_id}.png")
|
# plt.show()
|
||||||
|
plt.savefig(f"analysis\\g_firm_sample_id_{exp_id}_de.png")
|
||||||
plt.close()
|
plt.close()
|
||||||
|
|
||||||
# count firm product
|
# count firm product
|
||||||
|
@ -90,9 +91,9 @@ count_firm_prod.rename(columns={'Name': 'name_product'}, inplace=True)
|
||||||
count_firm_prod = count_firm_prod[[
|
count_firm_prod = count_firm_prod[[
|
||||||
'id_firm', 'name_firm', 'id_product', 'name_product', 'count'
|
'id_firm', 'name_firm', 'id_product', 'name_product', 'count'
|
||||||
]]
|
]]
|
||||||
count_firm_prod.to_csv('analysis\\count_firm_prod.csv',
|
# count_firm_prod.to_csv('analysis\\count_firm_prod.csv',
|
||||||
index=False,
|
# index=False,
|
||||||
encoding='utf-8-sig')
|
# encoding='utf-8-sig')
|
||||||
print(count_firm_prod)
|
print(count_firm_prod)
|
||||||
|
|
||||||
# count firm
|
# count firm
|
||||||
|
@ -106,9 +107,9 @@ count_firm = pd.merge(count_firm,
|
||||||
count_firm.drop('Code', axis=1, inplace=True)
|
count_firm.drop('Code', axis=1, inplace=True)
|
||||||
count_firm.sort_values('count', inplace=True, ascending=False)
|
count_firm.sort_values('count', inplace=True, ascending=False)
|
||||||
count_firm = count_firm[['id_firm', 'Name', 'count']]
|
count_firm = count_firm[['id_firm', 'Name', 'count']]
|
||||||
count_firm.to_csv('analysis\\count_firm.csv',
|
# count_firm.to_csv('analysis\\count_firm.csv',
|
||||||
index=False,
|
# index=False,
|
||||||
encoding='utf-8-sig')
|
# encoding='utf-8-sig')
|
||||||
print(count_firm)
|
print(count_firm)
|
||||||
|
|
||||||
# count product
|
# count product
|
||||||
|
@ -122,9 +123,9 @@ count_prod = pd.merge(count_prod,
|
||||||
count_prod.drop('Code', axis=1, inplace=True)
|
count_prod.drop('Code', axis=1, inplace=True)
|
||||||
count_prod.sort_values('count', inplace=True, ascending=False)
|
count_prod.sort_values('count', inplace=True, ascending=False)
|
||||||
count_prod = count_prod[['id_product', 'Name', 'count']]
|
count_prod = count_prod[['id_product', 'Name', 'count']]
|
||||||
count_prod.to_csv('analysis\\count_prod.csv',
|
# count_prod.to_csv('analysis\\count_prod.csv',
|
||||||
index=False,
|
# index=False,
|
||||||
encoding='utf-8-sig')
|
# encoding='utf-8-sig')
|
||||||
print(count_prod)
|
print(count_prod)
|
||||||
|
|
||||||
# DCP disruption causing probability
|
# DCP disruption causing probability
|
||||||
|
@ -187,5 +188,5 @@ count_dcp = count_dcp[[
|
||||||
'down_id_firm', 'down_name_firm', 'down_id_product', 'down_name_product',
|
'down_id_firm', 'down_name_firm', 'down_id_product', 'down_name_product',
|
||||||
'count'
|
'count'
|
||||||
]]
|
]]
|
||||||
count_dcp.to_csv('analysis\\count_dcp.csv', index=False, encoding='utf-8-sig')
|
# count_dcp.to_csv('analysis\\count_dcp.csv', index=False, encoding='utf-8-sig')
|
||||||
print(count_dcp)
|
print(count_dcp)
|
||||||
|
|
Loading…
Reference in New Issue