In [9]:
from SALib.sample import morris as ms
from SALib.analyze import morris as ma
from SALib.plotting import morris as mp
from mesa.visualization.ModularVisualization import ModularServer
from mesa.batchrunner import BatchRunner
from model.model import SOBAModel
import datetime as dt
import os
import subprocess
import configuration.defineOccupancy as co
import csv
import numpy as np
import matplotlib.pyplot as plt
from tempfile import mkstemp
from shutil import move
from os import fdopen, remove
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
from IPython.core.pylabtools import figsize
figsize(12, 10)

In [2]:
def replace(file_path, pattern, subst):
    #Create temp file
    fh, abs_path = mkstemp()
    with fdopen(fh,'w') as new_file:
        with open(file_path) as old_file:
            for line in old_file:
                new_file.write(line.replace(pattern, subst))
    #Remove original file
    remove(file_path)
    #Move new file
    move(abs_path, file_path)

In [3]:
def energy_model(data, nAux):

    y = []
    n = str(nAux)

    replace("configuration/settings.py", "model = 0", "model = "+n)
    replace("configuration/settings.py", "temperatureSummerIn = 24", "temperatureSummerIn = "+str(data[3]))
    replace("configuration/defineOccupancy.py", "NProfessors = 40", "NProfessors = "+str(data[0]))
    replace("configuration/defineOccupancy.py", "NResearches = 40", "NResearches = "+str(data[0]))
    replace("configuration/defineOccupancy.py", "TconfortProfessors = [19, 27]", "TconfortProfessors = "+str(data[1]))
    replace("configuration/defineOccupancy.py", "TconfortResearchers = [19, 27]", "TconfortResearchers = "+str(data[1]))
    replace("configuration/defineOccupancy.py", "behaviourEnvironmentProfessors = [25, 60, 15]", "behaviourEnvironmentProfessors = "+str(data[2]))
    replace("configuration/defineOccupancy.py", "behaviourEnvironmentResearchers = [35, 60, 5]", "behaviourEnvironmentResearchers = "+str(data[2]))
    
    proc = subprocess.run(['python3', 'batch.py'], shell = False)

    print('¡Cambio de valores!')
    if os.path.exists("log/tmp/occupants.txt"):
        os.remove("log/tmp/occupants.txt")
    if os.path.exists("log/tmp/rooms.txt"):
        os.remove("log/tmp/rooms.csv")
    replace("configuration/settings.py", "model = "+n, "model = 0")
    replace("configuration/settings.py", "temperatureSummerIn = "+str(data[3]), "temperatureSummerIn = 24")
    replace("configuration/defineOccupancy.py", "NProfessors = "+str(data[0]), "NProfessors = 40")
    replace("configuration/defineOccupancy.py", "NResearches = "+str(data[0]), "NResearches = 40")
    replace("configuration/defineOccupancy.py", "TconfortProfessors = "+str(data[1]), "TconfortProfessors = [19, 27]")
    replace("configuration/defineOccupancy.py", "TconfortResearchers = "+str(data[1]), "TconfortResearchers = [19, 27]")
    replace("configuration/defineOccupancy.py", "behaviourEnvironmentProfessors = "+str(data[2]), "behaviourEnvironmentProfessors = [25, 60, 15]")
    replace("configuration/defineOccupancy.py", "behaviourEnvironmentResearchers = "+str(data[2]), "behaviourEnvironmentResearchers = [35, 60, 5]")

    with open("/home/merinom/Desktop/GreenSOBA/results/M"+n+"/energyByDayTotal.csv") as csvfile1, open("/home/merinom/Desktop/GreenSOBA/results/M"+ n +"/energyByDayLPC.csv") as csvfile2, open("/home/merinom/Desktop/GreenSOBA/results/M"+n+"/energyByDayHVAC.csv") as csvfile3:
        readCSV = csv.reader(csvfile1, delimiter=',')
        for row in readCSV:
            if row[0] == 'total':
                print(row[1])
                print(np.maximum(0, np.minimum(float(row[1]), 10000000000000000000)))
                y.append(np.maximum(0, np.minimum(float(row[1]), 10000000000000000000)))
        readCSV = csv.reader(csvfile2, delimiter=',')
        for row in readCSV:
            if row[0] == 'total':
                print(row[1])
                print(np.maximum(0, np.minimum(float(row[1]), 10000000000000000000)))
                y.append(np.maximum(0, np.minimum(float(row[1]), 10000000000000000000)))
        readCSV = csv.reader(csvfile3, delimiter=',')
        for row in readCSV:
            if row[0] == 'total':
                print(row[1])
                print(np.maximum(0, np.minimum(float(row[1]), 10000000000000000000)))
                y.append(np.maximum(0, np.minimum(float(row[1]), 10000000000000000000)))
    return y

In [12]:
def model(data, n):
    values = []
    for i in data:
        values.append(energy_model(i, n))
    return values

In [ ]:
number_sims = 100


tempIn = np.random.randint(low=18, high=30, size=number_sims)

people = np.random.randint(low=0, high=40, size=number_sims)

temperature = []
temperature1 = np.random.randint(low=18, high=30, size=number_sims)
temperature2 = np.random.randint(low=18, high=30, size=number_sims)
for i in range(number_sims):
    if temperature2[i] < temperature1[i]:
        temperature.append([temperature1[i], temperature1[i]])
    else:
        temperature.append([temperature1[i], temperature2[i]])

behaviour = []
behaviour1 = np.random.randint(low=0, high=100, size=number_sims)
behaviour2 = np.random.randint(low=0, high=100, size=number_sims)
behaviour3 = np.random.randint(low=0, high=100, size=number_sims)
for i in range(number_sims):
    behaviour.append([behaviour1[i], behaviour2[i], behaviour3[i]])


data = []
print(behaviour)

for n in range(number_sims):
    a = [people[n], temperature[n], behaviour[n], tempIn[n]]
    data.append(a)

for i in range(0,3):
    y = model(data, i)
    if i == 0:
        y0 = y
    elif i == 1:
        y1 = y
    else:
        y2 = y

In [10]:
EnergyLE0 = []
EnergyHVAC0 = []
EnergyTotal0 = []

EnergyLE1 = []
EnergyHVAC1 = []
EnergyTotal1 = []

EnergyLE2 = []
EnergyHVAC2 = []
EnergyTotal2 = []

print(y0)
print(y1)
print(y2)

for i in y0:
    EnergyLE0.append(i[1]/1000)
    EnergyHVAC0.append(i[2]/1000)
    EnergyTotal0.append(i[0]/1000)

    
for i in y1:
    EnergyLE1.append(i[1]/1000)
    EnergyHVAC1.append(i[2]/1000)
    EnergyTotal1.append(i[0]/1000)
    
    
for i in y2:
    EnergyLE2.append(i[1]/1000)
    EnergyHVAC2.append(i[2]/1000)
    EnergyTotal2.append(i[0]/1000)


