Compare commits
No commits in common. "5b2cf3a3e59cc96839dc634867fe9d00aa61ad6b" and "42fba119d191840033d3646df35044f7b1883492" have entirely different histories.
5b2cf3a3e5
...
42fba119d1
2
main.py
|
@ -54,7 +54,7 @@ def do_computation(c_db):
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
# 输入参数
|
# 输入参数
|
||||||
parser = argparse.ArgumentParser(description='setting')
|
parser = argparse.ArgumentParser(description='setting')
|
||||||
parser.add_argument('--exp', type=str, default='without_exp')
|
parser.add_argument('--exp', type=str, default='with_exp')
|
||||||
parser.add_argument('--job', type=int, default='4')
|
parser.add_argument('--job', type=int, default='4')
|
||||||
parser.add_argument('--reset_sample', type=int, default='0')
|
parser.add_argument('--reset_sample', type=int, default='0')
|
||||||
parser.add_argument('--reset_db', type=bool, default=False)
|
parser.add_argument('--reset_db', type=bool, default=False)
|
||||||
|
|
Before Width: | Height: | Size: 1.5 MiB |
Before Width: | Height: | Size: 304 KiB |
|
@ -1,164 +1,46 @@
|
||||||
id_firm,count
|
id_firm,count
|
||||||
70634828,5066
|
126,6
|
||||||
3147511625,5066
|
85,5
|
||||||
653528340,5052
|
100,3
|
||||||
3103797386,5046
|
80,3
|
||||||
888395016,5046
|
79,3
|
||||||
301209792,5046
|
99,3
|
||||||
2327031723,5042
|
57,2
|
||||||
2317245827,5036
|
74,2
|
||||||
631449822,5032
|
13,2
|
||||||
2348941764,5026
|
97,2
|
||||||
194210021,5022
|
94,2
|
||||||
191912252,5012
|
93,2
|
||||||
3048263744,5002
|
108,2
|
||||||
3215814536,4996
|
45,2
|
||||||
2354145351,4992
|
68,2
|
||||||
2312490120,1910
|
53,2
|
||||||
503176785,1850
|
106,2
|
||||||
25685135,1566
|
73,2
|
||||||
2944892892,1556
|
75,2
|
||||||
2624175,1546
|
58,1
|
||||||
3269039233,1546
|
124,1
|
||||||
3445928818,1476
|
77,1
|
||||||
2321109759,1466
|
117,1
|
||||||
3299144127,1456
|
81,1
|
||||||
930767828,726
|
84,1
|
||||||
3407754893,716
|
98,1
|
||||||
571058167,350
|
115,1
|
||||||
343012684,350
|
49,1
|
||||||
750610681,350
|
50,1
|
||||||
2317841563,350
|
159,1
|
||||||
888356483,350
|
131,1
|
||||||
2320475044,350
|
135,1
|
||||||
43407343,350
|
14,1
|
||||||
152008168,350
|
142,1
|
||||||
413274977,350
|
148,1
|
||||||
3111033905,350
|
149,1
|
||||||
3069206426,350
|
21,1
|
||||||
25945288,350
|
119,1
|
||||||
607512171,340
|
22,1
|
||||||
448033045,340
|
23,1
|
||||||
1452048,20
|
25,1
|
||||||
2311838590,20
|
26,1
|
||||||
2424229017,20
|
31,1
|
||||||
3373311444,20
|
41,1
|
||||||
11807506,20
|
36,1
|
||||||
400488703,10
|
|
||||||
420984285,10
|
|
||||||
400692942,10
|
|
||||||
4208851809,10
|
|
||||||
3445244192,10
|
|
||||||
888478182,10
|
|
||||||
354897041,10
|
|
||||||
9,10
|
|
||||||
4518234098,10
|
|
||||||
3433628561,10
|
|
||||||
3398677646,10
|
|
||||||
3395900897,10
|
|
||||||
3384021594,10
|
|
||||||
3372913783,10
|
|
||||||
3344297292,10
|
|
||||||
3312358902,10
|
|
||||||
9746245,10
|
|
||||||
887840774,10
|
|
||||||
5007015990,10
|
|
||||||
453289520,10
|
|
||||||
593312758,10
|
|
||||||
7299120,10
|
|
||||||
7,10
|
|
||||||
762985858,10
|
|
||||||
695995052,10
|
|
||||||
688155470,10
|
|
||||||
654825436,10
|
|
||||||
771821595,10
|
|
||||||
80158773,10
|
|
||||||
644292599,10
|
|
||||||
829768,10
|
|
||||||
620220747,10
|
|
||||||
615763365,10
|
|
||||||
594378026,10
|
|
||||||
857978527,10
|
|
||||||
474279224,10
|
|
||||||
591452402,10
|
|
||||||
5849940,10
|
|
||||||
3271705843,10
|
|
||||||
581407487,10
|
|
||||||
561545339,10
|
|
||||||
560866402,10
|
|
||||||
549184982,10
|
|
||||||
863079,10
|
|
||||||
5278074,10
|
|
||||||
868012326,10
|
|
||||||
71271700,10
|
|
||||||
495782506,10
|
|
||||||
483081978,10
|
|
||||||
1033972427,10
|
|
||||||
3127420424,10
|
|
||||||
3269940677,10
|
|
||||||
218633337,10
|
|
||||||
2343704209,10
|
|
||||||
2341555098,10
|
|
||||||
2339684065,10
|
|
||||||
2339188563,10
|
|
||||||
2337952436,10
|
|
||||||
2333843479,10
|
|
||||||
2329375731,10
|
|
||||||
2327979389,10
|
|
||||||
2326478786,10
|
|
||||||
2324844174,10
|
|
||||||
2324787028,10
|
|
||||||
2320102626,10
|
|
||||||
2316990095,10
|
|
||||||
2310825263,10
|
|
||||||
213386023,10
|
|
||||||
2352036411,10
|
|
||||||
203314437,10
|
|
||||||
2010673,10
|
|
||||||
1679596339,10
|
|
||||||
1606833003,10
|
|
||||||
159511306,10
|
|
||||||
15613202,10
|
|
||||||
1549474227,10
|
|
||||||
151606446,10
|
|
||||||
145511905,10
|
|
||||||
1375606900,10
|
|
||||||
1307012237,10
|
|
||||||
1217957486,10
|
|
||||||
118882692,10
|
|
||||||
1128343125,10
|
|
||||||
2349656760,10
|
|
||||||
24284343,10
|
|
||||||
3267688490,10
|
|
||||||
24673506,10
|
|
||||||
3226664625,10
|
|
||||||
3221190269,10
|
|
||||||
3211956484,10
|
|
||||||
3203777710,10
|
|
||||||
3195502499,10
|
|
||||||
3188903709,10
|
|
||||||
3177507356,10
|
|
||||||
3133307899,10
|
|
||||||
3122923980,10
|
|
||||||
3120341363,10
|
|
||||||
3113895788,10
|
|
||||||
3072715478,10
|
|
||||||
3070859372,10
|
|
||||||
3047163873,10
|
|
||||||
3045721313,10
|
|
||||||
3026382513,10
|
|
||||||
3025036704,10
|
|
||||||
29954548,10
|
|
||||||
2820140348,10
|
|
||||||
278221281,10
|
|
||||||
27731896,10
|
|
||||||
2728939,10
|
|
||||||
271860868,10
|
|
||||||
27075840,10
|
|
||||||
26516263,10
|
|
||||||
26162741,10
|
|
||||||
2545430247,10
|
|
||||||
251189644,10
|
|
||||||
25036634,10
|
|
||||||
996174506,10
|
|
||||||
11164476478,6
|
|
||||||
|
|
|
|
@ -1,359 +1,58 @@
|
||||||
id_firm,id_product,count
|
id_firm,id_product,count
|
||||||
25685135,99,1566
|
126,2.1.3,4
|
||||||
2944892892,99,1556
|
100,1.3.1,3
|
||||||
3269039233,99,1546
|
85,1.3.1,3
|
||||||
2624175,99,1546
|
106,2.1.3,2
|
||||||
3445928818,95,1476
|
68,1.3.1.3,2
|
||||||
2321109759,95,1466
|
73,2.1.3,2
|
||||||
3299144127,95,1456
|
74,2.1.3,2
|
||||||
930767828,90,726
|
75,1.3.3,2
|
||||||
3407754893,90,716
|
85,2.1.1,2
|
||||||
194210021,50,646
|
80,1.3.4,2
|
||||||
3147511625,50,646
|
93,1.3.1,2
|
||||||
2327031723,50,646
|
94,1.1,2
|
||||||
191912252,50,646
|
108,2.1.3,2
|
||||||
631449822,50,646
|
99,1.3.1,2
|
||||||
653528340,50,636
|
53,1.4.5.6,1
|
||||||
2348941764,50,636
|
57,1.3.3.3,1
|
||||||
2317245827,50,636
|
57,2.3.1,1
|
||||||
3215814536,50,636
|
58,1.3.4.3,1
|
||||||
888395016,50,636
|
98,2,1
|
||||||
70634828,50,636
|
97,2.1.3,1
|
||||||
301209792,50,636
|
97,1.3.3,1
|
||||||
2354145351,50,636
|
77,1.3.4,1
|
||||||
3048263744,50,636
|
79,2.1.3.2,1
|
||||||
3103797386,50,636
|
79,2.1.3.7,1
|
||||||
2317245827,54,596
|
79,2.1.4.1,1
|
||||||
301209792,54,596
|
50,1.3.1.5,1
|
||||||
2317245827,51,596
|
80,2.1.1,1
|
||||||
3048263744,54,596
|
81,1.3.4,1
|
||||||
3103797386,51,596
|
84,2.3,1
|
||||||
194210021,54,596
|
53,1.4.3.4,1
|
||||||
194210021,53,596
|
45,2.1.4.1.1,1
|
||||||
2348941764,51,596
|
49,1.3.1.4,1
|
||||||
191912252,54,596
|
45,1.3.4.2,1
|
||||||
191912252,53,596
|
115,1.1.3,1
|
||||||
3215814536,53,596
|
117,2.1.1.4,1
|
||||||
3215814536,54,596
|
119,1.3.1.1,1
|
||||||
2348941764,54,596
|
124,2.3,1
|
||||||
2354145351,53,596
|
126,1.1,1
|
||||||
888395016,53,596
|
126,2.1.1.5,1
|
||||||
70634828,53,596
|
13,2.1.3.4,1
|
||||||
70634828,54,596
|
13,2.1.3.7,1
|
||||||
2327031723,54,596
|
131,2.1.1.5,1
|
||||||
3147511625,54,596
|
135,2.2,1
|
||||||
2327031723,53,596
|
14,1.3.3.4,1
|
||||||
653528340,54,596
|
142,1.4.3,1
|
||||||
653528340,53,596
|
148,2.1.3,1
|
||||||
631449822,54,596
|
149,2.1.2.2,1
|
||||||
2327031723,51,586
|
159,2.1.2,1
|
||||||
2354145351,54,586
|
21,1.3.1.3,1
|
||||||
301209792,51,586
|
22,2.1.3.7,1
|
||||||
2317245827,53,586
|
23,2.3.1,1
|
||||||
301209792,53,586
|
25,1.3.1.7,1
|
||||||
653528340,51,586
|
26,2.1.3.4,1
|
||||||
3215814536,51,586
|
31,1.3.3.3,1
|
||||||
3048263744,53,586
|
36,1.1.1,1
|
||||||
888395016,51,586
|
41,1.4.5,1
|
||||||
3103797386,54,586
|
99,1.3.3,1
|
||||||
3147511625,51,586
|
|
||||||
3103797386,53,586
|
|
||||||
3048263744,51,586
|
|
||||||
888395016,54,586
|
|
||||||
194210021,51,586
|
|
||||||
2354145351,51,576
|
|
||||||
191912252,51,576
|
|
||||||
631449822,51,576
|
|
||||||
2348941764,53,576
|
|
||||||
3147511625,53,576
|
|
||||||
631449822,53,576
|
|
||||||
70634828,51,576
|
|
||||||
653528340,52,556
|
|
||||||
70634828,52,556
|
|
||||||
3147511625,52,556
|
|
||||||
888395016,52,556
|
|
||||||
631449822,52,556
|
|
||||||
3103797386,52,546
|
|
||||||
301209792,52,546
|
|
||||||
2327031723,52,546
|
|
||||||
3147511625,55,536
|
|
||||||
2354145351,52,536
|
|
||||||
888395016,55,536
|
|
||||||
2348941764,52,536
|
|
||||||
631449822,55,536
|
|
||||||
653528340,55,536
|
|
||||||
2317245827,52,536
|
|
||||||
3048263744,52,536
|
|
||||||
70634828,55,536
|
|
||||||
191912252,52,536
|
|
||||||
194210021,52,536
|
|
||||||
3103797386,55,526
|
|
||||||
301209792,55,526
|
|
||||||
2327031723,55,526
|
|
||||||
3215814536,52,526
|
|
||||||
2354145351,55,516
|
|
||||||
2348941764,55,516
|
|
||||||
194210021,55,516
|
|
||||||
3048263744,55,516
|
|
||||||
2317245827,55,516
|
|
||||||
191912252,55,516
|
|
||||||
3215814536,55,506
|
|
||||||
2312490120,39,380
|
|
||||||
503176785,43,366
|
|
||||||
2312490120,43,366
|
|
||||||
3069206426,93,350
|
|
||||||
3111033905,93,350
|
|
||||||
571058167,94,350
|
|
||||||
25945288,93,350
|
|
||||||
43407343,93,350
|
|
||||||
343012684,92,350
|
|
||||||
413274977,91,350
|
|
||||||
888356483,91,350
|
|
||||||
503176785,40,350
|
|
||||||
2320475044,94,350
|
|
||||||
152008168,94,350
|
|
||||||
2317841563,91,350
|
|
||||||
750610681,92,350
|
|
||||||
448033045,94,340
|
|
||||||
607512171,91,340
|
|
||||||
2312490120,40,336
|
|
||||||
2312490120,38,336
|
|
||||||
503176785,38,326
|
|
||||||
503176785,39,316
|
|
||||||
2348941764,49,260
|
|
||||||
2348941764,48,260
|
|
||||||
3103797386,45,260
|
|
||||||
2317245827,44,260
|
|
||||||
2317245827,45,260
|
|
||||||
2317245827,46,260
|
|
||||||
301209792,49,260
|
|
||||||
301209792,48,260
|
|
||||||
3103797386,44,260
|
|
||||||
3103797386,48,260
|
|
||||||
3103797386,46,260
|
|
||||||
888395016,46,260
|
|
||||||
3215814536,49,260
|
|
||||||
3215814536,48,260
|
|
||||||
3215814536,47,260
|
|
||||||
3215814536,46,260
|
|
||||||
888395016,49,260
|
|
||||||
888395016,48,260
|
|
||||||
888395016,47,260
|
|
||||||
3147511625,49,260
|
|
||||||
3103797386,47,260
|
|
||||||
3147511625,48,260
|
|
||||||
3147511625,47,260
|
|
||||||
3147511625,46,260
|
|
||||||
3147511625,45,260
|
|
||||||
3147511625,44,260
|
|
||||||
3103797386,49,260
|
|
||||||
301209792,46,260
|
|
||||||
301209792,47,260
|
|
||||||
70634828,44,260
|
|
||||||
301209792,45,260
|
|
||||||
2348941764,44,260
|
|
||||||
301209792,44,260
|
|
||||||
2317245827,49,260
|
|
||||||
70634828,49,260
|
|
||||||
70634828,48,260
|
|
||||||
70634828,46,260
|
|
||||||
70634828,47,260
|
|
||||||
70634828,45,260
|
|
||||||
2317245827,47,260
|
|
||||||
2348941764,45,260
|
|
||||||
2348941764,46,260
|
|
||||||
2348941764,47,260
|
|
||||||
2317245827,48,260
|
|
||||||
631449822,45,256
|
|
||||||
191912252,49,256
|
|
||||||
191912252,48,256
|
|
||||||
191912252,47,256
|
|
||||||
191912252,46,256
|
|
||||||
631449822,48,256
|
|
||||||
191912252,45,256
|
|
||||||
631449822,47,256
|
|
||||||
631449822,46,256
|
|
||||||
2327031723,49,256
|
|
||||||
631449822,44,256
|
|
||||||
2327031723,48,256
|
|
||||||
2354145351,44,256
|
|
||||||
2327031723,47,256
|
|
||||||
191912252,44,256
|
|
||||||
2354145351,49,256
|
|
||||||
2354145351,48,256
|
|
||||||
2354145351,47,256
|
|
||||||
2354145351,46,256
|
|
||||||
2354145351,45,256
|
|
||||||
194210021,44,256
|
|
||||||
3048263744,45,256
|
|
||||||
2327031723,46,256
|
|
||||||
3048263744,49,256
|
|
||||||
653528340,44,256
|
|
||||||
653528340,45,256
|
|
||||||
653528340,46,256
|
|
||||||
2312490120,41,256
|
|
||||||
653528340,47,256
|
|
||||||
653528340,48,256
|
|
||||||
3048263744,44,256
|
|
||||||
3048263744,46,256
|
|
||||||
3048263744,47,256
|
|
||||||
3048263744,48,256
|
|
||||||
653528340,49,256
|
|
||||||
503176785,41,256
|
|
||||||
194210021,49,256
|
|
||||||
194210021,48,256
|
|
||||||
2327031723,45,256
|
|
||||||
194210021,47,256
|
|
||||||
2327031723,44,256
|
|
||||||
194210021,46,256
|
|
||||||
194210021,45,256
|
|
||||||
631449822,49,256
|
|
||||||
888395016,44,250
|
|
||||||
888395016,45,250
|
|
||||||
3215814536,45,250
|
|
||||||
3215814536,44,250
|
|
||||||
503176785,42,236
|
|
||||||
2312490120,42,236
|
|
||||||
549184982,69,10
|
|
||||||
474279224,71,10
|
|
||||||
4518234098,12,10
|
|
||||||
453289520,37,10
|
|
||||||
581407487,72,10
|
|
||||||
483081978,36,10
|
|
||||||
5007015990,74,10
|
|
||||||
495782506,19,10
|
|
||||||
5278074,36,10
|
|
||||||
561545339,33,10
|
|
||||||
560866402,9,10
|
|
||||||
1033972427,61,10
|
|
||||||
5849940,26,10
|
|
||||||
7299120,32,10
|
|
||||||
9746245,97,10
|
|
||||||
9,37,10
|
|
||||||
888478182,9,10
|
|
||||||
888395016,7,10
|
|
||||||
887840774,8,10
|
|
||||||
868012326,29,10
|
|
||||||
863079,11,10
|
|
||||||
857978527,60,10
|
|
||||||
829768,23,10
|
|
||||||
80158773,69,10
|
|
||||||
771821595,10,10
|
|
||||||
762985858,72,10
|
|
||||||
71271700,27,10
|
|
||||||
591452402,66,10
|
|
||||||
70634828,7,10
|
|
||||||
7,10,10
|
|
||||||
695995052,8,10
|
|
||||||
420984285,16,10
|
|
||||||
654825436,61,10
|
|
||||||
653528340,7,10
|
|
||||||
644292599,11,10
|
|
||||||
631449822,7,10
|
|
||||||
620220747,15,10
|
|
||||||
615763365,68,10
|
|
||||||
594378026,27,10
|
|
||||||
593312758,31,10
|
|
||||||
688155470,30,10
|
|
||||||
3070859372,62,10
|
|
||||||
4208851809,16,10
|
|
||||||
2337952436,24,10
|
|
||||||
2316990095,66,10
|
|
||||||
2317245827,7,10
|
|
||||||
2320102626,18,10
|
|
||||||
2324787028,18,10
|
|
||||||
2324844174,67,10
|
|
||||||
2326478786,60,10
|
|
||||||
2327031723,7,10
|
|
||||||
2327979389,13,10
|
|
||||||
2329375731,31,10
|
|
||||||
2333843479,70,10
|
|
||||||
2339188563,37,10
|
|
||||||
25036634,31,10
|
|
||||||
2339684065,74,10
|
|
||||||
2341555098,11,10
|
|
||||||
2343704209,69,10
|
|
||||||
2348941764,7,10
|
|
||||||
2349656760,79,10
|
|
||||||
2352036411,17,10
|
|
||||||
2354145351,7,10
|
|
||||||
2424229017,26,10
|
|
||||||
2424229017,30,10
|
|
||||||
24284343,35,10
|
|
||||||
2311838590,97,10
|
|
||||||
2311838590,34,10
|
|
||||||
2310825263,15,10
|
|
||||||
218633337,33,10
|
|
||||||
1128343125,63,10
|
|
||||||
11807506,23,10
|
|
||||||
11807506,60,10
|
|
||||||
118882692,35,10
|
|
||||||
1217957486,31,10
|
|
||||||
1307012237,68,10
|
|
||||||
1375606900,67,10
|
|
||||||
1452048,30,10
|
|
||||||
1452048,63,10
|
|
||||||
145511905,68,10
|
|
||||||
151606446,61,10
|
|
||||||
1549474227,67,10
|
|
||||||
15613202,32,10
|
|
||||||
159511306,69,10
|
|
||||||
1606833003,9,10
|
|
||||||
1679596339,74,10
|
|
||||||
191912252,7,10
|
|
||||||
194210021,7,10
|
|
||||||
2010673,64,10
|
|
||||||
203314437,22,10
|
|
||||||
213386023,19,10
|
|
||||||
24673506,67,10
|
|
||||||
251189644,23,10
|
|
||||||
400692942,68,10
|
|
||||||
3312358902,59,10
|
|
||||||
3188903709,65,10
|
|
||||||
3195502499,18,10
|
|
||||||
3203777710,74,10
|
|
||||||
3211956484,34,10
|
|
||||||
3215814536,7,10
|
|
||||||
3221190269,20,10
|
|
||||||
3226664625,28,10
|
|
||||||
3267688490,73,10
|
|
||||||
3269940677,28,10
|
|
||||||
3271705843,62,10
|
|
||||||
3344297292,12,10
|
|
||||||
2545430247,25,10
|
|
||||||
3372913783,20,10
|
|
||||||
3373311444,20,10
|
|
||||||
3373311444,71,10
|
|
||||||
3384021594,64,10
|
|
||||||
3395900897,73,10
|
|
||||||
3398677646,79,10
|
|
||||||
3433628561,29,10
|
|
||||||
3445244192,24,10
|
|
||||||
354897041,72,10
|
|
||||||
400488703,28,10
|
|
||||||
3177507356,24,10
|
|
||||||
3147511625,7,10
|
|
||||||
3133307899,23,10
|
|
||||||
3127420424,32,10
|
|
||||||
26162741,11,10
|
|
||||||
26516263,8,10
|
|
||||||
27075840,65,10
|
|
||||||
271860868,12,10
|
|
||||||
2728939,63,10
|
|
||||||
27731896,20,10
|
|
||||||
278221281,66,10
|
|
||||||
2820140348,62,10
|
|
||||||
29954548,27,10
|
|
||||||
301209792,7,10
|
|
||||||
3025036704,17,10
|
|
||||||
3026382513,15,10
|
|
||||||
3045721313,25,10
|
|
||||||
3047163873,27,10
|
|
||||||
3048263744,7,10
|
|
||||||
3072715478,33,10
|
|
||||||
3103797386,7,10
|
|
||||||
3113895788,35,10
|
|
||||||
3120341363,79,10
|
|
||||||
3122923980,34,10
|
|
||||||
996174506,15,10
|
|
||||||
11164476478,60,6
|
|
||||||
|
|
|
|
@ -1,73 +1,35 @@
|
||||||
id_product,count
|
id_product,count
|
||||||
50,9590
|
2.1.3,14
|
||||||
54,8910
|
1.3.1,10
|
||||||
53,8840
|
1.3.4,4
|
||||||
51,8780
|
1.3.3,4
|
||||||
52,8160
|
1.1,3
|
||||||
55,7860
|
2.1.3.7,3
|
||||||
99,6214
|
1.3.1.3,3
|
||||||
95,4398
|
2.1.1,3
|
||||||
46,3872
|
2.3,2
|
||||||
49,3872
|
2.1.3.4,2
|
||||||
47,3872
|
2.1.1.5,2
|
||||||
48,3872
|
2.3.1,2
|
||||||
45,3852
|
1.3.3.3,2
|
||||||
44,3852
|
1.3.3.4,1
|
||||||
90,1442
|
2.1.2.2,1
|
||||||
93,1400
|
1.1.3,1
|
||||||
94,1390
|
2.2,1
|
||||||
91,1390
|
2.1.4.1.1,1
|
||||||
43,732
|
2.1.4.1,1
|
||||||
92,700
|
1.3.1.1,1
|
||||||
39,696
|
1.3.1.4,1
|
||||||
40,686
|
2.1.3.2,1
|
||||||
38,662
|
1.3.1.5,1
|
||||||
41,512
|
2.1.2,1
|
||||||
42,472
|
1.3.4.2,1
|
||||||
7,150
|
1.3.1.7,1
|
||||||
11,40
|
2.1.1.4,1
|
||||||
23,40
|
2,1
|
||||||
20,40
|
1.4.5.6,1
|
||||||
69,40
|
1.1.1,1
|
||||||
68,40
|
1.4.3.4,1
|
||||||
67,40
|
1.4.3,1
|
||||||
15,40
|
1.3.4.3,1
|
||||||
74,40
|
1.4.5,1
|
||||||
31,40
|
|
||||||
27,40
|
|
||||||
60,36
|
|
||||||
61,30
|
|
||||||
72,30
|
|
||||||
79,30
|
|
||||||
8,30
|
|
||||||
9,30
|
|
||||||
12,30
|
|
||||||
66,30
|
|
||||||
63,30
|
|
||||||
62,30
|
|
||||||
24,30
|
|
||||||
37,30
|
|
||||||
28,30
|
|
||||||
30,30
|
|
||||||
18,30
|
|
||||||
32,30
|
|
||||||
33,30
|
|
||||||
34,30
|
|
||||||
35,30
|
|
||||||
73,20
|
|
||||||
97,20
|
|
||||||
26,20
|
|
||||||
29,20
|
|
||||||
36,20
|
|
||||||
10,20
|
|
||||||
71,20
|
|
||||||
19,20
|
|
||||||
17,20
|
|
||||||
16,20
|
|
||||||
25,20
|
|
||||||
65,20
|
|
||||||
64,20
|
|
||||||
13,10
|
|
||||||
22,10
|
|
||||||
70,10
|
|
||||||
59,10
|
|
||||||
|
|
|
Before Width: | Height: | Size: 1.9 MiB After Width: | Height: | Size: 1.1 MiB |
Before Width: | Height: | Size: 1.8 MiB After Width: | Height: | Size: 2.0 MiB |
Before Width: | Height: | Size: 2.2 MiB After Width: | Height: | Size: 3.1 MiB |
|
@ -13,6 +13,7 @@ count_dcp = pd.read_csv("output_result/risk/count_dcp.csv",
|
||||||
'up_id_firm': str,
|
'up_id_firm': str,
|
||||||
'down_id_firm': str
|
'down_id_firm': str
|
||||||
})
|
})
|
||||||
|
# print(count_dcp)
|
||||||
count_dcp = count_dcp[count_dcp['count'] > 35]
|
count_dcp = count_dcp[count_dcp['count'] > 35]
|
||||||
|
|
||||||
list_firm = count_dcp['up_id_firm'].tolist(
|
list_firm = count_dcp['up_id_firm'].tolist(
|
||||||
|
@ -81,18 +82,18 @@ nx.draw(G_firm,
|
||||||
pos,
|
pos,
|
||||||
node_size=node_size,
|
node_size=node_size,
|
||||||
labels=node_label,
|
labels=node_label,
|
||||||
font_size=6,
|
font_size=8,
|
||||||
width=2,
|
width=3,
|
||||||
edge_color=colors,
|
edge_color=colors,
|
||||||
edge_cmap=cmap,
|
edge_cmap=cmap,
|
||||||
edge_vmin=vmin,
|
edge_vmin=vmin,
|
||||||
edge_vmax=vmax)
|
edge_vmax=vmax)
|
||||||
# nx.draw_networkx_edge_labels(G_firm, pos, 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.95, 0.05, 0.01, 0.3])
|
position = fig.add_axes([0.95, 0.05, 0.01, 0.3])
|
||||||
cb = plt.colorbar(sm, fraction=0.01, cax=position)
|
cb = plt.colorbar(sm, fraction=0.01, cax=position)
|
||||||
cb.ax.tick_params(labelsize=4)
|
cb.ax.tick_params(labelsize=10)
|
||||||
cb.outline.set_visible(False)
|
cb.outline.set_visible(False)
|
||||||
plt.savefig("output_result\\risk\\count_dcp_network")
|
plt.savefig("output_result\\risk\\count_dcp_network")
|
||||||
plt.close()
|
plt.close()
|
||||||
|
|
|
@ -11,44 +11,39 @@ print(count_prod)
|
||||||
print(count_prod.describe())
|
print(count_prod.describe())
|
||||||
|
|
||||||
# prod_networkx
|
# prod_networkx
|
||||||
# BomNodes = pd.read_csv('input_data/input_product_data/BomNodes.csv', index_col=0)
|
BomNodes = pd.read_csv('input_data/input_product_data/BomNodes.csv', index_col=0)
|
||||||
# BomNodes.set_index('Code', inplace=True)
|
BomNodes.set_index('Code', inplace=True)
|
||||||
# BomCateNet = pd.read_csv('input_data/input_product_data/BomCateNet.csv', index_col=0)
|
BomCateNet = pd.read_csv('input_data/input_product_data/BomCateNet.csv', index_col=0)
|
||||||
# BomCateNet.fillna(0, inplace=True)
|
BomCateNet.fillna(0, inplace=True)
|
||||||
|
|
||||||
bom_nodes = pd.read_csv('input_data/input_product_data/BomNodes.csv')
|
G = nx.from_pandas_adjacency(BomCateNet.T, create_using=nx.MultiDiGraph())
|
||||||
bom_nodes['Code'] = bom_nodes['Code'].astype(str)
|
|
||||||
bom_nodes.set_index('Index', inplace=True)
|
|
||||||
|
|
||||||
bom_cate_net = pd.read_csv('input_data/input_product_data/合成结点.csv')
|
|
||||||
g_bom = nx.from_pandas_edgelist(bom_cate_net, source='UPID', target='ID', create_using=nx.MultiDiGraph())
|
|
||||||
|
|
||||||
labels_dict = {}
|
labels_dict = {}
|
||||||
for code in g_bom.nodes:
|
for code in G.nodes:
|
||||||
node_attr = bom_nodes.loc[code].to_dict()
|
node_attr = BomNodes.loc[code].to_dict()
|
||||||
index_list = count_prod[count_prod['id_product'] == code].index.tolist()
|
index_list = count_prod[count_prod['id_product'] == code].index.tolist()
|
||||||
index = index_list[0] if len(index_list) == 1 else -1
|
index = index_list[0] if len(index_list) == 1 else -1
|
||||||
node_attr['count'] = count_prod['count'].get(index, 0)
|
node_attr['count'] = count_prod['count'].get(index, 0)
|
||||||
node_attr['node_size'] = count_prod['count'].get(index, 0)
|
node_attr['node_size'] = count_prod['count'].get(index, 0)
|
||||||
node_attr['node_color'] = count_prod['count'].get(index, 0)
|
node_attr['node_color'] = count_prod['count'].get(index, 0)
|
||||||
labels_dict[code] = node_attr
|
labels_dict[code] = node_attr
|
||||||
nx.set_node_attributes(g_bom, labels_dict)
|
nx.set_node_attributes(G, labels_dict)
|
||||||
# print(labels_dict)
|
# print(labels_dict)
|
||||||
|
|
||||||
pos = nx.nx_agraph.graphviz_layout(g_bom, prog="twopi", args="")
|
pos = nx.nx_agraph.graphviz_layout(G, prog="twopi", args="")
|
||||||
dict_node_name = nx.get_node_attributes(g_bom, 'Name')
|
dict_node_name = nx.get_node_attributes(G, 'Name')
|
||||||
node_labels = {}
|
node_labels = {}
|
||||||
for node in nx.nodes(g_bom):
|
for node in nx.nodes(G):
|
||||||
node_labels[node] = f"{node} {str(dict_node_name[node])}"
|
node_labels[node] = f"{node} {str(dict_node_name[node])}"
|
||||||
# node_labels[node] = f"{str(dict_node_name[node])}"
|
# node_labels[node] = f"{str(dict_node_name[node])}"
|
||||||
colors = list(nx.get_node_attributes(g_bom, 'node_color').values())
|
colors = list(nx.get_node_attributes(G, 'node_color').values())
|
||||||
vmin = min(colors)
|
vmin = min(colors)
|
||||||
vmax = max(colors)
|
vmax = max(colors)
|
||||||
cmap = plt.cm.Blues
|
cmap = plt.cm.Blues
|
||||||
fig = plt.figure(figsize=(10, 10), dpi=300)
|
fig = plt.figure(figsize=(10, 10), dpi=300)
|
||||||
nx.draw(g_bom,
|
nx.draw(G,
|
||||||
pos,
|
pos,
|
||||||
node_size=list(nx.get_node_attributes(g_bom, 'node_size').values()),
|
node_size=list(nx.get_node_attributes(G, 'node_size').values()),
|
||||||
labels=node_labels,
|
labels=node_labels,
|
||||||
font_size=6,
|
font_size=6,
|
||||||
node_color=colors,
|
node_color=colors,
|
||||||
|
@ -60,7 +55,7 @@ sm = plt.cm.ScalarMappable(cmap=cmap, norm=plt.Normalize(vmin=vmin, vmax=vmax))
|
||||||
sm._A = []
|
sm._A = []
|
||||||
position = fig.add_axes([0.01, 0.05, 0.01, 0.3])
|
position = fig.add_axes([0.01, 0.05, 0.01, 0.3])
|
||||||
cb = plt.colorbar(sm, fraction=0.01, cax=position)
|
cb = plt.colorbar(sm, fraction=0.01, cax=position)
|
||||||
cb.ax.tick_params(labelsize=3)
|
cb.ax.tick_params(labelsize=8)
|
||||||
cb.outline.set_visible(False)
|
cb.outline.set_visible(False)
|
||||||
plt.savefig("output_result\\risk\\count_prod_network")
|
plt.savefig("output_result\\risk\\count_prod_network")
|
||||||
plt.close()
|
plt.close()
|
||||||
|
@ -88,10 +83,8 @@ list_prod = list(set(list_prod))
|
||||||
|
|
||||||
# init graph bom
|
# init graph bom
|
||||||
|
|
||||||
BomNodes = pd.read_csv('input_data/input_product_data/BomNodes.csv')
|
BomNodes = pd.read_csv('input_data/input_product_data/BomNodes.csv', index_col=0)
|
||||||
BomNodes.set_index('Index', inplace=True)
|
BomNodes.set_index('Code', inplace=True)
|
||||||
|
|
||||||
BomNodes.loc[13].to_dict()
|
|
||||||
|
|
||||||
g_bom = nx.MultiDiGraph()
|
g_bom = nx.MultiDiGraph()
|
||||||
g_bom.add_nodes_from(list_prod)
|
g_bom.add_nodes_from(list_prod)
|
||||||
|
@ -123,7 +116,7 @@ node_labels = nx.get_node_attributes(g_bom, 'Name')
|
||||||
# node_labels['1'] = '解决方案'
|
# node_labels['1'] = '解决方案'
|
||||||
temp = {}
|
temp = {}
|
||||||
for key, value in node_labels.items():
|
for key, value in node_labels.items():
|
||||||
temp[key] = str(key) + " " + value
|
temp[key] = key + " " + value
|
||||||
node_labels = temp
|
node_labels = temp
|
||||||
colors = nx.get_edge_attributes(g_bom, "count")
|
colors = nx.get_edge_attributes(g_bom, "count")
|
||||||
colors = [w for (n1, n2, _), w in colors.items()]
|
colors = [w for (n1, n2, _), w in colors.items()]
|
||||||
|
@ -139,7 +132,7 @@ fig = plt.figure(figsize=(6, 10), dpi=300)
|
||||||
# plt.subplots_adjust(right=0.7)
|
# plt.subplots_adjust(right=0.7)
|
||||||
nx.draw(g_bom,
|
nx.draw(g_bom,
|
||||||
pos_new,
|
pos_new,
|
||||||
node_size=25,
|
node_size=50,
|
||||||
labels=node_labels,
|
labels=node_labels,
|
||||||
font_size=5,
|
font_size=5,
|
||||||
width=1.5,
|
width=1.5,
|
||||||
|
@ -156,7 +149,7 @@ sm = plt.cm.ScalarMappable(cmap=cmap, norm=plt.Normalize(vmin=vmin, vmax=vmax))
|
||||||
sm._A = []
|
sm._A = []
|
||||||
position = fig.add_axes([0.75, 0.1, 0.01, 0.2])
|
position = fig.add_axes([0.75, 0.1, 0.01, 0.2])
|
||||||
cb = plt.colorbar(sm, fraction=0.01, cax=position)
|
cb = plt.colorbar(sm, fraction=0.01, cax=position)
|
||||||
cb.ax.tick_params(labelsize=3)
|
cb.ax.tick_params(labelsize=8)
|
||||||
cb.outline.set_visible(False)
|
cb.outline.set_visible(False)
|
||||||
plt.savefig("output_result\\risk\\count_dcp_prod_network")
|
plt.savefig("output_result\\risk\\count_dcp_prod_network")
|
||||||
plt.close()
|
plt.close()
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
import pickle
|
|
||||||
|
|
||||||
from sqlalchemy import text
|
from sqlalchemy import text
|
||||||
from orm import engine, connection
|
from orm import engine, connection
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
|
@ -7,101 +5,107 @@ import networkx as nx
|
||||||
import json
|
import json
|
||||||
import matplotlib.pyplot as plt
|
import matplotlib.pyplot as plt
|
||||||
|
|
||||||
# Prepare data
|
# prep data
|
||||||
Firm = pd.read_csv("input_data/input_firm_data/Firm_amended.csv")
|
Firm = pd.read_csv("input_data/input_firm_data/Firm_amended.csv")
|
||||||
Firm['Code'] = Firm['Code'].astype('string')
|
Firm['Code'] = Firm['Code'].astype('string')
|
||||||
Firm.fillna(0, inplace=True)
|
Firm.fillna(0, inplace=True)
|
||||||
BomNodes = pd.read_csv('input_data/input_product_data/BomNodes.csv', index_col=0)
|
BomNodes = pd.read_csv('input_data/input_product_data/BomNodes.csv', index_col=0)
|
||||||
|
|
||||||
# SQL query
|
|
||||||
with open('SQL_analysis_risk.sql', 'r') as f:
|
with open('SQL_analysis_risk.sql', 'r') as f:
|
||||||
str_sql = text(f.read())
|
str_sql = text(f.read())
|
||||||
|
|
||||||
result = pd.read_sql(sql=str_sql, con=connection)
|
result = pd.read_sql(sql=str_sql,
|
||||||
result.to_csv('output_result/risk/count.csv', index=False, encoding='utf-8-sig')
|
con=connection)
|
||||||
|
result.to_csv('output_result\\risk\\count.csv',
|
||||||
|
index=False,
|
||||||
|
encoding='utf-8-sig')
|
||||||
print(result)
|
print(result)
|
||||||
|
|
||||||
# G_bom
|
# G bom
|
||||||
plt.rcParams['font.sans-serif'] = 'SimHei'
|
plt.rcParams['font.sans-serif'] = 'SimHei'
|
||||||
|
|
||||||
exp_id = 1
|
exp_id = 1
|
||||||
G_bom_df = pd.read_sql(
|
G_bom_str = pd.read_sql(
|
||||||
sql=text(f'select g_bom from iiabmdb.without_exp_experiment where id = {exp_id};'),
|
sql=text(f'select g_bom from iiabmdb.without_exp_experiment '
|
||||||
con=connection
|
f'where id = {exp_id};'),
|
||||||
)
|
con=connection)['g_bom'].tolist()[0]
|
||||||
|
|
||||||
if G_bom_df.empty:
|
|
||||||
raise ValueError(f"No g_bom found for exp_id = {exp_id}")
|
|
||||||
|
|
||||||
G_bom_str = G_bom_df['g_bom'].tolist()[0]
|
|
||||||
if G_bom_str is None:
|
|
||||||
raise ValueError(f"g_bom data is None for exp_id = {exp_id}")
|
|
||||||
|
|
||||||
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="")
|
||||||
node_labels = nx.get_node_attributes(G_bom, 'Name')
|
node_labels = nx.get_node_attributes(G_bom, 'Name')
|
||||||
|
# rename node 1
|
||||||
|
# node_labels['1'] = '工业互联网'
|
||||||
|
# node_labels['1.1'] = '工业自动化硬件'
|
||||||
|
# node_labels['1.4'] = '工业互联网安全管理'
|
||||||
|
# node_labels['1.2.1'] = '网络互联服务'
|
||||||
|
# node_labels['1.2.2'] = '标识解析服务'
|
||||||
|
# node_labels['1.2.3'] = '数据互通服务'
|
||||||
|
# node_labels['1.3.1'] = '设计研发软件'
|
||||||
|
# node_labels['1.3.2'] = '采购供应软件'
|
||||||
|
# node_labels['1.3.3'] = '生产制造软件'
|
||||||
|
# node_labels['1.3.4'] = '企业运营软件'
|
||||||
|
# node_labels['1.3.5'] = '仓储物流软件'
|
||||||
plt.figure(figsize=(12, 12), dpi=300)
|
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=3)
|
nx.draw_networkx_labels(G_bom, pos, labels=node_labels, font_size=6)
|
||||||
plt.savefig(f"output_result/risk/g_bom_exp_id_{exp_id}.png")
|
# plt.show()
|
||||||
|
plt.savefig(f"output_result\\risk\\g_bom_exp_id_{exp_id}.png")
|
||||||
plt.close()
|
plt.close()
|
||||||
|
|
||||||
# G_firm
|
# G firm
|
||||||
plt.rcParams['font.sans-serif'] = 'SimHei'
|
plt.rcParams['font.sans-serif'] = 'SimHei'
|
||||||
|
|
||||||
sample_id = 1
|
sample_id = 1
|
||||||
# G_firm_df = pd.read_sql(
|
|
||||||
# sql=text(f'select g_firm from iiabmdb.without_exp_sample where id = {sample_id};'),
|
|
||||||
# con=connection
|
|
||||||
# )
|
|
||||||
#
|
|
||||||
# if G_firm_df.empty:
|
|
||||||
# raise ValueError(f"No g_firm found for sample_id = {sample_id}")
|
|
||||||
#
|
|
||||||
# G_firm_str = G_firm_df['g_firm'].tolist()[0]
|
|
||||||
# if G_firm_str is None:
|
|
||||||
# raise ValueError(f"g_firm data is None for sample_id = {sample_id}")
|
|
||||||
#
|
|
||||||
# G_firm = nx.adjacency_graph(json.loads(G_firm_str))
|
|
||||||
|
|
||||||
with open("firm_network.pkl", 'rb') as f:
|
G_firm_str = pd.read_sql(
|
||||||
G_firm = pickle.load(f)
|
sql=text(f'select g_firm from iiabmdb.without_exp_sample '
|
||||||
print(f"Successfully loaded cached data from firm_network.pkl")
|
f'where id = {exp_id};'),
|
||||||
|
con=connection)['g_firm'].tolist()[0]
|
||||||
|
|
||||||
|
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="")
|
||||||
|
# desensitize
|
||||||
node_label = nx.get_node_attributes(G_firm, 'Revenue_Log')
|
node_label = nx.get_node_attributes(G_firm, 'Revenue_Log')
|
||||||
node_label = {key: key for key in node_label.keys()}
|
node_label = {
|
||||||
|
key: key
|
||||||
|
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())
|
||||||
|
node_size = list(map(lambda x: x**2, node_size))
|
||||||
edge_label = nx.get_edge_attributes(G_firm, "Product")
|
edge_label = nx.get_edge_attributes(G_firm, "Product")
|
||||||
edge_label = {(n1, n2): label for (n1, n2, _), label in edge_label.items()}
|
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=5)
|
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"output_result/risk/g_firm_sample_id_{sample_id}_de.png")
|
# plt.show()
|
||||||
|
plt.savefig(f"output_result\\risk\\g_firm_sample_id_{exp_id}_de.png")
|
||||||
plt.close()
|
plt.close()
|
||||||
|
|
||||||
# Count firm product
|
# count firm product
|
||||||
count_firm_prod = result.value_counts(subset=['id_firm', 'id_product'])
|
count_firm_prod = result.value_counts(subset=['id_firm', 'id_product'])
|
||||||
count_firm_prod.name = 'count'
|
count_firm_prod.name = 'count'
|
||||||
count_firm_prod = count_firm_prod.to_frame().reset_index()
|
count_firm_prod = count_firm_prod.to_frame().reset_index()
|
||||||
count_firm_prod.to_csv('output_result/risk/count_firm_prod.csv', index=False, encoding='utf-8-sig')
|
count_firm_prod.to_csv('output_result\\risk\\count_firm_prod.csv',
|
||||||
|
index=False,
|
||||||
|
encoding='utf-8-sig')
|
||||||
print(count_firm_prod)
|
print(count_firm_prod)
|
||||||
|
|
||||||
# Count firm
|
# count firm
|
||||||
count_firm = count_firm_prod.groupby('id_firm')['count'].sum()
|
count_firm = count_firm_prod.groupby('id_firm')['count'].sum()
|
||||||
count_firm = count_firm.to_frame().reset_index()
|
count_firm = count_firm.to_frame().reset_index()
|
||||||
count_firm.sort_values('count', inplace=True, ascending=False)
|
count_firm.sort_values('count', inplace=True, ascending=False)
|
||||||
count_firm.to_csv('output_result/risk/count_firm.csv', index=False, encoding='utf-8-sig')
|
count_firm.to_csv('output_result\\risk\\count_firm.csv',
|
||||||
|
index=False,
|
||||||
|
encoding='utf-8-sig')
|
||||||
print(count_firm)
|
print(count_firm)
|
||||||
|
|
||||||
# Count product
|
# count product
|
||||||
count_prod = count_firm_prod.groupby('id_product')['count'].sum()
|
count_prod = count_firm_prod.groupby('id_product')['count'].sum()
|
||||||
count_prod = count_prod.to_frame().reset_index()
|
count_prod = count_prod.to_frame().reset_index()
|
||||||
count_prod.sort_values('count', inplace=True, ascending=False)
|
count_prod.sort_values('count', inplace=True, ascending=False)
|
||||||
count_prod.to_csv('output_result/risk/count_prod.csv', index=False, encoding='utf-8-sig')
|
count_prod.to_csv('output_result\\risk\\count_prod.csv',
|
||||||
|
index=False,
|
||||||
|
encoding='utf-8-sig')
|
||||||
print(count_prod)
|
print(count_prod)
|
||||||
|
|
||||||
# DCP disruption causing probability
|
# DCP disruption causing probability
|
||||||
|
@ -110,34 +114,26 @@ print(result_disrupt_ts_above_0)
|
||||||
result_dcp = pd.DataFrame(columns=[
|
result_dcp = pd.DataFrame(columns=[
|
||||||
's_id', 'up_id_firm', 'up_id_product', 'down_id_firm', 'down_id_product'
|
's_id', 'up_id_firm', 'up_id_product', 'down_id_firm', 'down_id_product'
|
||||||
])
|
])
|
||||||
|
|
||||||
result_dcp_list = [] # 用列表收集数据,避免DataFrame逐行增长的问题
|
|
||||||
for sid, group in result.groupby('s_id'):
|
for sid, group in result.groupby('s_id'):
|
||||||
ts_start = max(group['ts'])
|
ts_start = max(group['ts'])
|
||||||
while ts_start >= 1:
|
while ts_start >= 1:
|
||||||
ts_end = ts_start - 1
|
ts_end = ts_start - 1
|
||||||
while ts_end >= 0:
|
while ts_end >= 0:
|
||||||
up = group.loc[group['ts'] == ts_end, ['id_firm', 'id_product']]
|
up = group.loc[group['ts'] == ts_end, ['id_firm', 'id_product']]
|
||||||
down = group.loc[group['ts'] == ts_start, ['id_firm', 'id_product']]
|
down = group.loc[group['ts'] == ts_start,
|
||||||
|
['id_firm', 'id_product']]
|
||||||
for _, up_row in up.iterrows():
|
for _, up_row in up.iterrows():
|
||||||
for _, down_row in down.iterrows():
|
for _, down_row in down.iterrows():
|
||||||
result_dcp_list.append([sid] + up_row.tolist() + down_row.tolist())
|
row = [sid]
|
||||||
|
row += up_row.tolist()
|
||||||
|
row += down_row.tolist()
|
||||||
|
result_dcp.loc[len(result_dcp.index)] = row
|
||||||
ts_end -= 1
|
ts_end -= 1
|
||||||
ts_start -= 1
|
ts_start -= 1
|
||||||
|
|
||||||
# 转换为DataFrame
|
|
||||||
result_dcp = pd.DataFrame(result_dcp_list, columns=[
|
|
||||||
's_id', 'up_id_firm', 'up_id_product', 'down_id_firm', 'down_id_product'
|
|
||||||
])
|
|
||||||
|
|
||||||
# 统计
|
|
||||||
count_dcp = result_dcp.value_counts(
|
count_dcp = result_dcp.value_counts(
|
||||||
subset=['up_id_firm', 'up_id_product', 'down_id_firm', 'down_id_product']
|
subset=['up_id_firm', 'up_id_product', 'down_id_firm', 'down_id_product'])
|
||||||
).reset_index(name='count')
|
count_dcp.name = 'count'
|
||||||
|
count_dcp = count_dcp.to_frame().reset_index()
|
||||||
# 保存文件
|
count_dcp.to_csv('output_result\\risk\\count_dcp.csv',
|
||||||
count_dcp.to_csv('output_result/risk/count_dcp.csv', index=False, encoding='utf-8-sig')
|
index=False, encoding='utf-8-sig')
|
||||||
|
|
||||||
# 输出结果
|
|
||||||
print(count_dcp)
|
print(count_dcp)
|
||||||
|
|
||||||
|
|