-
Notifications
You must be signed in to change notification settings - Fork 0
/
shapleyFMPE.py
105 lines (85 loc) · 6.73 KB
/
shapleyFMPE.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
#!/usr/bin/env python
import xlrd
import xlwt
import re
import random
import numpy as np
import pandas as pd
from sklearn.metrics import mean_squared_error
def main():
#
m1=929530+1056810+1233800+1080350+1056600+1685450+1800920+1573630+146180+119460+92560+1409530+124040
m2=(1653120-999850)+(2190680-1056810)+(1709300-128280) + (2930300.0 - 128870)+(2748780-1141040)+(4224820-1685450)+ (3913280-1618840)+(4101480-1661500)+(692700-146180)+(752900-94520)+(2640860-69240)+(290720-7910)+ (539880 - 89770)
m3=(2173040-1653120)+(4000440-2190680)+(3895770-1590300)+ (1954820 - 2930300.0)+(4032300-2945120)+(2741130-1987940.0) + (4042440-2337080)+(3210930-359240)+(1319160-387120)+(1679610-717060)+(6472260-2888660)+(2249220-649140) + (1873500-539880)
m4=(6079960-2789760)+(6567800-3562650)+(5623040-3895770)+ (4283880-3563310)+(4162560-3530970)+(5228360-2437890) + (6491520 - 4042440)+(3025200-911340)+(2999480-1327560)+(2327040-1341000)+(6992680-4535430)+(2305080-1007520)+ (2546000 - 1000740)
d1=999850+1123930+688020+2197120+1141040+120170+1618840+1661500+129590+94520+1415460+117350+89770
d2=(2178840-999850)+(1548900-1056810)+(1035620-128280)+ (2020540 - 128870)+(2945120-1141040)+(3726620-1685450)+ (3178740 - 1618840)+(4747180-1661500)+(755660-146180)+(736220-94520)+(2888660-69240)+(377240-7910)+ (571760 - 89770)
d3=(3170400-1653120)+(4805070-2190680)+(3176520-1590300)+ (2972490 - 2930300)+(3526350-2945120)+(2177310-1987940)+ (3616350 - 2337080)+(3979740-359240)+(1800390-387120)+(1341000-717060)+(4535430-2888660)+(2084910-649140)+ (1939710 - 539880)
d4=(6302440-2789760)+(5756760-3562650)+(6327680-3895770) + (4455080 - 3563310)+(3871360-3530970)+(3838000-2437890)+ (5536840 - 4042440)+(3493680-911340)+(3532960-1327560)+(2838680-1341000)+(7763640-4535430)+(2457560-1007520)+ (2101440 - 1000740)
r1=166350+118750+128280+128870+105460+120170+114670+55310+25540+21140+69240+7910+9340
r2=(1281020-999850)+(1248000-1056810)+(685740-128280)+ (635200 - 128870)+(2627020-1141040)+(2720960.0-1685450)+ (2697840 - 1618840)+(2514780-1661500)+(375480-146180)+(363180-94520)+(256100-69240)+(51320-7910)+ (306800 - 89770)
r3=(1899460-1653120)+(2766090-2190680)+(3358470-1590300)+ (1873140 - 2930300.0)+(3231600-2945120)+(2282670-1987940)+ (2606070 - 2337080)+(911340-359240)+(1398510-387120)+(1580190-717060)+(4792680-2888660)+(835740-649140)+ (1217250 - 539880)
r4=(5829000-2789760)+(5483840-3562650)+(5915080-3895770)+ (4228040 - 3563310)+(3433200-3530970)+(3810280-2437890)+ (3322120 - 4042440)+(2276440-911340)+(2564480-1327560)+(3052360-1341000)+(5948240-4535430)+(1710640-1007520)+ (1756120 - 1000740)
M = (m1 + m2 + m3 + m4) / (4*13)
D = (d1 + d2 + d3 + d4) / (4*13)
R = (r1 + r2 + r3 + r4) / (4*13)
print('MA shapley is %f:' % (M))
print('DA is %f:' % (D))
print('RA is %f:' % (R))
m1g = -19386.7 - 169537.5 -177407.0 -32425.6 -412354.0 -242067.6 -442965.3 - 442491.7 - 809798.2 - 546253.5 - 936164.2 - 640612.9 - 823759.3 - 519333.2
m2g = (-46245.6 - (-19386.7)) + (-216687.0 - (-169537.5)) + (-205448.4 - (-177407.0)) + (-71293.8 - (-32425.6)) + (
-567885.3 - (-442965.3)) + (-278386.1 - (-242067.6)) + ((-596311.2) - (-412354.0)) + (-664585.1 - (-809798.2))
m3g = (-2388375.4 - (-2519807.6)) + (-3461114.8 - (-4271435.0)) + (-3745886.8 - (-4411341.1)) + (-2827577.1 - (-3578287.9)) + (
-4119640.9 - (-4086220.3)) + (-3792797.4 - (-4268037.8)) +(-2900269.2-(-4654854.6))+ (
-3841530.6 - (-5444607.6)) + (-2806021.0 - (-3408053.1)) + (-3218284.9 - (-3694505.5))
m4g = (-2849017.5 - (-2388375.4)) + (-4200700.9 - (-3461114.8)) + (
-3772836.7 - (-3745886.8)) + (-3584875.3 - (-2827577.0)) + (
-3186849.1 - (-3792797.4)) + (-3787136.1 - (-2900269.2) )+ (
-4256355.9 - (-4119640.9)) + (-3837278.1 - (-3841530.6))
d1g = -22318.4 - 209980.8 - 201740.3 - 34224.9 - 498689.9 - 276350.0 - 57635.8 - 225039.5 - 1062073.5 - 1003283.6 - 396773.2 - 434668.5 - 740940.6 - 841286.6 - 524142.3
d2g = (-41803.7 - (-19386.7)) + (-272856.1 - (-169537.5)) + (
-224401.9 - (-177407.0)) + (-78889.3 - (-32425.6)) + ((-602528.0) - (
-412354.0))+(-322392.7 - (-242067.6)) + (-601742.9 - (-546253.5)) + (
-617156.1 - (-442491.7))
d3g = (-2148698.1 - (-2519807.6)) + (-4678006.2 - (-4271435.0)) + (
-4602247.6 - (-4411341.1)) + (-3387114.0 - (-3578287.9)) + (
-4223230.8 - (-4086220.3)) + (-3972128.7 - (-4972010.8)) + (
-3441908.4 - (-4654854.6)) + (-4027708.7 - (-5444607.6)) + (
-4012605.1 - (-3096747.7))
d4g = (-2531704.0 - (-2388375.4)) + (-4052414.5 - (-3461114.8)) + (
-4400377.5 - (-3745886.8)) + (-2944995.6 - (-2827577.0)) + (
-4350921.3- (-4286265.8)) + (-4362999.2 - (-4119640.9)) + (
-4488903.3 - ( -3792797.4))
r1g = -2937099.7 - 4967505.7 - 5065887.7 - 2820138.5 - 4638554.1 - 4932131.1 - 3225642.8 - 5315434.5 - 4556783.7 - 5081891.7 - 4336601.6 - 5831771.0 - 4914002.8
r2g = -2594463.0 - (-19386.7) + (-434289.4 - (-169537.5)) + (
-4532349.0 - (-177407.0)) + (-3747017.9 - (-32425.6)) + (
-4129362.2 - (-412353.9)) + (-4923894.6 - (-442965.3)) + (
-3245911.6 - (-242067.6)) + (-4106333.4 - (-442491.7)) + (
-3549294.9 - (-519333.2))
r3g = -5755888.8 - (-2519807.6) + (-8515315.4 - (-4271435.0)) + (
-7075660.2 - (-4411341.1)) + (-7204442.4 - (-3578287.9)) + (
-7253236.7 - (-4268037.8)) + (-6960205.1 - (-4654854.6)) + (
-6279223.4 - (-3401041.3)) + (-5526942.4 - (-5444607.6)) + (
-5722563.9 - (-3408053.1))
r4g = -5831875.7 - (-2388375.4) + (-5408756.3 - (-3461114.8)) + (
-8285727.6- (-3745886.8)) + (-6889756.1 - (-2827577.0)) + (
-6759063.1 - (-4119640.9)) + (-5961105.6 - (-2900269.2)) + (
-2768406.6 - (-3841530.6)) + (-5572608.4 - (-3218284.9))
MM = (m1g/14 + m2g/8 + m3g/10 + m4g/8) / 4
DD = (d1g/15 + d2g/8 + d3g/9 + d4g/7) / 4
RR = (r1g/13 + r2g/9 + r3g/9 + r4g/8) / 4
# print('m1g is %f' % (m1g/14))
# print('m2g is %f' % (m2g/8))
# print('m3g is %f' % (m3g/10))
# print('m4g is %f' % (m4g/8))
print('MG shapley is %f:' % (MM))
print('DG is %f:' % (DD))
print('RG is %f:' % (RR))
NM=(MM+M)/2
ND=(DD+D)/2
DR=(RR+R)/2
print('MT shapley is %f:' % (NM))
print('DT is %f:' % (ND))
print('RT is %f:' % (DR))
if __name__ == '__main__':
main()