[[1893195.7214579713, 862124.2499999979, 1031071.471457961], [3026577.3168652607, 945759.8500000024, 2080817.4668652685], [1945101.2292943746, 391269.45000000217, 1553831.779294376], [2723727.9791701334, 897244.1500000027, 1826483.829170123], [1969453.8948145353, 641885.6499999986, 1327568.2448145277], [2332164.2864118163, 1019805.7499999986, 1312358.5364118235], [1574676.524777892, 132320.0500000014, 1442356.4747779034], [2264670.081168866, 983594.4999999981, 1281075.5811688653], [2514947.3777654725, 723285.5999999972, 1791661.777765473], [1932806.096930483, 713414.9000000007, 1219391.196930481], [2293268.2184545235, 989220.4500000029, 1304047.7684545112], [2150808.301921449, 565263.9999999986, 1585544.3019214354], [2415247.5677677067, 551401.8500000001, 1863845.7177677033], [1997462.3230336227, 667823.1499999958, 1329639.1730336177], [2828509.094080345, 764971.2500000041, 2063537.8440803487], [2496576.2647280153, 926832.7500000003, 1569743.5147280144], [2771964.72076, 942664.9999999995, 1829299.720760005], [2414659.856388362, 714293.2500000031, 1700366.6063883668], [1469375.521134459, 213738.94999999853, 1255636.5711344476], [2287440.342731617, 607288.5499999981, 1680151.792731617], [2116861.9697185582, 866256.0500000024, 1250605.9197185594], [2687188.322313549, 962072.1999999991, 1725116.1223135646], [3079576.998325197, 957844.600000001, 2121732.3983251927], [1532320.7710714494, 0.0, 1532320.7710714494], [2604871.3888250287, 554013.999999999, 2050857.3888250287], [1841272.463961821, 716890.1499999994, 1124382.313961817], [1183970.5633029253, 257844.44999999864, 926126.1133029244], [2012991.0725085838, 518282.39999999857, 1494708.6725085783], [2064997.8825656227, 314451.89999999903, 1750545.9825656123], [2159523.6983257867, 494170.7500000031, 1665352.9483257923], [1998787.3565521925, 344856.4499999982, 1653930.9065521958], [1772144.9574361145, 469826.59999999846, 1302318.35743611], [2674381.506429603, 869985.3000000038, 1804396.2064296065], [2625345.4430357907, 822555.1000000031, 1802790.3430357862], [2124539.286998189, 626718.2, 1497821.0869981812], [2043259.9971205743, 621325.0500000002, 1421934.9471205694], [2258101.9299105983, 1048499.6000000013, 1209602.329910598], [2806066.2831055042, 763414.5500000009, 2042651.733105523], [2711578.407483044, 806519.5000000017, 1905058.9074830422], [2961508.607599236, 959510.0000000006, 2001998.6075992528], [1148062.5056605039, 132320.0500000014, 1015742.4556605038], [1838444.9432154058, 807663.5000000037, 1030781.443215404], [2526514.578660779, 993077.5000000009, 1533437.0786607775], [2242488.2003894686, 326848.6500000017, 1915639.5503894717], [2712728.6481988085, 897812.2999999956, 1814916.348198806], [2159072.9299111376, 573752.3500000008, 1585320.5799111389], [2045392.1451881658, 132320.0500000014, 1913072.0951881758], [1633042.5121423856, 0.0, 1633042.5121423856], [2239314.1004869393, 398657.35000000324, 1840656.750486934], [2088263.6314986942, 666328.2500000006, 1421935.381498689], [2247799.600847527, 481710.09999999974, 1766089.5008475326], [2983046.053128256, 939075.3499999988, 2043970.7031282512], [2192005.5105772284, 345847.7500000029, 1846157.7605772258], [1548511.0568891307, 472060.8000000002, 1076450.2568891356], [2605621.9395297477, 807307.2999999998, 1798314.6395297546], [1640167.8387761444, 658073.4499999989, 982094.388776147], [2983934.551602283, 925957.3000000019, 2057977.2516022867], [2877025.914778252, 1032578.6499999993, 1844447.2647782725], [1651516.5355050107, 654005.449999997, 997511.0855050017], [1965513.9371659944, 132320.0500000014, 1833193.8871660056], [2240549.944522628, 323627.1000000012, 1916922.844522629], [1431477.161807549, 475172.7000000009, 956304.4618075467], [2614845.823333594, 816082.250000001, 1798763.5733335929], [2281069.580034796, 999474.7000000008, 1281594.880034795], [1780839.0311068464, 476138.9500000005, 1304700.0811068416], [2258876.990321664, 338324.8999999995, 1920552.0903216647], [2591876.7258321927, 886512.8000000024, 1705363.925832186], [2687955.8670443296, 1004717.7500000033, 1683238.117044324], [2353112.944585743, 1044648.9500000009, 1308463.9945857283], [2109676.2059345455, 262243.5999999989, 1847432.605934552], [2839417.963692177, 1067355.2499999986, 1772062.713692187], [1589337.8285062187, 237373.00000000023, 1351964.82850621], [2860940.3995244233, 947516.0000000009, 1913424.3995244096], [2431750.6076466385, 877906.799999997, 1553843.8076466403], [1998745.757483107, 934813.5499999997, 1063932.2074831098], [2031603.1488792642, 381599.4500000002, 1650003.698879266], [2127350.9416055833, 551972.0500000024, 1575378.8916055893], [2705035.2330434374, 810606.0500000019, 1894429.1830434361], [1870946.0863034655, 317772.8499999985, 1553173.236303465], [2910938.782810213, 979549.0999999989, 1931389.6828102246], [1043488.2258067621, 132320.0500000014, 911168.1758067616], [1750261.394166951, 206451.85000000085, 1543809.5441669514], [1358631.7291337748, 408222.3500000008, 950409.379133777], [1849867.3344131105, 729942.4499999969, 1119924.8844131099], [1404007.460623213, 446111.3999999973, 957896.0606232013], [1566389.3712322442, 301768.7499999998, 1264620.62123224], [2074896.1846930091, 323460.00000000163, 1751436.184693008], [1462003.2257962686, 121319.70000000014, 1340683.5257962607], [2467439.612792856, 910265.6999999956, 1557173.9127928694], [2968343.672009705, 1079726.8000000012, 1888616.8720096918], [2547536.037005984, 520288.3499999959, 2027247.6870059802], [1952554.359604133, 469662.3500000022, 1482892.0096041332], [2086017.4042731011, 345230.2499999997, 1740787.1542731007], [2638411.317333894, 926602.2499999958, 1711809.0673338983], [1864093.8417155654, 650886.1499999972, 1213207.691715559], [2875725.8315007663, 1025428.1499999999, 1850297.6815007657], [1992022.0075998185, 584563.650000002, 1407458.3575998158], [2055508.708719906, 900555.3499999989, 1154953.358719907], [2155326.49210107, 231787.20000000027, 1923539.292101066], [2687955.7391538722, 1013408.0999999989, 1674547.6391538724]]
[[1721630.101887394, 555587.999999999, 1166042.1018873944], [2379676.3698916407, 685764.7999999996, 1693911.5698916414], [1452494.632257094, 245915.50000000052, 1206579.132257094], [2289525.569740309, 720178.2499999993, 1569347.319740308], [1707294.3866495807, 488679.1499999997, 1218615.23664958], [1982472.976505728, 742267.5000000003, 1240205.4765057275], [1172858.9081532364, 41996.7499999996, 1130862.1581532352], [1889046.0171171366, 661342.2999999996, 1227703.7171171377], [1872558.8231268956, 479470.4999999997, 1393088.3231268958], [1787704.354448008, 580904.9, 1206799.4544480068], [1748178.525196734, 546523.449999999, 1201655.075196735], [1576043.2482360608, 338460.64999999985, 1237582.5982360595], [1487461.329394259, 239479.95000000016, 1247981.3793942623], [1694532.9932181623, 478752.1999999996, 1215780.7932181624], [1995713.270123469, 487730.1999999996, 1507983.0701234671], [1703585.0678072984, 431458.39999999944, 1272126.6678072975], [2342287.910028737, 755387.2999999995, 1586900.6100287372], [1597752.6938528458, 345350.9000000002, 1252401.793852846], [1271046.729545794, 130273.45000000019, 1140773.2795457933], [1536910.868646435, 300106.2499999994, 1236804.6186464373], [1932748.9947210646, 698412.0499999995, 1234336.944721064], [1973781.229010546, 561124.7999999993, 1412656.4290105435], [2229373.617084383, 604209.0499999998, 1625164.567084382], [1122670.3244431408, 0.0, 1122670.3244431408], [1849602.9477748317, 417057.7499999997, 1432545.1977748303], [1546409.2377159395, 383895.5000000001, 1162513.737715938], [1281098.9781559806, 151410.70000000042, 1129688.278155981], [1718086.533795977, 445586.19999999955, 1272500.3337959782], [1437853.4143269206, 211404.5, 1226448.9143269202], [1585770.5127053456, 330417.15, 1255353.362705346], [1425874.8087523088, 213598.04999999932, 1212276.758752311], [1360349.6064972812, 202220.29999999964, 1158129.3064972823], [2279486.820699314, 722139.1500000006, 1557347.6706993117], [1824006.388436493, 445417.74999999953, 1378588.6384364928], [1657217.8363338776, 407970.2999999991, 1249247.5363338762], [1793520.447372593, 529605.4499999993, 1263914.997372593], [1970193.4869054297, 752874.8499999999, 1217318.6369054304], [1643483.9956416285, 331082.6499999998, 1312401.3456416293], [1880215.7271969845, 470813.84999999986, 1409401.8771969844], [1939834.1971194833, 479470.4999999997, 1460363.6971194842], [1166169.881151212, 41996.7499999996, 1124173.1311512098], [1837633.176761394, 660926.7499999994, 1176706.4267613944], [2083472.8043972524, 741017.449999999, 1342455.3543972515], [1488031.1686139302, 223733.94999999978, 1264297.2186139298], [2241476.0950303376, 700240.8999999994, 1541235.1950303346], [1711714.2937502959, 415025.0499999995, 1296689.2437502972], [1179466.8657759854, 41996.7499999996, 1137470.1157759842], [1122564.6632675081, 0.0, 1122564.6632675081], [1580407.2534142279, 309201.6999999996, 1271205.553414229], [1724193.6596375895, 475127.1999999996, 1249066.459637588], [1492707.744526645, 251850.35000000012, 1240857.3945266458], [2066493.7008882423, 529605.4499999993, 1536888.2508882429], [1392198.445596461, 178425.05, 1213773.3955964614], [1602943.3685928406, 432727.79999999923, 1170215.5685928408], [1845402.7002354977, 455001.94999999914, 1390400.7502354977], [1609461.1441676803, 451650.9000000001, 1157810.2441676809], [2133587.9139301185, 558446.699999999, 1575141.2139301198], [2098371.959746767, 620003.7499999998, 1478368.209746766], [1415838.601334217, 270469.30000000016, 1145369.3013342163], [1178313.2034317902, 41996.7499999996, 1136316.453431789], [1348778.2292041285, 157228.35000000076, 1191549.8792041289], [1484993.7821282526, 335658.34999999957, 1149335.4321282513], [1959726.160547036, 531366.1999999994, 1428359.9605470374], [2010497.7675244517, 760174.0999999992, 1250323.6675244519], [1612607.6251971964, 412677.3999999998, 1199930.225197196], [1340793.105021277, 151410.70000000042, 1189382.4050212784], [2196487.9048422864, 700347.0999999999, 1496140.8048422865], [2008819.9712099181, 605833.4499999997, 1402986.5212099187], [2017820.7715675107, 769192.5499999991, 1248628.221567513], [1308918.69657439, 130273.45000000019, 1178645.2465743916], [2220659.333898793, 706639.1499999999, 1514020.1838987907], [1237430.2802854627, 97436.6499999996, 1139993.6302854628], [1898084.773822241, 479470.4999999997, 1418614.273822241], [2154895.061392007, 742267.5000000003, 1412627.561392008], [1803298.5260190384, 635979.4499999993, 1167319.0760190387], [1447247.50562701, 234336.75000000035, 1212910.7556270119], [1631620.9643655466, 368101.19999999995, 1263519.7643655483], [1999763.0019891644, 533886.0499999997, 1465876.9519891646], [1457820.2786856075, 249806.45000000048, 1208013.8286856064], [2020136.4100710968, 545847.4999999993, 1474288.9100710945], [1163834.836884194, 41996.7499999996, 1121838.086884192], [1238964.4581287415, 96317.20000000007, 1142647.2581287404], [1437747.0932581993, 287616.35, 1150130.7432581983], [1566541.5709856588, 405164.8999999998, 1161376.6709856591], [1509293.3254719304, 359665.0499999998, 1149628.2754719283], [1297373.7301543094, 151410.70000000042, 1145963.0301543116], [1405426.9459747123, 189021.29999999996, 1216405.645974715], [1198870.6946870007, 65117.59999999998, 1133753.0946869985], [1814518.1298424345, 513286.34999999986, 1301231.7798424335], [2169886.067655321, 661884.9499999991, 1508001.1176553192], [1539339.5947496793, 260098.25000000026, 1279241.3447496807], [1365475.78395974, 187106.8999999998, 1178368.8839597413], [1518634.831625204, 278435.65, 1240199.1816252072], [1859640.3557100073, 488679.1499999997, 1370961.2057100073], [1515939.2938524336, 349259.1, 1166680.1938524349], [2137147.072267802, 637110.0499999993, 1500037.0222678003], [1703328.0141985677, 462739.94999999955, 1240588.0641985696], [1860524.2756746653, 658907.2999999997, 1201616.9756746644], [1261673.994554832, 97436.6499999996, 1164237.3445548308], [1968789.5869695325, 584831.1999999997, 1383958.3869695314]]
[[1818407.3053817034, 567300.8499999985, 1251106.4553817029], [2095566.7501360397, 691357.7000000007, 1404209.0501360365], [1605025.409779002, 245018.35000000003, 1360007.0597790014], [2375469.2457479383, 703022.2500000002, 1672446.9957479371], [1665083.711496073, 484887.7499999998, 1180195.9614960733], [2297513.6946447385, 736576.8999999997, 1560936.7946447378], [1385926.3735346957, 41996.7499999996, 1343929.6235346948], [2041441.4915785631, 653881.9, 1387559.5915785609], [2083442.6804198117, 479470.4999999997, 1603972.1804198106], [1691113.3191208164, 588303.5999999996, 1102809.7191208166], [1851142.8405720224, 535249.5499999993, 1315893.2905720216], [1741293.0001904876, 343270.20000000024, 1398022.800190486], [1879936.5608011307, 245369.8000000003, 1634566.7608011297], [1702396.233543002, 462910.2999999993, 1239485.9335430022], [2116706.0426659025, 486100.49999999994, 1630605.5426659014], [1722438.6219799167, 431458.39999999944, 1290980.2219799163], [2085642.5949703227, 778573.2, 1307069.394970322], [1731501.4034523037, 345350.9000000002, 1386150.5034523038], [1236851.7976603634, 130273.45000000019, 1106578.3476603641], [1774126.3085398579, 304867.34999999934, 1469258.958539856], [2170032.3695437214, 698412.0499999995, 1471620.3195437186], [2019382.5335861023, 552497.8499999999, 1466884.683586103], [2085511.089712258, 611803.5499999989, 1473707.5397122572], [1465731.2135984967, 0.0, 1465731.2135984967], [2105171.3335572667, 414985.99999999977, 1690185.3335572653], [1455010.032569469, 384251.0500000003, 1070758.9825694694], [1031803.0655691817, 149118.40000000052, 882684.6655691823], [1868296.1829628411, 462739.94999999955, 1405556.2329628405], [1831258.6457647586, 221248.04999999978, 1610010.5957647602], [1733708.3951946963, 338460.64999999985, 1395247.745194696], [1731648.6566683897, 210329.0499999994, 1521319.6066683868], [1294032.6926841806, 206835.54999999987, 1087197.14268418], [1916203.6789502339, 718361.0499999991, 1197842.6289502329], [1789484.6210822805, 468867.34999999957, 1320617.2710822807], [1823980.8070431123, 403782.3999999997, 1420198.407043112], [1850851.4619748245, 523867.35, 1326984.1119748256], [2073195.0217415423, 746600.1499999999, 1326594.871741542], [2007459.4361990723, 345350.9000000002, 1662108.5361990735], [1835789.9693759938, 486226.14999999973, 1349563.8193759918], [2228739.4620687487, 482491.9999999995, 1746247.462068747], [922926.2230159354, 41996.7499999996, 880929.4730159368], [2012483.5390033901, 669757.7999999996, 1342725.7390033877], [2018112.3962451268, 726169.8499999994, 1291942.5462451247], [1852626.201133668, 220336.39999999997, 1632289.801133667], [2129645.849717973, 700240.8999999994, 1429404.9497179692], [1960860.242927862, 401894.4499999994, 1558965.7929278617], [1901700.9146821392, 41996.7499999996, 1859704.1646821373], [1578026.5788402315, 0.0, 1578026.5788402315], [1956146.1045717988, 302472.1499999998, 1653673.9545717963], [1824130.5067288433, 483469.00000000023, 1340661.5067288415], [1848859.4836831454, 244059.60000000003, 1604799.8836831418], [2173897.416003733, 529605.4499999993, 1644291.9660037328], [1882487.8778494531, 183817.00000000012, 1698670.877849451], [1660618.4085550539, 426019.2999999993, 1234599.1085550538], [1971120.5732186716, 455001.94999999914, 1516118.6232186714], [1523246.584818056, 445970.70000000007, 1077275.8848180552], [2097884.0050078705, 561071.749999999, 1536812.255007871], [2010600.481167953, 616975.8499999993, 1393624.6311679552], [1194882.0379213616, 259421.7000000001, 935460.3379213609], [1793796.6827069302, 41996.7499999996, 1751799.9327069283], [1878374.4993382639, 150540.80000000086, 1727833.6993382624], [1277561.6208190853, 326907.6999999997, 950653.9208190845], [1855969.8639992895, 517772.4499999993, 1338197.4139992876], [1970891.1266973442, 753411.9999999994, 1217479.1266973414], [1530641.057392352, 403782.3999999997, 1126858.6573923528], [1923390.3207969544, 160739.35000000094, 1762650.9707969557], [2138619.1494022813, 721576.0500000005, 1417043.0994022824], [2182670.850780857, 614903.6499999997, 1567767.200780854], [2065002.6987270447, 782550.9499999997, 1282451.7487270455], [1846722.5636398713, 128061.00000000028, 1718661.5636398704], [2229517.7348167533, 714692.8999999999, 1514824.8348167508], [1356446.9028614084, 96177.94999999969, 1260268.952861408], [1818691.8421256542, 477109.44999999984, 1341582.3921256526], [2471195.719914272, 742267.5000000003, 1728928.21991427], [2012178.3578982272, 631809.5499999986, 1380368.8078982288], [1734903.5873238393, 249806.45000000048, 1485097.137323837], [1723927.494282397, 371208.1, 1352719.3942823973], [2029442.6388001824, 545847.4999999993, 1483595.1388001805], [1702272.6736356828, 249806.45000000048, 1452466.2236356807], [2195485.93466177, 540804.5999999995, 1654681.3346617671], [814013.4377075145, 41996.7499999996, 772016.6877075152], [1577368.9768372776, 96317.20000000007, 1481051.7768372786], [1262638.2062310996, 287616.35, 975021.8562310992], [1651561.4020118439, 411699.3999999995, 1239862.0020118437], [1249725.445116832, 363596.6000000001, 886128.8451168317], [1273484.8544539022, 149118.40000000052, 1124366.4544539019], [1756272.1901596054, 189481.24999999985, 1566790.9401596077], [1290716.1679523732, 71330.50000000022, 1219385.6679523732], [1747699.7995774741, 517378.7499999999, 1230321.0495774741], [2222087.520694771, 661373.5999999994, 1560713.9206947673], [1943097.1077714844, 255404.1000000002, 1687693.0077714825], [1584860.5138963985, 183292.3500000003, 1401568.1638963972], [1846418.1895383096, 294926.04999999964, 1551492.13953831], [1791871.583355315, 488679.1499999997, 1303192.433355315], [1412125.7434163373, 338164.2999999996, 1073961.4434163366], [2148479.6939730523, 631506.7000000007, 1516972.993973051], [1781010.0393681747, 461940.9499999995, 1319069.0893681757], [2018840.3244458772, 677070.9499999989, 1341769.3744458766], [1969463.587147334, 97237.2999999998, 1872226.2871473338], [2070204.5112548927, 567404.2499999993, 1502800.2612548918]]

In [11]:
with open("/home/merinom/Desktop/GreenSOBA/results/sens/people.csv", 'w') as csvfile1, open("/home/merinom/Desktop/GreenSOBA/results/sens/temperature.csv", "w") as csvfile2, open("/home/merinom/Desktop/GreenSOBA/results/sens/behaviour.csv", 'w') as csvfile3, open("/home/merinom/Desktop/GreenSOBA/results/sens/tempIn.csv", 'w') as csvfile4:
    wr = csv.writer(csvfile1, quoting=csv.QUOTE_ALL)
    wr.writerow(people)
    wr = csv.writer(csvfile2, quoting=csv.QUOTE_ALL)
    wr.writerow(temperature)
    wr = csv.writer(csvfile3, quoting=csv.QUOTE_ALL)
    wr.writerow(behaviour)
    wr = csv.writer(csvfile4, quoting=csv.QUOTE_ALL)
    wr.writerow(tempIn)
    
with open("/home/merinom/Desktop/GreenSOBA/results/sens/EnergyLE0.csv", 'w') as csvfile1, open("/home/merinom/Desktop/GreenSOBA/results/sens/EnergyHVAC0.csv", "w") as csvfile2, open("/home/merinom/Desktop/GreenSOBA/results/sens/EnergyTotal0.csv", 'w') as csvfile3:
    wr = csv.writer(csvfile1, quoting=csv.QUOTE_ALL)
    wr.writerow(EnergyLE0)
    wr = csv.writer(csvfile2, quoting=csv.QUOTE_ALL)
    wr.writerow(EnergyHVAC0)
    wr = csv.writer(csvfile3, quoting=csv.QUOTE_ALL)
    wr.writerow(EnergyTotal0)
    
with open("/home/merinom/Desktop/GreenSOBA/results/sens/EnergyLE1.csv", 'w') as csvfile1, open("/home/merinom/Desktop/GreenSOBA/results/sens/EnergyHVAC1.csv", "w") as csvfile2, open("/home/merinom/Desktop/GreenSOBA/results/sens/EnergyTotal1.csv", 'w') as csvfile3:
    wr = csv.writer(csvfile1, quoting=csv.QUOTE_ALL)
    wr.writerow(EnergyLE1)
    wr = csv.writer(csvfile2, quoting=csv.QUOTE_ALL)
    wr.writerow(EnergyHVAC1)
    wr = csv.writer(csvfile3, quoting=csv.QUOTE_ALL)
    wr.writerow(EnergyTotal1)
    
with open("/home/merinom/Desktop/GreenSOBA/results/sens/EnergyLE2.csv", 'w') as csvfile1, open("/home/merinom/Desktop/GreenSOBA/results/sens/EnergyHVAC2.csv", "w") as csvfile2, open("/home/merinom/Desktop/GreenSOBA/results/sens/EnergyTotal2.csv", 'w') as csvfile3:
    wr = csv.writer(csvfile1, quoting=csv.QUOTE_ALL)
    wr.writerow(EnergyLE2)
    wr = csv.writer(csvfile2, quoting=csv.QUOTE_ALL)
    wr.writerow(EnergyHVAC2)
    wr = csv.writer(csvfile3, quoting=csv.QUOTE_ALL)
    wr.writerow(EnergyTotal2)

In [3]:
with open("/home/merinom/Desktop/GreenSOBA/results/sens/people.csv", 'r') as csvfile1, open("/home/merinom/Desktop/GreenSOBA/results/sens/temperature.csv", "r") as csvfile2, open("/home/merinom/Desktop/GreenSOBA/results/sens/behaviour.csv", 'r') as csvfile3, open("/home/merinom/Desktop/GreenSOBA/results/sens/tempIn.csv", 'r') as csvfile4:
    readCSV = csv.reader(csvfile1)
    people = list(readCSV)
    readCSV = csv.reader(csvfile2)
    temperature = list(readCSV)
    readCSV = csv.reader(csvfile3)
    behaviour = list(readCSV)
    readCSV = csv.reader(csvfile4)
    tempIn = list(readCSV)

with open("/home/merinom/Desktop/GreenSOBA/results/sens/EnergyLE0.csv", 'r') as csvfile1, open("/home/merinom/Desktop/GreenSOBA/results/sens/EnergyHVAC0.csv", "r") as csvfile2, open("/home/merinom/Desktop/GreenSOBA/results/sens/EnergyTotal0.csv", 'r') as csvfile3:
    readCSV = csv.reader(csvfile1)
    EnergyLE0 = list(readCSV)
    readCSV = csv.reader(csvfile2)
    EnergyHVAC0 = list(readCSV)
    readCSV = csv.reader(csvfile3)
    EnergyTotal0 = list(readCSV)
    
with open("/home/merinom/Desktop/GreenSOBA/results/sens/EnergyLE1.csv", 'r') as csvfile1, open("/home/merinom/Desktop/GreenSOBA/results/sens/EnergyHVAC1.csv", "r") as csvfile2, open("/home/merinom/Desktop/GreenSOBA/results/sens/EnergyTotal1.csv", 'r') as csvfile3:
    readCSV = csv.reader(csvfile1)
    EnergyLE1 = list(readCSV)
    readCSV = csv.reader(csvfile2)
    EnergyHVAC1 = list(readCSV)
    readCSV = csv.reader(csvfile3)
    EnergyTotal1 = list(readCSV)
    
with open("/home/merinom/Desktop/GreenSOBA/results/sens/EnergyLE2.csv", 'r') as csvfile1, open("/home/merinom/Desktop/GreenSOBA/results/sens/EnergyHVAC2.csv", "r") as csvfile2, open("/home/merinom/Desktop/GreenSOBA/results/sens/EnergyTotal2.csv", 'r') as csvfile3:
    readCSV = csv.reader(csvfile1)
    EnergyLE2 = list(readCSV)
    readCSV = csv.reader(csvfile2)
    EnergyHVAC2 = list(readCSV)
    readCSV = csv.reader(csvfile3)
    EnergyTotal2 = list(readCSV)

import re

temperature1 = []
temperature2 = []
for i in temperature[0]:
    iList = list(map(int, re.findall(r'\d+', i)))
    temperature1.append(iList[0])
    temperature2.append(iList[1])


behaviour1 = []
behaviour2 = []
behaviour3 = []
for i in behaviour[0]:
    iList = list(map(int, re.findall(r'\d+', i)))
    behaviour1.append(iList[0])
    behaviour2.append(iList[1])
    behaviour3.append(iList[2])

In [4]:
behaviour = []
temperature = []
for n in range(0, len(behaviour1)):
    behaviour.append((behaviour1[n] + behaviour2[n] + behaviour3[n])/3)

for n in range(len(temperature1)):
    temperature.append((temperature1[n] + temperature2[n])/2)

In [20]:
# Model 0
# LE
plt.figure(figsize = (20,6))
plt.subplot(161)
plt.scatter(people, EnergyLE0)
plt.title("Nº Occupants")
plt.ylabel("LE Comsumption (kWh)")
plt.subplot(162)
plt.scatter(behaviour3, EnergyLE0)
plt.title("% Bad behaviour")
plt.subplot(163)
plt.scatter(behaviour2, EnergyLE0)
plt.title("% Medium behaviour")
plt.subplot(164)
plt.scatter(behaviour1, EnergyLE0)
plt.title("% Good behaviour")
plt.subplot(165)
plt.scatter(temperature1, EnergyLE0)
plt.title("Tra min")
plt.subplot(166)
plt.scatter(temperature2, EnergyLE0)
plt.title("Tra max")
plt.show()
# HVAC
plt.figure(figsize = (20,6))
plt.subplot(161)
plt.scatter(people, EnergyHVAC0)
plt.title("Nº Occupants")
plt.ylabel("HVAC Comsumption (kWh)")
plt.subplot(162)
plt.scatter(behaviour3, EnergyHVAC0)
plt.title("% Bad behaviour")
plt.subplot(163)
plt.scatter(behaviour2, EnergyHVAC0)
plt.title("% Medium behaviour")
plt.subplot(164)
plt.scatter(behaviour1, EnergyHVAC0)
plt.title("% Good behaviour")
plt.subplot(165)
plt.scatter(temperature1, EnergyHVAC0)
plt.title("Tra min")
plt.subplot(166)
plt.scatter(temperature2, EnergyHVAC0)
plt.title("Tra max")
plt.show()
# TOTAL
plt.figure(figsize = (20,6))
plt.subplot(161)
plt.scatter(people, EnergyTotal0)
plt.title("Nº Occupants")
plt.ylabel("Total Comsumption (kWh)")
plt.subplot(162)
plt.scatter(behaviour3, EnergyTotal0)
plt.title("% Bad behaviour")
plt.subplot(163)
plt.scatter(behaviour2, EnergyTotal0)
plt.title("% Medium behaviour")
plt.subplot(164)
plt.scatter(behaviour1, EnergyTotal0)
plt.title("% Good behaviour")
plt.subplot(165)
plt.scatter(temperature1, EnergyTotal0)
plt.title("Tra min")
plt.subplot(166)
plt.scatter(temperature2, EnergyTotal0)
plt.title("Tra max")
plt.show()


# Model 1
# LE
plt.figure(figsize = (20,6))
plt.subplot(161)
plt.scatter(people, EnergyLE1)
plt.title("Nº Occupants")
plt.ylabel("LE Comsumption (kWh)")
plt.subplot(162)
plt.scatter(behaviour3, EnergyLE1)
plt.title("% Bad behaviour")
plt.subplot(163)
plt.scatter(behaviour2, EnergyLE1)
plt.title("% Medium behaviour")
plt.subplot(164)
plt.scatter(behaviour1, EnergyLE1)
plt.title("% Good behaviour")
plt.subplot(165)
plt.scatter(temperature1, EnergyLE1)
plt.title("Tra min")
plt.subplot(166)
plt.scatter(temperature2, EnergyLE1)
plt.title("Tra max")
plt.show()
# HVAC
plt.figure(figsize = (20,6))
plt.subplot(161)
plt.scatter(people, EnergyHVAC1)
plt.title("Nº Occupants")
plt.ylabel("HVAC Comsumption (kWh)")
plt.subplot(162)
plt.scatter(behaviour3, EnergyHVAC1)
plt.title("% Bad behaviour")
plt.subplot(163)
plt.scatter(behaviour2, EnergyHVAC1)
plt.title("% Medium behaviour")
plt.subplot(164)
plt.scatter(behaviour1, EnergyHVAC1)
plt.title("% Good behaviour")
plt.subplot(165)
plt.scatter(temperature1, EnergyHVAC1)
plt.title("Tra min")
plt.subplot(166)
plt.scatter(temperature2, EnergyHVAC1)
plt.title("Tra max")
plt.show()
# TOTAL
plt.figure(figsize = (20,6))
plt.subplot(161)
plt.scatter(people, EnergyTotal1)
plt.title("Nº Occupants")
plt.ylabel("Total Comsumption (kWh)")
plt.subplot(162)
plt.scatter(behaviour3, EnergyTotal1)
plt.title("% Bad behaviour")
plt.subplot(163)
plt.scatter(behaviour2, EnergyTotal1)
plt.title("% Medium behaviour")
plt.subplot(164)
plt.scatter(behaviour1, EnergyTotal1)
plt.title("% Good behaviour")
plt.subplot(165)
plt.scatter(temperature1, EnergyTotal1)
plt.title("Tra min")
plt.subplot(166)
plt.scatter(temperature2, EnergyTotal1)
plt.title("Tra max")
plt.show()

# Model 2
# LE
plt.figure(figsize = (20,6))
plt.subplot(161)
plt.scatter(people, EnergyLE2)
plt.title("Nº Occupants")
plt.ylabel("LE Comsumption (kWh)")
plt.subplot(162)
plt.scatter(behaviour3, EnergyLE2)
plt.title("% Bad behaviour")
plt.subplot(163)
plt.scatter(behaviour2, EnergyLE2)
plt.title("% Medium behaviour")
plt.subplot(164)
plt.scatter(behaviour1, EnergyLE2)
plt.title("% Good behaviour")
plt.subplot(165)
plt.scatter(temperature1, EnergyLE2)
plt.title("Tra min")
plt.subplot(166)
plt.scatter(temperature2, EnergyLE2)
plt.title("Tra max")
plt.show()
# HVAC
plt.figure(figsize = (40,6))
plt.subplot(161)
plt.scatter(people, EnergyHVAC2)
plt.title("Nº Occupants")
plt.ylabel("HVAC Comsumption (kWh)")
plt.subplot(162)
plt.scatter(behaviour3, EnergyHVAC2)
plt.title("% Bad behaviour")
plt.subplot(163)
plt.scatter(behaviour2, EnergyHVAC2)
plt.title("% Medium behaviour")
plt.subplot(164)
plt.scatter(behaviour1, EnergyHVAC2)
plt.title("% Good behaviour")
plt.subplot(165)
plt.scatter(temperature1, EnergyHVAC2)
plt.title("Tra min")
plt.subplot(166)
plt.scatter(temperature2, EnergyHVAC2)
plt.title("Tra max")
plt.show()
# TOTAL
plt.figure(figsize = (20,6))
plt.subplot(161)
plt.scatter(people, EnergyTotal2)
plt.title("Nº Occupants")
plt.ylabel("Total Comsumption (kWh)")
plt.subplot(162)
plt.scatter(behaviour3, EnergyTotal2)
plt.title("% Bad behaviour")
plt.subplot(163)
plt.scatter(behaviour2, EnergyTotal2)
plt.title("% Medium behaviour")
plt.subplot(164)
plt.scatter(behaviour1, EnergyTotal2)
plt.title("% Good behaviour")
plt.subplot(165)
plt.scatter(temperature1, EnergyTotal2)
plt.title("Tra min")
plt.subplot(166)
plt.scatter(temperature2, EnergyTotal2)
plt.title("Tra max")
plt.show()




# Model 0
# LE
plt.figure(figsize = (20,6))
plt.subplot(131)
plt.scatter(tempIn, EnergyLE0)
plt.title("Temperature In")
plt.ylabel("LE Comsumption (kWh)")
plt.subplot(132)
plt.scatter(behaviour, EnergyLE0)
plt.title("% Behaviour")
plt.subplot(133)
plt.scatter(temperature, EnergyLE0)
plt.title("Temperature desired")
plt.show()
# HVAC
plt.figure(figsize = (20,6))
plt.subplot(131)
plt.scatter(tempIn, EnergyHVAC0)
plt.title("Temperature In")
plt.ylabel("HVAC Comsumption (kWh)")
plt.subplot(132)
plt.scatter(behaviour, EnergyHVAC0)
plt.title("% Behaviour")
plt.subplot(133)
plt.scatter(temperature, EnergyHVAC0)
plt.title("Temperature desired")
plt.show()
# TOTAL
plt.figure(figsize = (20,6))
plt.subplot(131)
plt.scatter(tempIn, EnergyTotal0)
plt.title("Temperature In")
plt.ylabel("Total Comsumption (kWh)")
plt.subplot(132)
plt.scatter(behaviour, EnergyTotal0)
plt.title("% Behaviour")
plt.subplot(133)
plt.scatter(temperature, EnergyTotal0)
plt.title("Temperature desired")
plt.show()



# Model 1
# LE
plt.figure(figsize = (20,6))
plt.subplot(131)
plt.scatter(tempIn, EnergyLE1)
plt.title("Temperature In")
plt.ylabel("LE Comsumption (kWh)")
plt.subplot(132)
plt.scatter(behaviour, EnergyLE1)
plt.title("% Behaviour")
plt.subplot(133)
plt.scatter(temperature, EnergyLE1)
plt.title("Temperature desired")
plt.show()

# HVAC
plt.figure(figsize = (20,6))
plt.subplot(131)
plt.scatter(tempIn, EnergyHVAC1)
plt.title("Temperature In")
plt.ylabel("HVAC Comsumption (kWh)")
plt.subplot(132)
plt.scatter(behaviour, EnergyHVAC1)
plt.title("% Behaviour")
plt.subplot(133)
plt.scatter(temperature, EnergyHVAC1)
plt.title("Temperature desired")
plt.show()


# TOTAL
plt.figure(figsize = (20,6))
plt.subplot(131)
plt.scatter(tempIn, EnergyTotal1)
plt.title("Temperature In")
plt.ylabel("Total Comsumption (kWh)")
plt.subplot(132)
plt.scatter(behaviour, EnergyTotal1)
plt.title("% Behaviour")
plt.subplot(133)
plt.scatter(temperature, EnergyTotal1)
plt.title("Temperature desired")
plt.show()



# Model 2
# LE
plt.figure(figsize = (20,6))
plt.subplot(131)
plt.scatter(tempIn, EnergyLE2)
plt.title("Temperature In")
plt.ylabel("LE Comsumption (kWh)")
plt.subplot(132)
plt.scatter(behaviour, EnergyLE2)
plt.title("% Behaviour")
plt.subplot(133)
plt.scatter(temperature, EnergyLE2)
plt.title("Temperature desired")
plt.show()
# HVAC
plt.figure(figsize = (20,6))
plt.subplot(131)
plt.scatter(tempIn, EnergyHVAC2)
plt.title("Temperature In")
plt.ylabel("HVAC Comsumption (kWh)")
plt.subplot(132)
plt.scatter(behaviour, EnergyHVAC2)
plt.title("% Behaviour")
plt.subplot(133)
plt.scatter(temperature, EnergyHVAC2)
plt.title("Temperature desired")
plt.show()


# TOTAL
plt.figure(figsize = (20,6))
plt.subplot(131)
plt.scatter(tempIn, EnergyTotal2)
plt.title("Temperature In")
plt.ylabel("Total Comsumption (kWh)")
plt.subplot(132)
plt.scatter(behaviour, EnergyTotal2)
plt.title("% Behaviour")
plt.subplot(133)
plt.scatter(temperature, EnergyTotal2)
plt.title("Temperature desired")
plt.show()


#plt.savefig('scatter.png')



In [5]:
import matplotlib.pyplot as plt
import numpy as np

people = list(map(int, people[0]))
tempIn = list(map(int, tempIn[0]))
##behaviour1 = list(map(int, behaviour1[0]))
##behaviour3 = list(map(int, behaviour3[0]))
##temperature1 = list(map(int, temperature1[0]))
##temperature2 = list(map(int, temperature2[0]))
##temperature = list(map(int, temperature[0]))
EnergyLE0 = [int(i.split('.')[0]) for i in EnergyLE0[0]]
EnergyLE1 = [int(i.split('.')[0]) for i in EnergyLE1[0]]
EnergyLE2 = [int(i.split('.')[0]) for i in EnergyLE2[0]]
EnergyHVAC0 = [int(i.split('.')[0]) for i in EnergyHVAC0[0]]
EnergyHVAC1 = [int(i.split('.')[0]) for i in EnergyHVAC1[0]]
EnergyHVAC2 = [int(i.split('.')[0]) for i in EnergyHVAC2[0]]
EnergyTotal0 = [int(i.split('.')[0]) for i in EnergyTotal0[0]]
EnergyTotal1 = [int(i.split('.')[0]) for i in EnergyTotal1[0]]
EnergyTotal2 = [int(i.split('.')[0]) for i in EnergyTotal2[0]]

In [6]:
people = [i*2 for i in people]

In [21]:
########################
####Para el articulo####
########################

# Model 0
# LE
plt.figure(figsize = (20,3))
plt.subplot(161)
plt.title("Nº Occupants")
plt.ylabel("LE Comsumption (kWh), Model 0")
fit = np.polyfit(people,EnergyLE0,1)
fit_fn = np.poly1d(fit)
plt.plot(people, EnergyLE0,'bo', people, fit_fn(people), 'k', linewidth=0.7)
plt.show()
# HVAC
plt.figure(figsize = (20,3))
plt.subplot(161)
plt.title("Nº Occupants")
plt.ylabel("HVAC Comsumption (kWh), Model 0")
fit = np.polyfit(people,EnergyHVAC0,1)
fit_fn = np.poly1d(fit) 
plt.plot(people, EnergyHVAC0, 'bo', people, fit_fn(people),'k', linewidth=0.7)
plt.show()
plt.figure(figsize = (20,3))
plt.subplot(161)
plt.title("Temperature In")
plt.ylabel("HVAC Comsumption (kWh), Model 0")
fit = np.polyfit(tempIn,EnergyHVAC0,1)
fit_fn = np.poly1d(fit) 
plt.plot(tempIn, EnergyHVAC0, 'bo', tempIn, fit_fn(tempIn),'k', linewidth=0.7)
plt.show()

# Model 1
# LE
plt.figure(figsize = (20,3))
plt.subplot(161)
plt.title("Nº Occupants")
plt.ylabel("LE Comsumption (kWh), Model 1")
fit = np.polyfit(people,EnergyLE1,1)
fit_fn = np.poly1d(fit) 
plt.plot(people, EnergyLE1, 'bo', people, fit_fn(people),'k', linewidth=0.7)
plt.show()
# HVAC
plt.figure(figsize = (20,3))
plt.subplot(161)
plt.title("Nº Occupants")
plt.ylabel("HVAC Comsumption (kWh), Model 1")
fit = np.polyfit(people,EnergyHVAC1,1)
fit_fn = np.poly1d(fit) 
plt.plot(people, EnergyHVAC1, 'bo', people, fit_fn(people),'k', linewidth=0.7)
plt.show()

# Model 2
# HVAC
plt.figure(figsize = (20,3))
plt.subplot(161)
plt.title("Temperature desired")
plt.ylabel("HVAC Comsumption (kWh), Model 2")
fit = np.polyfit(tempIn,EnergyHVAC2,1)
fit_fn = np.poly1d(fit) 
plt.plot(tempIn, EnergyHVAC2, 'bo', tempIn, fit_fn(tempIn),'k', linewidth=0.7)
plt.show()
# TOTAL
plt.figure(figsize = (20,3))
plt.subplot(161)
plt.title("Nº Occupants")
plt.ylabel("Total Comsumption (kWh), Model 2")
fit = np.polyfit(people,EnergyTotal2,1)
fit_fn = np.poly1d(fit)
plt.plot(people, EnergyTotal2, 'bo', people, fit_fn(people),'k', linewidth=0.7)
plt.show()



In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [13]:
#Eliminar Deseada
morris_problem = {

    'num_vars': 5,

    'names': ['People', 'DesTemperature', 'tempIn', 
              'GoodBehaviour', 'BadBehaviour'],

    'bounds': [
            [0, 40],
            [18, 30],
            [18, 30],
            [0, 100],
            [0, 100]
              ],

    'groups': None

    }

In [14]:
sample = ms.sample(morris_problem, 10, num_levels=4, grid_jump=2)

In [7]:
output = []
for n in range(len(sample)):
    data = sample[n]
    m = 0 if ((100 - (int(data[3]) + int(data[4])))<0) else (100 - (int(data[3]) + int(data[4])))
    a = [int(data[0]), [int(data[1]), int(data[1])], [int(data[3]), m, int(data[4])], int(data[2])]
    print(a)
    y = energy_model(a, 0)
    output.append(y)
    
output2 = []
for i in range(len(output)):
    output2.append(output[i][0])
output2 = np.array(output2, dtype=np.float32)

Si = ma.analyze(morris_problem, sample, output2, print_to_console=False)
print("{:20s} {:>7s} {:>7s} {:>7s}".format("Name", "mu", "mu_star", "sigma"))
for name, s1, st, mean in zip(morris_problem['names'], 
                              Si['mu'], 
                              Si['mu_star'], 
                              Si['sigma']):

    print("{:20s} {:=7.2f} {:=7.2f} {:=7.2f}".format(name, s1, st, mean))

fig, (ax1, ax2) = plt.subplots(1,2)
mp.horizontal_bar_plot(ax1, Si, {})
mp.covariance_plot(ax2, Si, {})


[13, [26, 26], [100, 0, 0], 22]
¡Cambio de valores!
2100292.314847817
2100292.31485
439056.00000000163
439056.0
1661236.3148478188
1661236.31485
[40, [26, 26], [100, 0, 0], 22]
¡Cambio de valores!
2514508.5102523286
2514508.51025
809871.2999999991
809871.3
1704637.2102523302
1704637.21025
[40, [26, 26], [33, 67, 0], 22]
¡Cambio de valores!
2611143.938568659
2611143.93857
899349.3000000016
899349.3
1711794.6385686619
1711794.63857
[40, [18, 18], [33, 67, 0], 22]
¡Cambio de valores!
2664549.253649003
2664549.25365
945502.5499999986
945502.55
1719046.703649009
1719046.70365
[40, [18, 18], [33, 1, 66], 22]
¡Cambio de valores!
2698378.777221712
2698378.77722
978898.3000000003
978898.3
1719480.4772217302
1719480.47722
[40, [18, 18], [33, 1, 66], 30]
¡Cambio de valores!
1955434.3697333066
1955434.36973
1009732.6499999964
1009732.65
945701.7197333165
945701.719733
[40, [18, 18], [0, 34, 66], 18]
¡Cambio de valores!
3144178.854326148
3144178.85433
1076824.0499999989
1076824.05
2067354.8043261582
2067354.80433
[40, [26, 26], [0, 34, 66], 18]
¡Cambio de valores!
3117601.725133099
3117601.72513
1067704.9999999937
1067705.0
2049896.7251331182
2049896.72513
[40, [26, 26], [0, 100, 0], 18]
¡Cambio de valores!
3037259.6893944954
3037259.68939
985407.200000002
985407.2
2051852.4893945013
2051852.48939
[40, [26, 26], [0, 100, 0], 26]
¡Cambio de valores!
2383399.699900832
2383399.6999
1001121.0500000023
1001121.05
1382278.6499008276
1382278.6499
[13, [26, 26], [0, 100, 0], 26]
¡Cambio de valores!
1676489.5706895774
1676489.57069
394825.80000000144
394825.8
1281663.770689579
1281663.77069
[13, [26, 26], [66, 34, 0], 26]
¡Cambio de valores!
1620424.4781488022
1620424.47815
345114.75000000006
345114.75
1275309.7281488036
1275309.72815
[26, [22, 22], [100, 0, 0], 22]
¡Cambio de valores!
2213881.9037584607
2213881.90376
525224.4499999995
525224.45
1688657.4537584647
1688657.45376
[26, [22, 22], [33, 67, 0], 22]
¡Cambio de valores!
2302793.885161305
2302793.88516
623668.3500000028
623668.35
1679125.5351613034
1679125.53516
[26, [30, 30], [33, 67, 0], 22]
¡Cambio de valores!
2305127.7308426653
2305127.73084
617468.8000000002
617468.8
1687658.930842657
1687658.93084
[26, [30, 30], [33, 67, 0], 30]
¡Cambio de valores!
1558532.9483754167
1558532.94838
668143.3500000002
668143.35
890389.5983754154
890389.598375
[0, [30, 30], [33, 67, 0], 30]
¡Cambio de valores!
802012.6227059508
802012.622706
0.0
0.0
802012.6227059508
802012.622706
[0, [30, 30], [33, 1, 66], 30]
¡Cambio de valores!
802012.6227059508
802012.622706
0.0
0.0
802012.6227059508
802012.622706
[26, [18, 18], [0, 100, 0], 18]
¡Cambio de valores!
2750670.8282772293
2750670.82828
707236.1999999997
707236.2
2043434.6282772184
2043434.62828
[26, [18, 18], [66, 34, 0], 18]
¡Cambio de valores!
2629946.071732609
2629946.07173
590228.0499999998
590228.05
2039718.0217326074
2039718.02173
[26, [18, 18], [66, 34, 0], 26]
¡Cambio de valores!
1959241.0370435603
1959241.03704
628420.3499999992
628420.35
1330820.6870435646
1330820.68704
[26, [26, 26], [66, 34, 0], 26]
¡Cambio de valores!
1987793.2598083494
1987793.25981
652813.7499999984
652813.75
1334979.5098083406
1334979.50981
[26, [26, 26], [66, 0, 66], 26]
¡Cambio de valores!
2168023.7771154167
2168023.77712
807133.8500000018
807133.85
1360889.927115417
1360889.92712
[0, [26, 26], [66, 0, 66], 26]
¡Cambio de valores!
1233834.7541640291
1233834.75416
0.0
0.0
1233834.7541640291
1233834.75416
[26, [18, 18], [66, 34, 0], 26]
¡Cambio de valores!
1892827.0342753548
1892827.03428
567700.7999999991
567700.8
1325126.2342753569
1325126.23428
[26, [18, 18], [66, 34, 0], 18]
¡Cambio de valores!
2651637.4678662773
2651637.46787
611028.800000003
611028.8
2040608.667866271
2040608.66787
[26, [18, 18], [0, 100, 0], 18]
¡Cambio de valores!
2760373.6614317903
2760373.66143
711957.1000000031
711957.1
2048416.5614317888
2048416.56143
[0, [18, 18], [0, 100, 0], 18]
¡Cambio de valores!
2011597.6459836927
2011597.64598
0.0
0.0
2011597.6459836927
2011597.64598
[0, [18, 18], [0, 34, 66], 18]
¡Cambio de valores!
2011597.6459836927
2011597.64598
0.0
0.0
2011597.6459836927
2011597.64598
[0, [26, 26], [0, 34, 66], 18]
¡Cambio de valores!
2011597.6459836927
2011597.64598
0.0
0.0
2011597.6459836927
2011597.64598
[40, [22, 22], [33, 67, 0], 30]
¡Cambio de valores!
1851661.7800210249
1851661.78002
916094.2500000041
916094.25
935567.5300210273
935567.530021
[40, [22, 22], [100, 0, 0], 30]
¡Cambio de valores!
1738078.622326949
1738078.62233
811455.1500000011
811455.15
926623.4723269424
926623.472327
[40, [22, 22], [100, 0, 0], 22]
¡Cambio de valores!
2502936.2668635156
2502936.26686
798371.4499999993
798371.45
1704564.8168635035
1704564.81686
[40, [22, 22], [100, 0, 66], 22]
¡Cambio de valores!
2724602.5979786143
2724602.59798
939830.7000000008
939830.7
1784771.8979786274
1784771.89798
[13, [22, 22], [100, 0, 66], 22]
¡Cambio de valores!
2272645.4904549597
2272645.49045
590439.5000000012
590439.5
1682205.9904549571
1682205.99045
[13, [30, 30], [100, 0, 66], 22]
¡Cambio de valores!
2234549.599803053
2234549.5998
554116.5999999978
554116.6
1680432.9998030465
1680432.9998
[13, [30, 30], [100, 0, 0], 30]
¡Cambio de valores!
1145792.8342559573
1145792.83426
295684.90000000014
295684.9
850107.9342559535
850107.934256
[40, [30, 30], [100, 0, 0], 30]
¡Cambio de valores!
1719514.5817450928
1719514.58175
788684.3999999996
788684.4
930830.181745094
930830.181745
[40, [22, 22], [100, 0, 0], 30]
¡Cambio de valores!
1742427.5866132972
1742427.58661
812558.6000000006
812558.6
929868.9866133056
929868.986613
[40, [22, 22], [100, 0, 0], 22]
¡Cambio de valores!
2484268.9947977713
2484268.9948
784008.2
784008.2
1700260.794797766
1700260.7948
[40, [22, 22], [100, 0, 66], 22]
¡Cambio de valores!
2735883.8059677724
2735883.80597
963350.3000000016
963350.3
1772533.5059677497
1772533.50597
[40, [22, 22], [33, 1, 66], 22]
¡Cambio de valores!
2692843.7614359106
2692843.76144
980340.1999999975
980340.2
1712503.5614359344
1712503.56144
[0, [18, 18], [100, 0, 0], 22]
¡Cambio de valores!
1633042.5121423856
1633042.51214
0.0
0.0
1633042.5121423856
1633042.51214
[26, [18, 18], [100, 0, 0], 22]
¡Cambio de valores!
2202433.2832776564
2202433.28328
514990.6000000002
514990.6
1687442.6832776435
1687442.68328
[26, [26, 26], [100, 0, 0], 22]
¡Cambio de valores!
2249215.521919504
2249215.52192
556528.6999999991
556528.7
1692686.8219195127
1692686.82192
[26, [26, 26], [33, 67, 0], 22]
¡Cambio de valores!
2348772.256350077
2348772.25635
658128.5499999998
658128.55
1690643.7063500679
1690643.70635
[26, [26, 26], [33, 67, 0], 30]
¡Cambio de valores!
1509004.4913302453
1509004.49133
610751.1499999997
610751.15
898253.341330243
898253.34133
[26, [26, 26], [33, 1, 66], 30]
¡Cambio de valores!
1649923.961276038
1649923.96128
745071.900000003
745071.9
904852.0612760361
904852.061276
[26, [26, 26], [0, 100, 0], 26]
¡Cambio de valores!
2058123.7464126952
2058123.74641
721776.3000000026
721776.3
1336347.446412693
1336347.44641
[26, [26, 26], [0, 100, 0], 18]
¡Cambio de valores!
2738630.228849137
2738630.22885
695063.150000002
695063.15
2043567.078849137
2043567.07885
[26, [26, 26], [0, 34, 66], 18]
¡Cambio de valores!
2815226.0399940806
2815226.03999
751575.7499999992
751575.75
2063650.2899940824
2063650.28999
[26, [18, 18], [0, 34, 66], 18]
¡Cambio de valores!
2870924.7163354526
2870924.71634
819989.5500000075
819989.55
2050935.1663354374
2050935.16634
[0, [18, 18], [0, 34, 66], 18]
¡Cambio de valores!
2011597.6459836927
2011597.64598
0.0
0.0
2011597.6459836927
2011597.64598
[0, [18, 18], [66, 0, 66], 18]
¡Cambio de valores!
2011597.6459836927
2011597.64598
0.0
0.0
2011597.6459836927
2011597.64598
[13, [22, 22], [66, 0, 66], 30]
¡Cambio de valores!
1282853.1393302192
1282853.13933
426490.54999999853
426490.55
856362.5893302134
856362.58933
[13, [22, 22], [66, 0, 66], 22]
¡Cambio de valores!
2118551.7831149036
2118551.78311
455754.14999999845
455754.15
1662797.6331149025
1662797.63311
[13, [22, 22], [66, 34, 0], 22]
¡Cambio de valores!
1968176.474573426
1968176.47457
312432.99999999965
312433.0
1655743.4745734222
1655743.47457
[13, [22, 22], [0, 100, 0], 22]
¡Cambio de valores!
2076087.9352458054
2076087.93525
418914.75000000105
418914.75
1657173.1852457984
1657173.18525
[40, [22, 22], [0, 100, 0], 22]
¡Cambio de valores!
2700202.723983719
2700202.72398
980773.3999999985
980773.4
1719429.323983717
1719429.32398
[40, [30, 30], [0, 100, 0], 22]
¡Cambio de valores!
2698736.625085773
2698736.62509
973448.1000000023
973448.1
1725288.5250857708
1725288.52509
Name                      mu mu_star   sigma
People               995868.38 995868.38 252383.17
DesTemperature       -18073.16 41373.64 50489.59
tempIn               -1115338.00 1115338.00 94569.88
GoodBehaviour        -112362.73 125274.73 82131.39
BadBehaviour         170336.03 170336.03 134083.41
Out[7]:
<matplotlib.collections.PathCollection at 0x7f5ea361d6a0>

In [15]:
output = []
for n in range(len(sample)):
    data = sample[n]
    m = 0 if ((100 - (int(data[3]) + int(data[4])))<0) else (100 - (int(data[3]) + int(data[4])))
    a = [int(data[0]), [int(data[1]), int(data[1])], [int(data[3]), m, int(data[4])], int(data[2])]
    print(a)
    y = energy_model(a, 1)
    output.append(y)

output2 = []
for i in range(len(output)):
    output2.append(output[i][0])
output2 = np.array(output2, dtype=np.float32)

Si = ma.analyze(morris_problem, sample, output2, print_to_console=False)
print("{:20s} {:>7s} {:>7s} {:>7s}".format("Name", "mu", "mu_star", "sigma"))
for name, s1, st, mean in zip(morris_problem['names'], 
                              Si['mu'], 
                              Si['mu_star'], 
                              Si['sigma']):
    print("{:20s} {:=7.2f} {:=7.2f} {:=7.2f}".format(name, s1, st, mean))

fig, (ax1, ax2) = plt.subplots(1,2)
mp.horizontal_bar_plot(ax1, Si, {})
mp.covariance_plot(ax2, Si, {})


[0, [18, 18], [66, 34, 0], 26]
¡Cambio de valores!
1122497.1688975748
1122497.1689
0.0
0.0
1122497.1688975748
1122497.1689
[0, [18, 18], [0, 100, 0], 26]
¡Cambio de valores!
1122497.1688975748
1122497.1689
0.0
0.0
1122497.1688975748
1122497.1689
[0, [26, 26], [0, 100, 0], 26]
¡Cambio de valores!
1122497.1688975748
1122497.1689
0.0
0.0
1122497.1688975748
1122497.1689
[26, [26, 26], [0, 100, 0], 26]
¡Cambio de valores!
1756443.0023957705
1756443.0024
513233.34999999916
513233.35
1243209.65239577
1243209.6524
[26, [26, 26], [0, 34, 66], 26]
¡Cambio de valores!
1750485.0429052848
1750485.04291
515529.8999999995
515529.9
1234955.1429052863
1234955.14291
[26, [26, 26], [0, 34, 66], 18]
¡Cambio de valores!
2136089.3142555356
2136089.31426
550253.5999999994
550253.6
1585835.7142555343
1585835.71426
[13, [30, 30], [33, 1, 66], 22]
¡Cambio de valores!
1592875.1025410795
1592875.10254
302078.4500000004
302078.45
1290796.6525410805
1290796.65254
[13, [30, 30], [33, 1, 66], 30]
¡Cambio de valores!
1437841.3391300126
1437841.33913
309922.74999999994
309922.75
1127918.5891300123
1127918.58913
[13, [22, 22], [33, 1, 66], 30]
¡Cambio de valores!
1410689.3052301288
1410689.30523
300458.1499999999
300458.15
1110231.1552301284
1110231.15523
[13, [22, 22], [33, 67, 0], 30]
¡Cambio de valores!
1411421.3745001336
1411421.3745
280526.5499999998
280526.55
1130894.8245001342
1130894.8245
[13, [22, 22], [100, 0, 0], 30]
¡Cambio de valores!
1401208.8336088446
1401208.83361
294469.0999999999
294469.1
1106739.7336088456
1106739.73361
[40, [22, 22], [100, 0, 0], 30]
¡Cambio de valores!
1923203.6268736508
1923203.62687
773376.6999999997
773376.7
1149826.926873651
1149826.92687
[0, [26, 26], [66, 34, 0], 30]
¡Cambio de valores!
1122903.9870709975
1122903.98707
0.0
0.0
1122903.9870709975
1122903.98707
[0, [18, 18], [66, 34, 0], 30]
¡Cambio de valores!
1122903.9870709975
1122903.98707
0.0
0.0
1122903.9870709975
1122903.98707
[0, [18, 18], [0, 100, 0], 30]
¡Cambio de valores!
1122903.9870709975
1122903.98707
0.0
0.0
1122903.9870709975
1122903.98707
[26, [18, 18], [0, 100, 0], 30]
¡Cambio de valores!
1671746.421505908
1671746.42151
543295.3999999989
543295.4
1128451.021505908
1128451.02151
[26, [18, 18], [0, 34, 66], 30]
¡Cambio de valores!
1692343.0532562917
1692343.05326
531971.3499999988
531971.35
1160371.703256293
1160371.70326
[26, [18, 18], [0, 34, 66], 22]
¡Cambio de valores!
1955916.4250798153
1955916.42508
517381.14999999956
517381.15
1438535.2750798133
1438535.27508
[13, [22, 22], [0, 0, 100], 18]
¡Cambio de valores!
1623476.8768625823
1623476.87686
285484.5500000003
285484.55
1337992.326862582
1337992.32686
[13, [22, 22], [66, 0, 100], 18]
¡Cambio de valores!
1627429.5474849213
1627429.54748
291193.00000000006
291193.0
1336236.5474849192
1336236.54748
[13, [22, 22], [66, 1, 33], 18]
¡Cambio de valores!
1646338.600724743
1646338.60072
301272.2500000002
301272.25
1345066.3507247427
1345066.35072
[40, [22, 22], [66, 1, 33], 18]
¡Cambio de valores!
2552599.0123103256
2552599.01231
774808.399999999
774808.4
1777790.6123103246
1777790.61231
[40, [22, 22], [66, 1, 33], 26]
¡Cambio de valores!
2085065.8537693822
2085065.85377
778163.0499999984
778163.05
1306902.8037693813
1306902.80377
[40, [30, 30], [66, 1, 33], 26]
¡Cambio de valores!
2077517.3363651368
2077517.33637
774810.5999999995
774810.6
1302706.736365138
1302706.73637
[40, [22, 22], [33, 0, 100], 18]
¡Cambio de valores!
2572044.4071238823
2572044.40712
787394.5
787394.5
1784649.9071238802
1784649.90712
[40, [30, 30], [33, 0, 100], 18]
¡Cambio de valores!
2582421.879129034
2582421.87913
783323.1999999995
783323.2
1799098.6791290306
1799098.67913
[40, [30, 30], [33, 0, 100], 26]
¡Cambio de valores!
2097172.0794140226
2097172.07941
785436.1499999992
785436.15
1311735.929414023
1311735.92941
[40, [30, 30], [33, 34, 33], 26]
¡Cambio de valores!
2090262.4612457736
2090262.46125
781606.6499999992
781606.65
1308655.8112457749
1308655.81125
[13, [30, 30], [33, 34, 33], 26]
¡Cambio de valores!
1446539.6673294166
1446539.66733
269605.1499999999
269605.15
1176934.5173294172
1176934.51733
[13, [30, 30], [100, 0, 33], 26]
¡Cambio de valores!
1487827.059044364
1487827.05904
290575.7499999999
290575.75
1197251.3090443648
1197251.30904
[13, [26, 26], [66, 34, 0], 22]
¡Cambio de valores!
1611825.8078726474
1611825.80787
300295.75
300295.75
1311530.0578726463
1311530.05787
[13, [18, 18], [66, 34, 0], 22]
¡Cambio de valores!
1657196.0270473186
1657196.02705
315951.7000000002
315951.7
1341244.3270473182
1341244.32705
[40, [18, 18], [66, 34, 0], 22]
¡Cambio de valores!
2330907.5787342903
2330907.57873
791253.5499999992
791253.55
1539654.0287342896
1539654.02873
[40, [18, 18], [66, 0, 66], 22]
¡Cambio de valores!
2306277.4261063333
2306277.42611
768868.6499999989
768868.65
1537408.7761063299
1537408.77611
[40, [18, 18], [0, 34, 66], 22]
¡Cambio de valores!
2358423.117166821
2358423.11717
798001.3499999993
798001.35
1560421.7671668173
1560421.76717
[40, [18, 18], [0, 34, 66], 30]
¡Cambio de valores!
1930848.472361809
1930848.47236
787815.9499999996
787815.95
1143032.5223618075
1143032.52236
[40, [22, 22], [66, 0, 66], 18]
¡Cambio de valores!
2547202.7800247995
2547202.78002
775253.1999999991
775253.2
1771949.5800247984
1771949.58002
[40, [22, 22], [66, 34, 0], 18]
¡Cambio de valores!
2559997.694670814
2559997.69467
783470.2499999994
783470.25
1776527.4446708134
1776527.44467
[13, [22, 22], [66, 34, 0], 18]
¡Cambio de valores!
1663488.878990182
1663488.87899
305151.7500000001
305151.75
1358337.1289901813
1358337.12899
[13, [22, 22], [66, 34, 0], 26]
¡Cambio de valores!
1459687.5868064978
1459687.58681
270859.4000000002
270859.4
1188828.186806499
1188828.18681
[13, [22, 22], [0, 100, 0], 26]
¡Cambio de valores!
1461951.1907044097
1461951.1907
275277.4499999999
275277.45
1186673.7407044074
1186673.7407
[13, [30, 30], [0, 100, 0], 26]
¡Cambio de valores!
1460844.9933127286
1460844.99331
283908.2500000002
283908.25
1176936.7433127293
1176936.74331
[13, [18, 18], [33, 1, 66], 18]
¡Cambio de valores!
1641629.9747801365
1641629.97478
283920.14999999985
283920.15
1357709.8247801352
1357709.82478
[13, [26, 26], [33, 1, 66], 18]
¡Cambio de valores!
1636002.714489102
1636002.71449
293519.3000000004
293519.3
1342483.4144891
1342483.41449
[13, [26, 26], [33, 67, 0], 18]
¡Cambio de valores!
1685394.2194307048
1685394.21943
332961.8499999998
332961.85
1352432.369430703
1352432.36943
[13, [26, 26], [100, 0, 0], 18]
¡Cambio de valores!
1749508.0720465514
1749508.07205
321088.04999999976
321088.05
1428420.022046551
1428420.02205
[40, [26, 26], [100, 0, 0], 18]
¡Cambio de valores!
2563047.219015093
2563047.21902
777204.1499999992
777204.15
1785843.0690150913
1785843.06902
[40, [26, 26], [100, 0, 0], 26]
¡Cambio de valores!
2074152.1316419959
2074152.13164
774876.3999999987
774876.4
1299275.7316419948
1299275.73164
[13, [30, 30], [66, 0, 66], 18]
¡Cambio de valores!
1625777.0138153676
1625777.01382
288906.05000000005
288906.05
1336870.9638153673
1336870.96382
[13, [22, 22], [66, 0, 66], 18]
¡Cambio de valores!
1703447.8879405991
1703447.88794
296598.80000000016
296598.8
1406849.087940603
1406849.08794
[40, [22, 22], [66, 0, 66], 18]
¡Cambio de valores!
2582591.000586472
2582591.00059
788834.199999999
788834.2
1793756.8005864737
1793756.80059
[40, [22, 22], [0, 34, 66], 18]
¡Cambio de valores!
2552460.0159929353
2552460.01599
772380.3499999996
772380.35
1780079.6659929343
1780079.66599
[40, [22, 22], [0, 100, 0], 18]
¡Cambio de valores!
2546270.746937846
2546270.74694
774727.7999999986
774727.8
1771542.946937845
1771542.94694
[40, [22, 22], [0, 100, 0], 26]
¡Cambio de valores!
2092759.5900039189
2092759.59
788132.4000000001
788132.4
1304627.1900039192
1304627.19
[0, [30, 30], [0, 100, 0], 30]
¡Cambio de valores!
1122903.9870709975
1122903.98707
0.0
0.0
1122903.9870709975
1122903.98707
[0, [30, 30], [66, 34, 0], 30]
¡Cambio de valores!
1122903.9870709975
1122903.98707
0.0
0.0
1122903.9870709975
1122903.98707
[26, [30, 30], [66, 34, 0], 30]
¡Cambio de valores!
1662999.6026106563
1662999.60261
527478.0999999994
527478.1
1135521.5026106557
1135521.50261
[26, [30, 30], [66, 34, 0], 22]
¡Cambio de valores!
1963132.3621666068
1963132.36217
524178.9999999999
524179.0
1438953.3621666075
1438953.36217
[26, [30, 30], [66, 0, 66], 22]
¡Cambio de valores!
1918254.4754736938
1918254.47547
508778.3499999988
508778.35
1409476.1254736958
1409476.12547
[26, [22, 22], [66, 0, 66], 22]
¡Cambio de valores!
1952795.6315374407
1952795.63154
516851.6499999993
516851.65
1435943.9815374422
1435943.98154
Name                      mu mu_star   sigma
People               1058664.75 1058664.75 231373.06
DesTemperature       -20150.19 31409.08 45865.39
tempIn               -544636.38 544636.38 185085.78
GoodBehaviour        11229.49 30615.97 47452.23
BadBehaviour         -18539.74 28648.35 33912.01
Out[15]:
<matplotlib.collections.PathCollection at 0x7f5ea08c7dd8>

In [8]:
output = []
for n in range(len(sample)):
    data = sample[n]
    m = 0 if ((100 - (int(data[3]) + int(data[4])))<0) else (100 - (int(data[3]) + int(data[4])))
    a = [int(data[0]), [int(data[1]), int(data[1])], [int(data[3]), m, int(data[4])], int(data[2])]
    print(a)
    y = energy_model(a, 2)
    output.append(y)

output2 = []
for i in range(len(output)):
    output2.append(output[i][0])
output2 = np.array(output2, dtype=np.float32)

Si = ma.analyze(morris_problem, sample, output2, print_to_console=False)
print("{:20s} {:>7s} {:>7s} {:>7s}".format("Name", "mu", "mu_star", "sigma"))
for name, s1, st, mean in zip(morris_problem['names'], 
                              Si['mu'], 
                              Si['mu_star'], 
                              Si['sigma']):
    print("{:20s} {:=7.2f} {:=7.2f} {:=7.2f}".format(name, s1, st, mean))

print(Si)
fig, (ax1, ax2) = plt.subplots(1,2)
mp.horizontal_bar_plot(ax1, Si, {})
mp.covariance_plot(ax2, Si, {})


[13, [26, 26], [100, 0, 0], 22]
¡Cambio de valores!
1652151.8814846892
1652151.88148
285792.5999999999
285792.6
1366359.2814846877
1366359.28148
[40, [26, 26], [100, 0, 0], 22]
¡Cambio de valores!
2110836.419182709
2110836.41918
791309.9999999991
791310.0
1319526.419182707
1319526.41918
[40, [26, 26], [33, 67, 0], 22]
¡Cambio de valores!
2114309.912976804
2114309.91298
791800.8999999998
791800.9
1322509.012976805
1322509.01298
[40, [18, 18], [33, 67, 0], 22]
¡Cambio de valores!
2492745.4118398745
2492745.41184
774070.2999999991
774070.3
1718675.111839869
1718675.11184
[40, [18, 18], [33, 1, 66], 22]
¡Cambio de valores!
2503703.5077681188
2503703.50777
776529.649999999
776529.65
1727173.857768118
1727173.85777
[40, [18, 18], [33, 1, 66], 30]
¡Cambio de valores!
2369249.7674085177
2369249.76741
782204.3499999992
782204.35
1587045.4174085152
1587045.41741
[40, [18, 18], [0, 34, 66], 18]
¡Cambio de valores!
2531724.1758544343
2531724.17585
769315.0499999996
769315.05
1762409.1258544326
1762409.12585
[40, [26, 26], [0, 34, 66], 18]
¡Cambio de valores!
2127901.3035122068
2127901.30351
781027.699999999
781027.7
1346873.6035122045
1346873.60351
[40, [26, 26], [0, 100, 0], 18]
¡Cambio de valores!
2134387.7365859393
2134387.73659
780215.8499999987
780215.85
1354171.8865859366
1354171.88659
[40, [26, 26], [0, 100, 0], 26]
¡Cambio de valores!
2005783.0792616797
2005783.07926
779483.7999999993
779483.8
1226299.2792616787
1226299.27926
[13, [26, 26], [0, 100, 0], 26]
¡Cambio de valores!
1400134.5615268308
1400134.56153
294664.35000000015
294664.35
1105470.2115268316
1105470.21153
[13, [26, 26], [66, 34, 0], 26]
¡Cambio de valores!
1420320.6268822814
1420320.62688
299252.4000000001
299252.4
1121068.2268822794
1121068.22688
[26, [22, 22], [100, 0, 0], 22]
¡Cambio de valores!
2067402.6419584742
2067402.64196
529674.1499999989
529674.15
1537728.4919584724
1537728.49196
[26, [22, 22], [33, 67, 0], 22]
¡Cambio de valores!
2113211.6855413797
2113211.68554
568162.6999999997
568162.7
1545048.9855413781
1545048.98554
[26, [30, 30], [33, 67, 0], 22]
¡Cambio de valores!
1742678.6261202209
1742678.62612
510483.9999999994
510484.0
1232194.62612022
1232194.62612
[26, [30, 30], [33, 67, 0], 30]
¡Cambio de valores!
1341211.3950325213
1341211.39503
539293.2999999988
539293.3
801918.0950325212
801918.095033
[0, [30, 30], [33, 67, 0], 30]
¡Cambio de valores!
598373.9484541289
598373.948454
0.0
0.0
598373.9484541289
598373.948454
[0, [30, 30], [33, 1, 66], 30]
¡Cambio de valores!
598373.9484541289
598373.948454
0.0
0.0
598373.9484541289
598373.948454
[26, [18, 18], [0, 100, 0], 18]
¡Cambio de valores!
2203528.8376676436
2203528.83767
503785.2999999997
503785.3
1699743.5376676437
1699743.53767
[26, [18, 18], [66, 34, 0], 18]
¡Cambio de valores!
2298928.9005644354
2298928.90056
552516.5999999993
552516.6
1746412.3005644353
1746412.30056
[26, [18, 18], [66, 34, 0], 26]
¡Cambio de valores!
2004233.5530224247
2004233.55302
541347.1999999998
541347.2
1462886.353022423
1462886.35302
[26, [26, 26], [66, 34, 0], 26]
¡Cambio de valores!
1696934.6528962047
1696934.6529
527382.5499999996
527382.55
1169552.1028962035
1169552.1029
[26, [26, 26], [66, 0, 66], 26]
¡Cambio de valores!
1700875.4349385614
1700875.43494
541928.6999999993
541928.7
1158946.7349385612
1158946.73494
[0, [26, 26], [66, 0, 66], 26]
¡Cambio de valores!
1061345.5482434495
1061345.54824
0.0
0.0
1061345.5482434495
1061345.54824
[26, [18, 18], [66, 34, 0], 26]
¡Cambio de valores!
1958452.3697350775
1958452.36974
512028.3499999995
512028.35
1446424.0197350765
1446424.01974
[26, [18, 18], [66, 34, 0], 18]
¡Cambio de valores!
2261660.997449505
2261660.99745
530592.9499999997
530592.95
1731068.0474495036
1731068.04745
[26, [18, 18], [0, 100, 0], 18]
¡Cambio de valores!
2268465.385798671
2268465.3858
533078.9999999995
533079.0
1735386.3857986704
1735386.3858
[0, [18, 18], [0, 100, 0], 18]
¡Cambio de valores!
1974998.4835446542
1974998.48354
0.0
0.0
1974998.4835446542
1974998.48354
[0, [18, 18], [0, 34, 66], 18]
¡Cambio de valores!
1974998.4835446542
1974998.48354
0.0
0.0
1974998.4835446542
1974998.48354
[0, [26, 26], [0, 34, 66], 18]
¡Cambio de valores!
1974998.4835446542
1974998.48354
0.0
0.0
1974998.4835446542
1974998.48354
[40, [22, 22], [33, 67, 0], 30]
¡Cambio de valores!
2217621.2141448525
2217621.21414
776820.1
776820.1
1440801.114144853
1440801.11414
[40, [22, 22], [100, 0, 0], 30]
¡Cambio de valores!
2236362.7139454316
2236362.71395
784141.1499999997
784141.15
1452221.563945431
1452221.56395
[40, [22, 22], [100, 0, 0], 22]
¡Cambio de valores!
2372582.1198410015
2372582.11984
789888.0999999997
789888.1
1582694.0198409976
1582694.01984
[40, [22, 22], [100, 0, 66], 22]
¡Cambio de valores!
2367487.7420884403
2367487.74209
778668.25
778668.25
1588819.4920884375
1588819.49209
[13, [22, 22], [100, 0, 66], 22]
¡Cambio de valores!
1740066.9219736469
1740066.92197
263722.6000000002
263722.6
1476344.3219736456
1476344.32197
[13, [30, 30], [100, 0, 66], 22]
¡Cambio de valores!
1517766.6648393436
1517766.66484
280386.95
280386.95
1237379.7148393416
1237379.71484
[13, [30, 30], [100, 0, 0], 30]
¡Cambio de valores!
1056538.686201782
1056538.6862
304355.8999999998
304355.9
752182.7862017814
752182.786202
[40, [30, 30], [100, 0, 0], 30]
¡Cambio de valores!
1633253.4612551434
1633253.46126
784550.6999999995
784550.7
848702.7612551426
848702.761255
[40, [22, 22], [100, 0, 0], 30]
¡Cambio de valores!
2244212.1314608008
2244212.13146
786042.3499999996
786042.35
1458169.7814607983
1458169.78146
[40, [22, 22], [100, 0, 0], 22]
¡Cambio de valores!
2361215.687402038
2361215.6874
776591.5499999993
776591.55
1584624.1374020379
1584624.1374
[40, [22, 22], [100, 0, 66], 22]
¡Cambio de valores!
2391882.4770436287
2391882.47704
798970.9999999994
798971.0
1592911.4770436268
1592911.47704
[40, [22, 22], [33, 1, 66], 22]
¡Cambio de valores!
2347526.320498067
2347526.3205
765240.9999999998
765241.0
1582285.3204980642
1582285.3205
[0, [18, 18], [100, 0, 0], 22]
¡Cambio de valores!
1554051.6272323115
1554051.62723
0.0
0.0
1554051.6272323115
1554051.62723
[26, [18, 18], [100, 0, 0], 22]
¡Cambio de valores!
2158705.695490057
2158705.69549
525377.8999999992
525377.9
1633327.7954900535
1633327.79549
[26, [26, 26], [100, 0, 0], 22]
¡Cambio de valores!
1855590.8886318672
1855590.88863
516108.5499999994
516108.55
1339482.338631866
1339482.33863
[26, [26, 26], [33, 67, 0], 22]
¡Cambio de valores!
1849701.8673220198
1849701.86732
508363.7999999996
508363.8
1341338.0673220174
1341338.06732
[26, [26, 26], [33, 67, 0], 30]
¡Cambio de valores!
1533522.9991534706
1533522.99915
524823.1999999997
524823.2
1008699.7991534697
1008699.79915
[26, [26, 26], [33, 1, 66], 30]
¡Cambio de valores!
1516299.9874716247
1516299.98747
519053.3
519053.3
997246.687471623
997246.687472
[26, [26, 26], [0, 100, 0], 26]
¡Cambio de valores!
1711242.0872225813
1711242.08722
537055.0999999989
537055.1
1174186.9872225802
1174186.98722
[26, [26, 26], [0, 100, 0], 18]
¡Cambio de valores!
1942298.869888539
1942298.86989
523957.3999999984
523957.4
1418341.4698885386
1418341.46989
[26, [26, 26], [0, 34, 66], 18]
¡Cambio de valores!
1956027.829153811
1956027.82915
537380.9999999994
537381.0
1418646.8291538097
1418646.82915
[26, [18, 18], [0, 34, 66], 18]
¡Cambio de valores!
2259204.4665737953
2259204.46657
529092.3499999987
529092.35
1730112.116573791
1730112.11657
[0, [18, 18], [0, 34, 66], 18]
¡Cambio de valores!
1974998.4835446542
1974998.48354
0.0
0.0
1974998.4835446542
1974998.48354
[0, [18, 18], [66, 0, 66], 18]
¡Cambio de valores!
1974998.4835446542
1974998.48354
0.0
0.0
1974998.4835446542
1974998.48354
[13, [22, 22], [66, 0, 66], 30]
¡Cambio de valores!
1374712.9631259143
1374712.96313
318734.45000000007
318734.45
1055978.5131259132
1055978.51313
[13, [22, 22], [66, 0, 66], 22]
¡Cambio de valores!
1777915.6212022873
1777915.6212
295628.6999999997
295628.7
1482286.921202284
1482286.9212
[13, [22, 22], [66, 34, 0], 22]
¡Cambio de valores!
1735499.996019778
1735499.99602
261848.35000000033
261848.35
1473651.6460197791
1473651.64602
[13, [22, 22], [0, 100, 0], 22]
¡Cambio de valores!
1773915.3646722932
1773915.36467
286478.3500000002
286478.35
1487437.0146722908
1487437.01467
[40, [22, 22], [0, 100, 0], 22]
¡Cambio de valores!
2354565.166968052
2354565.16697
767441.9499999996
767441.95
1587123.2169680481
1587123.21697
[40, [30, 30], [0, 100, 0], 22]
¡Cambio de valores!
1853829.6417042234
1853829.6417
785638.6999999996
785638.7
1068190.9417042227
1068190.9417
Name                      mu mu_star   sigma
People               812072.00 812072.00 225268.80
DesTemperature       -510056.44 510056.44 244426.16
tempIn               -369913.59 369913.59 169253.97
GoodBehaviour        13510.59 41861.34 60587.54
BadBehaviour         10935.96 19577.08 26910.74
{'mu_star': array([ 812072.        ,  510056.4375    ,  369913.59375   ,
         41861.34375   ,   19577.08203125], dtype=float32), 'mu': array([ 812072.        , -510056.4375    , -369913.59375   ,
         13510.59375   ,   10935.95605469], dtype=float32), 'names': ['People', 'DesTemperature', 'tempIn', 'GoodBehaviour', 'BadBehaviour'], 'mu_star_conf': [133576.78232517588, 144931.77242073417, 101105.09432352716, 26402.464292732915, 12082.88320448082], 'sigma': array([ 225268.796875  ,  244426.15625   ,  169253.96875   ,
         60587.5390625 ,   26910.74023438], dtype=float32)}
Out[8]:
<matplotlib.collections.PathCollection at 0x7f5ea08b2ba8>

In [21]:
print(Si)
type(Si)
fig, (ax1, ax2) = plt.subplots(1,2)
mp.horizontal_bar_plot(ax1, Si, {})
mp.covariance_plot(ax2, Si, {})


{'mu_star': array([ 801797.8125    ,  208950.21875   ,  378130.1875    ,
         20975.51171875,   22686.20703125], dtype=float32), 'mu': array([ 801797.8125    , -208950.21875   , -378130.1875    ,
          2584.42504883,  -19866.28125   ], dtype=float32), 'mu_star_conf': [139717.80885529873, 106020.37009627171, 185067.1339729953, 8674.010102287546, 14503.556438068499], 'names': ['People', 'DesTemperature', 'tempIn', 'GoodBehaviour', 'BadBehaviour'], 'sigma': array([ 237033.1875    ,  177152.1875    ,  313885.84375   ,
         26756.03320312,   27457.07617188], dtype=float32)}
Out[21]:
<matplotlib.collections.PathCollection at 0x7f068c027240>

In [ ]:
print(Si)
type(Si)
fig, (ax1, ax2) = plt.subplots(1,2)
mp.horizontal_bar_plot(ax1, Si, {})
mp.covariance_plot(ax2, Si, {})

In [ ]:


In [ ]:


In [ ]:


In [9]:
import seaborn as sns

%matplotlib inline
from IPython.core.pylabtools import figsize
figsize(12, 10)

sns.set(style="whitegrid")

# Load the example Titanic dataset
titanic = sns.load_dataset("titanic")

print(titanic)
print(type(titanic))

# Draw a nested barplot to show survival for class and sex
g = sns.catplot(x="class", y="survived", hue="sex", data=titanic,
                height=6, kind="bar", palette="muted")
g.despine(left=True)
g.set_ylabels("survival probability")


     survived  pclass     sex   age  sibsp  parch      fare embarked   class  \
0           0       3    male  22.0      1      0    7.2500        S   Third   
1           1       1  female  38.0      1      0   71.2833        C   First   
2           1       3  female  26.0      0      0    7.9250        S   Third   
3           1       1  female  35.0      1      0   53.1000        S   First   
4           0       3    male  35.0      0      0    8.0500        S   Third   
5           0       3    male   NaN      0      0    8.4583        Q   Third   
6           0       1    male  54.0      0      0   51.8625        S   First   
7           0       3    male   2.0      3      1   21.0750        S   Third   
8           1       3  female  27.0      0      2   11.1333        S   Third   
9           1       2  female  14.0      1      0   30.0708        C  Second   
10          1       3  female   4.0      1      1   16.7000        S   Third   
11          1       1  female  58.0      0      0   26.5500        S   First   
12          0       3    male  20.0      0      0    8.0500        S   Third   
13          0       3    male  39.0      1      5   31.2750        S   Third   
14          0       3  female  14.0      0      0    7.8542        S   Third   
15          1       2  female  55.0      0      0   16.0000        S  Second   
16          0       3    male   2.0      4      1   29.1250        Q   Third   
17          1       2    male   NaN      0      0   13.0000        S  Second   
18          0       3  female  31.0      1      0   18.0000        S   Third   
19          1       3  female   NaN      0      0    7.2250        C   Third   
20          0       2    male  35.0      0      0   26.0000        S  Second   
21          1       2    male  34.0      0      0   13.0000        S  Second   
22          1       3  female  15.0      0      0    8.0292        Q   Third   
23          1       1    male  28.0      0      0   35.5000        S   First   
24          0       3  female   8.0      3      1   21.0750        S   Third   
25          1       3  female  38.0      1      5   31.3875        S   Third   
26          0       3    male   NaN      0      0    7.2250        C   Third   
27          0       1    male  19.0      3      2  263.0000        S   First   
28          1       3  female   NaN      0      0    7.8792        Q   Third   
29          0       3    male   NaN      0      0    7.8958        S   Third   
..        ...     ...     ...   ...    ...    ...       ...      ...     ...   
861         0       2    male  21.0      1      0   11.5000        S  Second   
862         1       1  female  48.0      0      0   25.9292        S   First   
863         0       3  female   NaN      8      2   69.5500        S   Third   
864         0       2    male  24.0      0      0   13.0000        S  Second   
865         1       2  female  42.0      0      0   13.0000        S  Second   
866         1       2  female  27.0      1      0   13.8583        C  Second   
867         0       1    male  31.0      0      0   50.4958        S   First   
868         0       3    male   NaN      0      0    9.5000        S   Third   
869         1       3    male   4.0      1      1   11.1333        S   Third   
870         0       3    male  26.0      0      0    7.8958        S   Third   
871         1       1  female  47.0      1      1   52.5542        S   First   
872         0       1    male  33.0      0      0    5.0000        S   First   
873         0       3    male  47.0      0      0    9.0000        S   Third   
874         1       2  female  28.0      1      0   24.0000        C  Second   
875         1       3  female  15.0      0      0    7.2250        C   Third   
876         0       3    male  20.0      0      0    9.8458        S   Third   
877         0       3    male  19.0      0      0    7.8958        S   Third   
878         0       3    male   NaN      0      0    7.8958        S   Third   
879         1       1  female  56.0      0      1   83.1583        C   First   
880         1       2  female  25.0      0      1   26.0000        S  Second   
881         0       3    male  33.0      0      0    7.8958        S   Third   
882         0       3  female  22.0      0      0   10.5167        S   Third   
883         0       2    male  28.0      0      0   10.5000        S  Second   
884         0       3    male  25.0      0      0    7.0500        S   Third   
885         0       3  female  39.0      0      5   29.1250        Q   Third   
886         0       2    male  27.0      0      0   13.0000        S  Second   
887         1       1  female  19.0      0      0   30.0000        S   First   
888         0       3  female   NaN      1      2   23.4500        S   Third   
889         1       1    male  26.0      0      0   30.0000        C   First   
890         0       3    male  32.0      0      0    7.7500        Q   Third   

       who adult_male deck  embark_town alive  alone  
0      man       True  NaN  Southampton    no  False  
1    woman      False    C    Cherbourg   yes  False  
2    woman      False  NaN  Southampton   yes   True  
3    woman      False    C  Southampton   yes  False  
4      man       True  NaN  Southampton    no   True  
5      man       True  NaN   Queenstown    no   True  
6      man       True    E  Southampton    no   True  
7    child      False  NaN  Southampton    no  False  
8    woman      False  NaN  Southampton   yes  False  
9    child      False  NaN    Cherbourg   yes  False  
10   child      False    G  Southampton   yes  False  
11   woman      False    C  Southampton   yes   True  
12     man       True  NaN  Southampton    no   True  
13     man       True  NaN  Southampton    no  False  
14   child      False  NaN  Southampton    no   True  
15   woman      False  NaN  Southampton   yes   True  
16   child      False  NaN   Queenstown    no  False  
17     man       True  NaN  Southampton   yes   True  
18   woman      False  NaN  Southampton    no  False  
19   woman      False  NaN    Cherbourg   yes   True  
20     man       True  NaN  Southampton    no   True  
21     man       True    D  Southampton   yes   True  
22   child      False  NaN   Queenstown   yes   True  
23     man       True    A  Southampton   yes   True  
24   child      False  NaN  Southampton    no  False  
25   woman      False  NaN  Southampton   yes  False  
26     man       True  NaN    Cherbourg    no   True  
27     man       True    C  Southampton    no  False  
28   woman      False  NaN   Queenstown   yes   True  
29     man       True  NaN  Southampton    no   True  
..     ...        ...  ...          ...   ...    ...  
861    man       True  NaN  Southampton    no  False  
862  woman      False    D  Southampton   yes   True  
863  woman      False  NaN  Southampton    no  False  
864    man       True  NaN  Southampton    no   True  
865  woman      False  NaN  Southampton   yes   True  
866  woman      False  NaN    Cherbourg   yes  False  
867    man       True    A  Southampton    no   True  
868    man       True  NaN  Southampton    no   True  
869  child      False  NaN  Southampton   yes  False  
870    man       True  NaN  Southampton    no   True  
871  woman      False    D  Southampton   yes  False  
872    man       True    B  Southampton    no   True  
873    man       True  NaN  Southampton    no   True  
874  woman      False  NaN    Cherbourg   yes  False  
875  child      False  NaN    Cherbourg   yes   True  
876    man       True  NaN  Southampton    no   True  
877    man       True  NaN  Southampton    no   True  
878    man       True  NaN  Southampton    no   True  
879  woman      False    C    Cherbourg   yes  False  
880  woman      False  NaN  Southampton   yes  False  
881    man       True  NaN  Southampton    no   True  
882  woman      False  NaN  Southampton    no   True  
883    man       True  NaN  Southampton    no   True  
884    man       True  NaN  Southampton    no   True  
885  woman      False  NaN   Queenstown    no  False  
886    man       True  NaN  Southampton    no   True  
887  woman      False    B  Southampton   yes   True  
888  woman      False  NaN  Southampton    no  False  
889    man       True    C    Cherbourg   yes   True  
890    man       True  NaN   Queenstown    no   True  

[891 rows x 15 columns]
<class 'pandas.core.frame.DataFrame'>
Out[9]:
<seaborn.axisgrid.FacetGrid at 0x7f2dc817e2b0>

In [ ]:
import seaborn as sns

%matplotlib inline
from IPython.core.pylabtools import figsize
figsize(12, 10)

sns.set(style="whitegrid")

d = {'model': [1, 2], 'col2': [3, 4]}
df = pd.DataFrame(data=d)

print(df)

# Load the example Titanic dataset
titanic = sns.load_dataset("titanic")

print(titanic)
print(type(titanic))

# Draw a nested barplot to show survival for class and sex
g = sns.catplot(x="class", y="survived", hue="sex", data=titanic,
                height=6, kind="bar", palette="muted")
g.despine(left=True)
g.set_ylabels("survival probability")

In [ ]:
M0:
Name                      mu mu_star   sigma
People               995868.38 995868.38 252383.17
DesTemperature       -18073.16 41373.64 50489.59
tempIn               -1115338.00 1115338.00 94569.88
GoodBehaviour        -112362.73 125274.73 82131.39
BadBehaviour         170336.03 170336.03 134083.41


M1:
Name                      mu mu_star   sigma
People               1058664.75 1058664.75 231373.06
DesTemperature       -20150.19 31409.08 45865.39
tempIn               -544636.38 544636.38 185085.78
GoodBehaviour        11229.49 30615.97 47452.23
BadBehaviour         -18539.74 28648.35 33912.01


M2:
Name                      mu mu_star   sigma
People               812072.00 812072.00 225268.80
DesTemperature       -510056.44 510056.44 244426.16
tempIn               -369913.59 369913.59 169253.97
GoodBehaviour        13510.59 41861.34 60587.54
BadBehaviour         10935.96 19577.08 26910.74

In [16]:
import seaborn as sns
import pandas as pd

%matplotlib inline
from IPython.core.pylabtools import figsize
figsize(12, 10)

sns.set(style="whitegrid")

aux = [995868.38, 1058664.75, 812072.00,
           41373.64, 31409.08,  510056.44,
           1115338.00, 544636.38, 369913.59,
           125274.73, 30615.97, 41861.34,
           170336.03, 28648.35, 19577.08]

print(aux)

d = {'atr': ["People", "People", "People",
             "DesTemperature", "DesTemperature", "DesTemperature", 
             "Temperature", "Temperature", "Temperature",
             "GoodBehaviour", "GoodBehaviour", "GoodBehaviour",
             "BadBehaviour", "BadBehaviour", "BadBehaviour"], 
     'Model': [1, 2, 3, 1, 2, 3, 1, 2, 3 , 1, 2, 3, 1, 2, 3], 
     'mu_star': [995868.38, 1058664.75, 812072.00,
           41373.64, 31409.08,  510056.44,
           1115338.00, 544636.38, 369913.59,
           125274.73, 30615.97, 41861.34,
           170336.03, 28648.35, 19577.08], 
     'mu_start_conf': [(7.5/55)*aux[0], (6.5/56)*aux[1], (9/55)*aux[2], 
                 (1/2)*aux[3], (1/2)*aux[4], (10/35)*aux[5], 
                 (2.5/60)*aux[6], (6/30)*aux[7], (1/4)*aux[8], 
                 (2/7)*aux[9], (1/2)*aux[10], (1/4)*aux[11], 
                 (4/10)*aux[12], (1/2)*aux[13], (1/2)*aux[14]]
    }

df = pd.DataFrame(data=d)

print(df)

g = sns.catplot(x="atr", y="mu_star", hue="Model", data=df,
                height=6, kind="bar", palette="muted")
g.despine(left=True)
g.set_ylabels("μ'")

print(df['mu_start_conf'])


[995868.38, 1058664.75, 812072.0, 41373.64, 31409.08, 510056.44, 1115338.0, 544636.38, 369913.59, 125274.73, 30615.97, 41861.34, 170336.03, 28648.35, 19577.08]
               atr  Model     mu_star  mu_start_conf
0           People      1   995868.38  135800.233636
1           People      2  1058664.75  122880.729911
2           People      3   812072.00  132884.509091
3   DesTemperature      1    41373.64   20686.820000
4   DesTemperature      2    31409.08   15704.540000
5   DesTemperature      3   510056.44  145730.411429
6      Temperature      1  1115338.00   46472.416667
7      Temperature      2   544636.38  108927.276000
8      Temperature      3   369913.59   92478.397500
9    GoodBehaviour      1   125274.73   35792.780000
10   GoodBehaviour      2    30615.97   15307.985000
11   GoodBehaviour      3    41861.34   10465.335000
12    BadBehaviour      1   170336.03   68134.412000
13    BadBehaviour      2    28648.35   14324.175000
14    BadBehaviour      3    19577.08    9788.540000
0     135800.233636
1     122880.729911
2     132884.509091
3      20686.820000
4      15704.540000
5     145730.411429
6      46472.416667
7     108927.276000
8      92478.397500
9      35792.780000
10     15307.985000
11     10465.335000
12     68134.412000
13     14324.175000
14      9788.540000
Name: mu_start_conf, dtype: float64

In [17]:
import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np
import pandas as pd

def grouped_barplot(df, cat,subcat, val , err):
    u = df[cat].unique()
    x = np.arange(len(u))
    subx = df[subcat].unique()
    offsets = (np.arange(len(subx))-np.arange(len(subx)).mean())/(len(subx)+1.)
    width= np.diff(offsets).mean()
    for i,gr in enumerate(subx):
        dfg = df[df[subcat] == gr]
        plt.bar(x+offsets[i], dfg[val].values, width=width, 
                label="{} {}".format(subcat, gr), yerr=dfg[err].values)
    plt.xlabel(cat)
    plt.ylabel(val)
    plt.xticks(x, u)
    plt.legend()
    plt.show()

cat = "atr"
subcat = "Model"
val = "mu_star"
err = "mu_start_conf"
grouped_barplot(df, cat, subcat, val, err )



In [ ]: