diff --git a/docs/source/_static/online-shop.png b/docs/source/_static/online-shop.png new file mode 100644 index 000000000..3c36413ed Binary files /dev/null and b/docs/source/_static/online-shop.png differ diff --git a/docs/source/example_notebooks/2021 Data.csv b/docs/source/example_notebooks/2021 Data.csv new file mode 100644 index 000000000..949c24137 --- /dev/null +++ b/docs/source/example_notebooks/2021 Data.csv @@ -0,0 +1,366 @@ +Date,Shopping Event?,Ad Spend,Page Views,Unit Price,Sold Units,Revenue,Operational Cost,Profit +2021-01-01,False,1490.490265381528,11861,999.0,2317,2314683.0,1659999.894355353,654683.105644647 +2021-01-02,False,1455.9174625782161,11776,999.0,2355,2352645.0,1678959.080093096,673685.919906904 +2021-01-03,False,1405.8247897430833,11861,999.0,2391,2388609.0,1696906.137024402,691702.8629755981 +2021-01-04,False,1379.2993911273163,11677,999.0,2344,2341656.0,1673380.6353440138,668275.3646559862 +2021-01-05,False,1234.1992678703598,11871,999.0,2412,2409588.0,1707252.6139868004,702335.3860131996 +2021-01-06,False,1159.0742312826828,11757,999.0,2289,2286711.0,1645662.3900002348,641048.6099997652 +2021-01-07,True,2785.152912023138,19233,912.4881880650531,5813,5304293.837222154,3409292.086000969,1895001.751221185 +2021-01-08,False,1196.760681680594,11783,999.0,2350,2347650.0,1676199.365811293,671450.634188707 +2021-01-09,False,1272.9125924725195,12024,999.0,2412,2409588.0,1707294.122216526,702293.877783474 +2021-01-10,False,1308.7985094519931,11684,999.0,2280,2277720.0,1641317.121415526,636402.8785844741 +2021-01-11,False,1409.2334216219488,11697,999.0,2353,2350647.0,1677923.6128316629,672723.3871683371 +2021-01-12,False,1483.4963692226372,11775,999.0,2326,2323674.0,1664495.102550666,659178.8974493339 +2021-01-13,False,1146.9281921539243,11520,999.0,2327,2324673.0,1664653.7631703438,660019.2368296562 +2021-01-14,False,1142.8016560775166,11710,999.0,2387,2384613.0,1694642.8327602614,689970.1672397386 +2021-01-15,False,1335.8778892054202,11759,999.0,2429,2426571.0,1715842.4218234145,710728.5781765855 +2021-01-16,False,1398.1592295789171,11832,999.0,2527,2524473.0,1764902.658427361,759570.3415726391 +2021-01-17,False,1439.260152138794,11655,999.0,2330,2327670.0,1666444.7247434529,661225.2752565471 +2021-01-18,False,1474.3328320867154,11720,999.0,2251,2248749.0,1626981.8114488083,621767.1885511917 +2021-01-19,False,1493.370496904257,11786,999.0,2297,2294703.0,1649996.1095128139,644706.8904871861 +2021-01-20,False,1259.9206768898102,11603,999.0,2301,2298699.0,1651762.0183827095,646936.9816172905 +2021-01-21,False,1252.1340734110292,11646,999.0,2327,2324673.0,1664754.5299240712,659918.4700759288 +2021-01-22,False,1159.123470678909,11639,999.0,2282,2279718.0,1642173.325758806,637544.674241194 +2021-01-23,False,1373.9737754734238,11861,999.0,2429,2426571.0,1715881.0212605912,710689.9787394088 +2021-01-24,False,1362.704783376335,11701,999.0,2329,2326671.0,1665870.0584323294,660800.9415676706 +2021-01-25,False,1444.825038340483,11991,999.0,2426,2423574.0,1714450.0443145118,709123.9556854882 +2021-01-26,False,1138.9031979150564,11587,999.0,2256,2253744.0,1629154.8251481727,624589.1748518273 +2021-01-27,True,2148.140860948165,20194,975.4071845051653,5266,5136494.2336042,3135162.4003654267,2001331.8332387735 +2021-01-28,False,1332.4327718688253,11961,995.2411356969759,2983,2968804.307784079,1992837.3482955953,975966.9594884838 +2021-01-29,False,1196.6228160159674,11788,999.0,2425,2422575.0,1713702.918930913,708872.0810690869 +2021-01-30,False,1167.6101624516646,11725,999.0,2318,2315682.0,1660174.028026395,655507.971973605 +2021-01-31,False,1443.8323345678486,11583,999.0,2323,2320677.0,1662946.2392060945,657730.7607939055 +2021-02-01,False,1123.4139688942234,11449,999.0,2265,2262735.0,1633629.5981859828,629105.4018140172 +2021-02-02,False,1288.248361567229,11868,999.0,2448,2445552.0,1725289.010992668,720262.9890073319 +2021-02-03,False,1146.3336005203541,11584,999.0,2330,2327670.0,1666148.9485037127,661521.0514962873 +2021-02-04,False,1282.8235045325468,11670,999.0,2300,2297700.0,1651291.3708171973,646408.6291828027 +2021-02-05,False,1491.9849305369237,11818,999.0,2267,2264733.0,1635003.8638695406,629729.1361304594 +2021-02-06,False,1269.482541382189,11845,999.0,2356,2353644.0,1679279.6428153082,674364.3571846918 +2021-02-07,False,1442.8499670018268,11836,999.0,2429,2426571.0,1715945.918696612,710625.0813033881 +2021-02-08,False,1146.9262256732775,11788,999.0,2363,2360637.0,1682652.6033019517,677984.3966980483 +2021-02-09,False,1208.5008307047456,11633,999.0,2360,2357640.0,1681229.7932874202,676410.2067125798 +2021-02-10,False,1261.5170962669338,11536,999.0,2187,2184813.0,1594763.4677654942,590049.5322345058 +2021-02-11,False,1259.9248560037322,11816,999.0,2414,2411586.0,1708263.5348796612,703322.4651203388 +2021-02-12,False,1368.5533914680614,11849,999.0,2394,2391606.0,1698370.0731434575,693235.9268565425 +2021-02-13,False,1237.887250950203,11786,999.0,2308,2305692.0,1655240.1099782498,650451.8900217502 +2021-02-14,False,1385.5067473640065,12062,999.0,2449,2446551.0,1725898.5544792265,720652.4455207735 +2021-02-15,True,2407.241171413807,21467,817.6134280155665,6772,5536878.134521416,3888408.1735484214,1648469.960972995 +2021-02-16,False,1259.6644581019093,11455,999.0,2307,2304693.0,1654761.0598374568,649931.9401625432 +2021-02-17,False,1272.7040510617276,11688,999.0,2334,2331666.0,1668275.113418527,663390.886581473 +2021-02-18,False,1345.8110799241283,11721,999.0,2348,2345652.0,1675356.1521337174,670295.8478662826 +2021-02-19,False,1128.0168760578579,11642,999.0,2394,2391606.0,1698130.941472296,693475.0585277041 +2021-02-20,False,1428.9626953422762,11814,999.0,2326,2323674.0,1664437.306189022,659236.693810978 +2021-02-21,False,1361.3684644454547,11814,999.0,2337,2334663.0,1669862.4560498614,664800.5439501386 +2021-02-22,False,1390.536985767134,11737,999.0,2352,2349648.0,1677407.6141233458,672240.3858766542 +2021-02-23,False,1314.769200432956,11972,999.0,2428,2425572.0,1715317.7760615817,710254.2239384183 +2021-02-24,False,1144.190844396698,11705,999.0,2221,2218779.0,1611650.3485607388,607128.6514392612 +2021-02-25,False,1262.01424531878,11611,999.0,2315,2312685.0,1658764.795352707,653920.2046472931 +2021-02-26,False,1262.1494331394224,11717,999.0,2308,2305692.0,1655264.9169012865,650427.0830987135 +2021-02-27,False,1228.4171960172866,11764,999.0,2437,2434563.0,1719734.0256098548,714828.9743901452 +2021-02-28,False,1111.9801299618998,11708,999.0,2354,2351646.0,1678124.1431705554,673521.8568294446 +2021-03-01,False,1394.901697038591,11799,999.0,2287,2284713.0,1644895.9995133227,639817.0004866773 +2021-03-02,False,1143.9137832250003,11642,999.0,2264,2261736.0,1633151.0983407507,628584.9016592493 +2021-03-03,False,1342.523253218034,11656,999.0,2307,2304693.0,1654858.2851828537,649834.7148171463 +2021-03-04,False,1381.2869985868863,11841,999.0,2223,2220777.0,1612885.7056935495,607891.2943064505 +2021-03-05,False,1353.9145291734778,11870,999.0,2315,2312685.0,1658862.0831399565,653822.9168600435 +2021-03-06,False,1483.6569007911899,11828,999.0,2308,2305692.0,1655491.1119467902,650200.8880532098 +2021-03-07,False,1141.3192620340556,11520,999.0,2340,2337660.0,1671145.8595537725,666514.1404462275 +2021-03-08,False,1446.8668636420796,12005,999.0,2344,2341656.0,1673460.8504955515,668195.1495044485 +2021-03-09,False,1111.6760939395654,11675,999.0,2336,2333664.0,1669132.5721984995,664531.4278015005 +2021-03-10,False,1313.9667419708335,11764,999.0,2309,2306691.0,1655826.1128195229,650864.8871804771 +2021-03-11,False,1261.6974471757035,11610,999.0,2291,2288709.0,1646765.6250291632,641943.3749708368 +2021-03-12,False,1309.6735441575033,11846,999.0,2416,2413584.0,1709311.2658395944,704272.7341604056 +2021-03-13,False,1246.0399508240039,11802,999.0,2372,2369628.0,1687257.6193561181,682370.3806438819 +2021-03-14,False,1176.2267659760273,11854,999.0,2395,2392605.0,1698681.3036973355,693923.6963026645 +2021-03-15,False,1107.649158979476,11569,999.0,2323,2320677.0,1662609.053993624,658067.9460063761 +2021-03-16,False,1307.2599255164696,11740,999.0,2316,2313684.0,1659313.603327924,654370.3966720761 +2021-03-17,False,1437.1107450739369,11835,999.0,2307,2304693.0,1654947.8168056197,649745.1831943803 +2021-03-18,False,1249.2863822979177,11658,999.0,2401,2398599.0,1701751.5154899901,696847.4845100099 +2021-03-19,False,1189.145527205992,11529,999.0,2302,2299698.0,1652218.0707254258,647479.9292745742 +2021-03-20,True,2373.8131379325614,17455,989.1786220741245,4750,4698598.454852091,2877377.2067975793,1821221.2480545118 +2021-03-21,False,1134.1243692474814,11583,999.0,2376,2373624.0,1689137.244861201,684486.7551387991 +2021-03-22,False,1188.5585785171088,11622,999.0,2395,2392605.0,1698698.3177884882,693906.6822115118 +2021-03-23,False,1140.0056243686222,11691,999.0,2296,2293704.0,1649140.2469260297,644563.7530739703 +2021-03-24,False,1206.0158793457929,11778,999.0,2378,2375622.0,1690217.2205208445,685404.7794791555 +2021-03-25,False,1126.459784846782,11963,999.0,2409,2406591.0,1705637.7585571408,700953.2414428592 +2021-03-26,False,1126.2419468839703,11663,999.0,2320,2317680.0,1661142.141176798,656537.8588232021 +2021-03-27,False,1442.5104718491127,11776,999.0,2398,2395602.0,1700452.2977728562,695149.7022271438 +2021-03-28,False,1164.8481042835333,11627,999.0,2284,2281716.0,1643174.1897405346,638541.8102594654 +2021-03-29,False,1323.8729623293793,11664,999.0,2370,2367630.0,1686332.0200482714,681297.9799517286 +2021-03-30,False,1409.3822177796123,11946,999.0,2434,2431566.0,1718411.8946422513,713154.1053577487 +2021-03-31,False,1282.5638261356266,11740,999.0,2351,2348649.0,1676786.3921748525,671862.6078251475 +2021-04-01,True,2959.433340833425,21790,914.938061949047,6293,5757705.223845352,3649459.436750413,2108245.7870949395 +2021-04-02,False,1179.8384568480458,11863,999.0,2392,2389608.0,1697180.4605048546,692427.5394951454 +2021-04-03,False,1273.1936825124722,11845,999.0,2314,2311686.0,1658276.3671713206,653409.6328286794 +2021-04-04,False,1311.2936356714144,11462,999.0,2199,2196801.0,1600813.0729091326,595987.9270908674 +2021-04-05,False,1239.776116819414,11786,999.0,2391,2388609.0,1696741.892319989,691867.1076800111 +2021-04-06,False,1412.5918400938644,11692,999.0,2354,2351646.0,1678415.2666787244,673230.7333212756 +2021-04-07,False,1400.4086595425592,11813,999.0,2334,2331666.0,1668416.9268298964,663249.0731701036 +2021-04-08,False,1470.8847229492471,11675,999.0,2329,2326671.0,1665975.7505064374,660695.2494935626 +2021-04-09,False,1111.581019610784,11638,999.0,2290,2287710.0,1646128.5537365947,641581.4462634053 +2021-04-10,False,1458.2765164840814,11903,999.0,2332,2329668.0,1667469.001524957,662198.9984750431 +2021-04-11,False,1257.0275153848604,11716,999.0,2353,2350647.0,1677766.4864876494,672880.5135123506 +2021-04-12,False,1451.3489981519976,11651,999.0,2322,2319678.0,1662461.795078389,657216.2049216109 +2021-04-13,False,1376.3139104626118,11766,999.0,2340,2337660.0,1671399.2101889886,666260.7898110114 +2021-04-14,False,1494.9395028295874,11741,999.0,2357,2354643.0,1679997.3650654247,674645.6349345753 +2021-04-15,False,1403.7129806866672,11784,999.0,2320,2317680.0,1661410.9232998996,656269.0767001004 +2021-04-16,False,1245.8178503987147,11461,999.0,2319,2316681.0,1660768.8116543987,655912.1883456013 +2021-04-17,True,2458.6039617685856,20806,833.4618649395306,6466,5389164.418699005,3735468.9069180447,1653695.51178096 +2021-04-18,False,1250.5556620777404,11697,999.0,2316,2313684.0,1659266.0628680899,654417.9371319101 +2021-04-19,False,1245.9647344084951,11718,999.0,2415,2412585.0,1708756.9169899635,703828.0830100365 +2021-04-20,False,1204.3617997524238,11596,999.0,2327,2324673.0,1664706.718008332,659966.281991668 +2021-04-21,False,1298.388118149388,11915,999.0,2319,2316681.0,1660802.307809176,655878.6921908241 +2021-04-22,False,1372.6959780277446,11968,999.0,2389,2386611.0,1695878.3388493208,690732.6611506792 +2021-04-23,False,1210.9361085220974,11564,999.0,2208,2205792.0,1605218.8311839863,600573.1688160137 +2021-04-24,False,1309.751924430888,11834,999.0,2362,2359638.0,1682311.3136750036,677326.6863249964 +2021-04-25,False,1146.9521176682229,11866,999.0,2343,2340657.0,1672660.0760590283,667996.9239409717 +2021-04-26,False,1163.9381147416766,11773,999.0,2347,2344653.0,1674674.600838888,669978.399161112 +2021-04-27,False,1118.7225418848755,11700,999.0,2412,2409588.0,1707122.5111451715,702465.4888548285 +2021-04-28,False,1488.2925771082532,11728,999.0,2329,2326671.0,1666000.0787434042,660670.9212565958 +2021-04-29,False,1101.5441406041045,11712,999.0,2330,2327670.0,1666109.1340988125,661560.8659011875 +2021-04-30,False,1171.4319872230626,11772,999.0,2330,2327670.0,1666176.9617873477,661493.0382126523 +2021-05-01,True,2590.984165323685,19557,909.282053830764,5846,5315662.886694646,3425596.3545108004,1890066.532183846 +2021-05-02,False,1132.547839541322,11658,999.0,2307,2304693.0,1654635.416191623,650057.5838083769 +2021-05-03,False,1452.7586012387328,11852,999.0,2457,2454543.0,1729969.1026576879,724573.8973423121 +2021-05-04,False,1387.8480631369152,11857,999.0,2406,2403594.0,1704393.560329447,699200.439670553 +2021-05-05,False,1486.5559885751572,11729,999.0,2382,2379618.0,1692494.4555291766,687123.5444708234 +2021-05-06,False,1303.0542188963059,11629,999.0,2329,2326671.0,1665818.4817983005,660852.5182016995 +2021-05-07,False,1220.1614732633948,11657,999.0,2404,2401596.0,1703227.8347950913,698368.1652049087 +2021-05-08,False,1319.8002291181085,11733,999.0,2309,2306691.0,1655843.4964620513,650847.5035379487 +2021-05-09,False,1472.3274869191891,11871,999.0,2435,2432565.0,1718974.9330853596,713590.0669146404 +2021-05-10,False,1308.3045748967443,11523,999.0,2333,2330667.0,1667809.5941454028,662857.4058545972 +2021-05-11,False,1206.8828127449274,11677,999.0,2339,2336661.0,1670718.9594770921,665942.0405229079 +2021-05-12,False,1450.9595156696478,11869,999.0,2341,2338659.0,1671956.413951578,666702.5860484219 +2021-05-13,False,1248.7674994049846,11985,999.0,2395,2392605.0,1698764.3003259064,693840.6996740936 +2021-05-14,False,1100.5533399995998,11460,999.0,2238,2235762.0,1620101.6262533562,615660.3737466438 +2021-05-15,False,1199.0740089969263,11790,999.0,2297,2294703.0,1649714.427444437,644988.572555563 +2021-05-16,False,1227.293403670825,11471,999.0,2357,2354643.0,1679729.1429178414,674913.8570821586 +2021-05-17,False,1443.510987292761,11790,999.0,2377,2374623.0,1689945.278814426,684677.7211855741 +2021-05-18,False,1283.401266826578,11816,999.0,2392,2389608.0,1697305.3938072799,692302.6061927201 +2021-05-19,False,1277.8349151245202,11427,999.0,2254,2251746.0,1628285.1278025967,623460.8721974033 +2021-05-20,False,1234.440906559955,11669,999.0,2344,2341656.0,1673245.4464889606,668410.5535110394 +2021-05-21,False,1452.2712492188318,11590,999.0,2316,2313684.0,1659455.6949296575,654228.3050703425 +2021-05-22,True,2401.2595008036087,19355,838.9345667860393,6498,5451396.814975684,3751404.3625430567,1699992.4524326269 +2021-05-23,False,1496.7561316618517,11780,999.0,2298,2295702.0,1650504.8864954417,645197.1135045583 +2021-05-24,False,1250.6965067843946,11700,999.0,2322,2319678.0,1662258.0594776832,657419.9405223168 +2021-05-25,False,1486.4589782508685,11769,999.0,2357,2354643.0,1679994.282221441,674648.7177785591 +2021-05-26,False,1416.7518278523605,11798,999.0,2355,2352645.0,1678919.922809514,673725.077190486 +2021-05-27,False,1370.2756590577067,11716,999.0,2311,2308689.0,1656876.3381725377,651812.6618274623 +2021-05-28,False,1197.9557917680397,11641,999.0,2343,2340657.0,1672704.066370609,667952.933629391 +2021-05-29,False,1186.582904377684,11876,999.0,2392,2389608.0,1697195.7859995302,692412.2140004698 +2021-05-30,False,1166.4191298084984,11755,999.0,2344,2341656.0,1673181.5142189998,668474.4857810002 +2021-05-31,False,1469.1026440901462,11865,999.0,2398,2395602.0,1700475.6672809327,695126.3327190673 +2021-06-01,False,1217.6306649532664,11757,999.0,2305,2302695.0,1653718.2891767444,648976.7108232556 +2021-06-02,False,1281.2376981795514,11615,999.0,2339,2336661.0,1670789.974004505,665871.025995495 +2021-06-03,False,1297.5831335948894,11870,999.0,2349,2346651.0,1675808.1606725936,670842.8393274064 +2021-06-04,False,1411.2686381801018,11742,999.0,2346,2343654.0,1674420.241008487,669233.7589915129 +2021-06-05,False,1437.6939846212097,11868,999.0,2381,2378619.0,1691952.0160176125,686666.9839823875 +2021-06-06,False,1155.629080459445,11658,999.0,2303,2300697.0,1652669.0333836393,648027.9666163607 +2021-06-07,False,1270.7617440844294,11763,999.0,2360,2357640.0,1681274.1824924753,676365.8175075247 +2021-06-08,False,1437.1419551341828,11752,999.0,2387,2384613.0,1694947.8482384386,689665.1517615614 +2021-06-09,False,1427.2133223023354,11795,999.0,2379,2376621.0,1690944.6039726562,685676.3960273438 +2021-06-10,False,1140.9655033809665,11729,999.0,2320,2317680.0,1661154.0315636154,656525.9684363846 +2021-06-11,False,1162.5533395471853,11379,999.0,2269,2266731.0,1635667.0495074622,631063.9504925378 +2021-06-12,False,1221.6794766397632,11737,999.0,2363,2360637.0,1682725.789981098,677911.2100189021 +2021-06-13,False,1130.143627633336,11629,999.0,2287,2284713.0,1644637.6366231833,640075.3633768167 +2021-06-14,False,1269.8652011362371,11633,999.0,2276,2273724.0,1639271.9765788275,634452.0234211725 +2021-06-15,False,1143.0470820598327,11661,999.0,2335,2332665.0,1668645.6535934666,664019.3464065334 +2021-06-16,False,1327.287037467938,11734,999.0,2302,2299698.0,1652332.4390211776,647365.5609788224 +2021-06-17,False,1198.6227759244625,11644,999.0,2357,2354643.0,1679709.4149436883,674933.5850563117 +2021-06-18,False,1338.573226139849,11743,999.0,2349,2346651.0,1675853.3478540063,670797.6521459937 +2021-06-19,False,1147.010257161455,11703,999.0,2367,2364633.0,1684649.7613443993,679983.2386556007 +2021-06-20,False,1490.3535473674133,11844,999.0,2384,2381616.0,1693494.7236244958,688121.2763755042 +2021-06-21,False,1473.0244815429362,12012,999.0,2316,2313684.0,1659480.0061789304,654203.9938210696 +2021-06-22,False,1256.7187754258662,11731,999.0,2404,2401596.0,1703263.0705394112,698332.9294605888 +2021-06-23,False,1196.8714376504342,11906,999.0,2408,2405592.0,1705202.9082045201,700389.0917954799 +2021-06-24,False,1200.159285141429,11696,999.0,2209,2206791.0,1605717.5285812002,601073.4714187998 +2021-06-25,False,1293.357414080957,11719,999.0,2390,2387610.0,1696297.535758442,691312.464241558 +2021-06-26,False,1115.9971207602869,11459,999.0,2314,2311686.0,1658116.2422530823,653569.7577469177 +2021-06-27,False,1355.8820424300507,11555,999.0,2352,2349648.0,1677375.7789732052,672272.2210267948 +2021-06-28,False,1263.3211633358978,11543,999.0,2332,2329668.0,1667267.0528464657,662400.9471535343 +2021-06-29,False,1250.962629035555,11855,999.0,2320,2317680.0,1661252.372996351,656427.627003649 +2021-06-30,False,1423.7459885956794,11620,999.0,2312,2309688.0,1657433.1641433397,652254.8358566603 +2021-07-01,False,1383.614184073316,11800,999.0,2351,2348649.0,1676890.6425300357,671758.3574699643 +2021-07-02,False,1481.7335261570768,11769,999.0,2320,2317680.0,1661495.5218958757,656184.4781041243 +2021-07-03,False,1240.7744961982762,12041,999.0,2448,2445552.0,1725270.0269920388,720281.9730079612 +2021-07-04,False,1459.017105859762,11688,999.0,2242,2239758.0,1622464.7346257719,617293.2653742281 +2021-07-05,False,1407.9868745000356,11671,999.0,2307,2304693.0,1654908.445629992,649784.554370008 +2021-07-06,False,1242.9698606378852,11721,999.0,2342,2339658.0,1672253.5405035526,667404.4594964474 +2021-07-07,False,1348.666174581303,11902,999.0,2303,2300697.0,1652866.9131052135,647830.0868947865 +2021-07-08,False,1215.4279830606783,11727,999.0,2261,2258739.0,1631717.8453659436,627021.1546340564 +2021-07-09,False,1449.759966829937,11657,999.0,2387,2384613.0,1694951.2114850213,689661.7885149787 +2021-07-10,False,1144.9709268849244,11767,999.0,2350,2347650.0,1676149.9908535236,671500.0091464764 +2021-07-11,False,1184.9737445176165,11484,999.0,2335,2332665.0,1668691.8970329284,663973.1029670716 +2021-07-12,False,1173.2133168319685,11726,999.0,2331,2328669.0,1666683.3360672595,661985.6639327405 +2021-07-13,False,1261.2104009617155,11990,999.0,2482,2479518.0,1742261.632172089,737256.3678279109 +2021-07-14,False,1398.0931840128517,11811,999.0,2306,2303694.0,1654404.3132886605,649289.6867113395 +2021-07-15,False,1310.762979620872,11879,999.0,2388,2385612.0,1695314.838340903,690297.1616590971 +2021-07-16,False,1295.070529415283,11732,999.0,2306,2303694.0,1654303.5849934015,649390.4150065985 +2021-07-17,False,1100.2183859587983,11600,999.0,2337,2334663.0,1669603.6002186462,665059.3997813538 +2021-07-18,False,1270.1606901420218,11891,999.0,2334,2331666.0,1668277.8503675468,663388.1496324532 +2021-07-19,False,1125.4215099344633,11718,999.0,2367,2364633.0,1684631.4864866196,680001.5135133804 +2021-07-20,False,1183.3013008485937,11725,999.0,2301,2298699.0,1651683.427432272,647015.5725677281 +2021-07-21,False,1472.9575755841977,11817,999.0,2363,2360637.0,1682976.1818528129,677660.8181471871 +2021-07-22,False,1186.1592817372953,11766,999.0,2362,2359638.0,1682202.2343651624,677435.7656348376 +2021-07-23,False,1443.335055453705,11959,999.0,2397,2394603.0,1699961.3591565387,694641.6408434613 +2021-07-24,False,1421.1573486245338,11926,999.0,2465,2462535.0,1733933.7080275891,728601.2919724109 +2021-07-25,False,1163.6584947768972,11595,999.0,2371,2368629.0,1686663.788832371,681965.2111676291 +2021-07-26,False,1342.2847829081115,11667,999.0,2355,2352645.0,1678849.28835628,673795.71164372 +2021-07-27,False,1146.2647487620054,11723,999.0,2382,2379618.0,1692148.4174811072,687469.5825188928 +2021-07-28,False,1391.1552633478045,11634,999.0,2360,2357640.0,1681400.1861478966,676239.8138521034 +2021-07-29,False,1354.9849109488828,11784,999.0,2297,2294703.0,1649885.0592829934,644817.9407170066 +2021-07-30,False,1424.7754246764077,11679,994.9723749324899,2928,2913279.11380233,1965448.080097253,947831.0337050771 +2021-07-31,False,1291.7538197556753,11737,999.0,2263,2260737.0,1632797.4318526327,627939.5681473673 +2021-08-01,False,1465.9452351333532,11690,999.0,2306,2303694.0,1654492.6184560223,649201.3815439777 +2021-08-02,False,1119.739578715376,11528,999.0,2291,2288709.0,1646619.740262241,642089.2597377589 +2021-08-03,False,1217.155426010806,11836,999.0,2366,2363634.0,1684239.5699156888,679394.4300843112 +2021-08-04,False,1386.0210389860667,11724,999.0,2368,2365632.0,1685389.6213363144,680242.3786636856 +2021-08-05,False,1267.2436846992005,11844,999.0,2358,2355642.0,1680273.418623515,675368.5813764851 +2021-08-06,False,1169.1805417084624,11659,999.0,2461,2458539.0,1731678.8027655205,726860.1972344795 +2021-08-07,False,1142.8842981714183,11667,999.0,2288,2285712.0,1645147.5897872834,640564.4102127166 +2021-08-08,True,2994.4007896476796,21716,965.5177035644367,5960,5754485.513244043,3482996.7588317017,2271488.7544123414 +2021-08-09,False,1289.2571913862575,11713,999.0,2366,2363634.0,1684296.0450843284,679337.9549156716 +2021-08-10,False,1452.9134687676428,11862,999.0,2376,2373624.0,1689464.4496490834,684159.5503509166 +2021-08-11,False,1393.3156537266905,11891,999.0,2410,2407590.0,1706398.862981785,701191.1370182149 +2021-08-12,False,1263.8904822522975,11796,999.0,2322,2319678.0,1662265.1264898665,657412.8735101335 +2021-08-13,False,1249.4044056622733,11775,999.0,2241,2238759.0,1621750.7653827225,617008.2346172775 +2021-08-14,False,1306.2553386605007,11926,999.0,2402,2399598.0,1702323.3107627244,697274.6892372756 +2021-08-15,False,1455.6239812758915,11749,999.0,2341,2338659.0,1671968.1949455182,666690.8050544818 +2021-08-16,False,1394.911431885667,11881,999.0,2398,2395602.0,1700418.097681764,695183.902318236 +2021-08-17,False,1102.0611857076092,11397,999.0,2205,2202795.0,1603602.9045649595,599192.0954350405 +2021-08-18,False,1377.6631405476503,11808,999.0,2309,2306691.0,1655880.6398730706,650810.3601269294 +2021-08-19,False,1467.8029627623282,11981,999.0,2438,2435562.0,1720471.1932915193,715090.8067084807 +2021-08-20,False,1384.1823038017967,11698,999.0,2312,2309688.0,1657384.526341294,652303.4736587061 +2021-08-21,False,1170.8023126269984,11680,999.0,2271,2268729.0,1636675.9950045128,632053.0049954872 +2021-08-22,False,1293.4072509709836,11808,999.0,2364,2361636.0,1683300.1330819477,678335.8669180523 +2021-08-23,False,1156.1264071693677,11543,999.0,2337,2334663.0,1669667.8625194267,664995.1374805733 +2021-08-24,False,1243.5981113358528,11772,999.0,2433,2430567.0,1717759.5204062124,712807.4795937876 +2021-08-25,False,1474.846816776207,11916,999.0,2466,2463534.0,1734474.9833087842,729059.0166912158 +2021-08-26,False,1469.3221230234833,11855,999.0,2396,2393604.0,1699470.3055779254,694133.6944220746 +2021-08-27,False,1213.1347408704332,11806,999.0,2350,2347650.0,1676221.6335116196,671428.3664883804 +2021-08-28,False,1235.8524176664796,11617,999.0,2422,2419578.0,1712240.8022747654,707337.1977252346 +2021-08-29,True,2505.8663838253083,20892,860.1931181107782,6128,5271263.4277828485,3566516.553692409,1704746.8740904396 +2021-08-30,False,1485.2789181041521,11893,999.0,2322,2319678.0,1662487.6175822103,657190.3824177897 +2021-08-31,False,1159.1205336261562,11554,999.0,2272,2269728.0,1637160.1385846932,632567.8614153068 +2021-09-01,False,1202.7666574746677,11573,999.0,2437,2434563.0,1719704.257429102,714858.742570898 +2021-09-02,False,1449.4227309163086,11724,999.0,2254,2251746.0,1628456.4036933412,623289.5963066588 +2021-09-03,True,2333.5074657912755,19281,998.9862294037632,5210,5204718.255193606,3107342.038947436,2097376.21624617 +2021-09-04,False,1459.5844368908126,11690,999.0,2306,2303694.0,1654465.6318448524,649228.3681551476 +2021-09-05,False,1174.2071590092705,11505,999.0,2345,2342655.0,1673688.296068629,668966.703931371 +2021-09-06,False,1313.0674349885444,11805,999.0,2335,2332665.0,1668822.8784511504,663842.1215488496 +2021-09-07,False,1230.5078530597489,11782,999.0,2340,2337660.0,1671232.1596837398,666427.8403162602 +2021-09-08,False,1226.6170239569904,11838,999.0,2389,2386611.0,1695726.783482512,690884.216517488 +2021-09-09,False,1278.7507855784797,11738,999.0,2296,2293704.0,1649280.1601122855,644423.8398877145 +2021-09-10,False,1273.2309796405075,11520,999.0,2234,2231766.0,1618280.4827009412,613485.5172990588 +2021-09-11,False,1242.9387518711817,11770,999.0,2386,2383614.0,1694250.8961600221,689363.1038399779 +2021-09-12,False,1465.9883081262474,11799,999.0,2388,2385612.0,1695467.752693539,690144.247306461 +2021-09-13,False,1392.697674173157,11784,999.0,2312,2309688.0,1657409.0320194713,652278.9679805287 +2021-09-14,False,1391.0187965326118,11874,999.0,2310,2307690.0,1656392.5722943307,651297.4277056693 +2021-09-15,False,1215.9653798367822,11560,999.0,2318,2315682.0,1660221.43963982,655460.56036018 +2021-09-16,False,1331.0837697267361,11685,999.0,2269,2266731.0,1635832.5213728389,630898.4786271611 +2021-09-17,False,1411.6717733207336,11635,999.0,2290,2287710.0,1646412.973983113,641297.026016887 +2021-09-18,True,2879.234763031327,20719,942.4370480596212,6015,5668758.844078622,3510381.506482546,2158377.3375960756 +2021-09-19,False,1237.812184301725,11935,999.0,2420,2417580.0,1711248.3494755828,706331.6505244172 +2021-09-20,False,1408.3491026274592,11743,999.0,2375,2372625.0,1688923.6666328716,683701.3333671284 +2021-09-21,False,1394.3575587230932,11749,999.0,2361,2358639.0,1681897.6224945604,676741.3775054396 +2021-09-22,True,2710.3368289742134,19367,961.1392692002911,5572,5355468.007984022,3288725.005280679,2066743.0027033426 +2021-09-23,False,1446.378187426591,11708,999.0,2347,2344653.0,1674951.9194761016,669701.0805238984 +2021-09-24,False,1276.5285880721644,11618,999.0,2296,2293704.0,1649286.1953418006,644417.8046581994 +2021-09-25,False,1294.5641795554661,11679,999.0,2305,2302695.0,1653796.9659760427,648898.0340239573 +2021-09-26,False,1279.347671559199,11731,999.0,2405,2402595.0,1703780.3508158957,698814.6491841043 +2021-09-27,False,1327.1384005910031,11773,999.0,2324,2321676.0,1663336.5263151599,658339.4736848401 +2021-09-28,False,1348.4676989468219,11800,999.0,2386,2383614.0,1694360.525884511,689253.474115489 +2021-09-29,False,1299.2718263051775,11846,999.0,2414,2411586.0,1708303.4615464127,703282.5384535873 +2021-09-30,False,1446.7154173036383,11834,999.0,2298,2295702.0,1650447.6179180034,645254.3820819966 +2021-10-01,False,1351.0939024781137,11550,999.0,2319,2316681.0,1660863.167652346,655817.832347654 +2021-10-02,False,1260.571179722208,11834,999.0,2366,2363634.0,1684261.4569816962,679372.5430183038 +2021-10-03,False,1266.6767027634844,11683,981.7119376916577,2952,2898013.6400657734,1977288.7747586563,920724.8653071171 +2021-10-04,False,1424.3354460515807,11875,999.0,2319,2316681.0,1660934.502217251,655746.4977827489 +2021-10-05,False,1239.2767770986081,11495,999.0,2344,2341656.0,1673242.5838678568,668413.4161321432 +2021-10-06,False,1184.5819183129654,11425,999.0,2291,2288709.0,1646698.1657371917,642010.8342628083 +2021-10-07,False,1123.7532752023158,11501,999.0,2322,2319678.0,1662124.3618390476,657553.6381609524 +2021-10-08,False,1450.4107391682296,11744,999.0,2342,2339658.0,1672470.469653572,667187.530346428 +2021-10-09,False,1467.41858047614,11886,999.0,2349,2346651.0,1675968.235164108,670682.764835892 +2021-10-10,False,1148.0480728653904,11589,999.0,2277,2274723.0,1639648.8401665222,635074.1598334778 +2021-10-11,False,1233.789496598446,11772,999.0,2272,2269728.0,1637234.729179596,632493.2708204039 +2021-10-12,False,1170.1488278060974,11631,999.0,2256,2253744.0,1629174.143894637,624569.856105363 +2021-10-13,False,1146.3593875303518,11649,999.0,2375,2372625.0,1688661.8525001348,683963.1474998652 +2021-10-14,False,1459.946697200012,11850,999.0,2441,2438559.0,1721962.8752664065,716596.1247335935 +2021-10-15,False,1122.7509036581423,11824,999.0,2425,2422575.0,1713623.8180529082,708951.1819470918 +2021-10-16,False,1492.1942653876026,11652,999.0,2241,2238759.0,1621997.1288655982,616761.8711344018 +2021-10-17,False,1138.5803442789536,11701,999.0,2296,2293704.0,1649146.4371572367,644557.5628427633 +2021-10-18,False,1445.3882596774342,11801,999.0,2323,2320677.0,1662950.9317109836,657726.0682890164 +2021-10-19,False,1326.602442795665,11872,999.0,2338,2335662.0,1670338.2907460153,665323.7092539847 +2021-10-20,False,1247.1669951271492,11670,999.0,2381,2378619.0,1691756.5894595303,686862.4105404697 +2021-10-21,False,1236.9369506500632,11779,999.0,2284,2281716.0,1643241.5862266938,638474.4137733062 +2021-10-22,False,1402.9456572950835,11910,999.0,2379,2376621.0,1690904.1900010093,685716.8099989907 +2021-10-23,False,1225.829318001715,11377,999.0,2243,2240757.0,1622736.3610387002,618020.6389612998 +2021-10-24,False,1362.9275666468568,11730,999.0,2434,2431566.0,1718368.7000021643,713197.2999978357 +2021-10-25,False,1306.930433406432,11794,999.0,2307,2304693.0,1654818.901717931,649874.098282069 +2021-10-26,False,1293.9862580632282,11817,999.0,2304,2301696.0,1653310.3633209346,648385.6366790654 +2021-10-27,False,1460.4648682596646,11882,999.0,2433,2430567.0,1717986.810896268,712580.1891037319 +2021-10-28,True,2886.9607812174177,20146,875.9259632011078,6166,5400959.489098031,3585902.8250204697,1815056.6640775613 +2021-10-29,False,1430.744641219478,11777,999.0,2393,2390607.0,1697932.7255116045,692674.2744883955 +2021-10-30,False,1390.2294136405958,11852,999.0,2369,2366631.0,1685892.4052138147,680738.5947861853 +2021-10-31,False,1115.4228984235992,11705,999.0,2427,2424573.0,1714623.276045642,709949.7239543579 +2021-11-01,False,1409.2440210021678,11955,999.0,2409,2406591.0,1705916.0081078475,700674.9918921525 +2021-11-02,False,1186.7481000364162,11634,999.0,2278,2275722.0,1640197.3202416785,635524.6797583215 +2021-11-03,False,1461.2598587406287,11657,999.0,2293,2290707.0,1647962.9817198424,642744.0182801576 +2021-11-04,False,1117.1696762435329,11832,999.0,2317,2314683.0,1659629.263525363,655053.736474637 +2021-11-05,False,1233.2288137897276,11715,999.0,2363,2360637.0,1682733.8693907098,677903.1306092902 +2021-11-06,False,1139.8931788939017,11842,999.0,2304,2301696.0,1653150.5309785614,648545.4690214386 +2021-11-07,False,1290.2356468339376,11618,999.0,2318,2315682.0,1660291.027521892,655390.972478108 +2021-11-08,False,1428.0089743479007,12039,999.0,2476,2473524.0,1739433.283935011,734090.7160649891 +2021-11-09,False,1219.2749438652256,11822,999.0,2358,2355642.0,1680223.8770915812,675418.1229084188 +2021-11-10,False,1160.3739589244167,11812,999.0,2399,2396601.0,1700664.365627847,695936.6343721531 +2021-11-11,False,1232.1068142787597,11595,999.0,2330,2327670.0,1666232.8486462324,661437.1513537676 +2021-11-12,False,1425.5520567682543,11678,999.0,2331,2328669.0,1666936.4056311906,661732.5943688094 +2021-11-13,False,1156.1535831197389,11565,999.0,2324,2321676.0,1663166.847147801,658509.152852199 +2021-11-14,False,1190.9449796310007,11649,999.0,2280,2277720.0,1641194.5012638657,636525.4987361343 +2021-11-15,False,1127.5407857973496,11646,993.6799667962582,2965,2946261.1015509055,1983638.2355569052,962622.8659940003 +2021-11-16,False,1382.2840175958431,11585,999.0,2316,2313684.0,1659408.5987606144,654275.4012393856 +2021-11-17,False,1258.0932974145348,11881,999.0,2400,2397600.0,1701272.2230411537,696327.7769588463 +2021-11-18,False,1224.3359908573264,11500,999.0,2253,2250747.0,1627729.4102939153,623017.5897060847 +2021-11-19,False,1387.4505561364608,11996,999.0,2388,2385612.0,1695409.0872117465,690202.9127882535 +2021-11-20,False,1234.391016936102,11715,999.0,2312,2309688.0,1657237.4762444326,652450.5237555674 +2021-11-21,False,1391.1085092857672,11905,999.0,2497,2494503.0,1749892.989644486,744610.010355514 +2021-11-22,False,1426.0797581257254,11816,999.0,2366,2363634.0,1684428.6035378126,679205.3964621874 +2021-11-23,False,1187.0651373830954,11592,990.3048449071808,2985,2956059.962047935,1993700.7005774877,962359.2614704473 +2021-11-24,False,1489.5274787383933,11745,999.0,2418,2415582.0,1710498.11278819,705083.8872118101 +2021-11-25,False,1164.9431791650668,11614,999.0,2361,2358639.0,1681673.00878691,676965.99121309 +2021-11-26,False,1216.336362662697,11884,999.0,2363,2360637.0,1682728.0775989546,677908.9224010454 +2021-11-27,False,1171.9181163334167,11720,999.0,2333,2330667.0,1667681.398574778,662985.6014252219 +2021-11-28,False,1238.2022625425338,11880,999.0,2406,2403594.0,1704252.5535214555,699341.4464785445 +2021-11-29,False,1292.0243551283022,11716,999.0,2306,2303694.0,1654295.9364452502,649398.0635547498 +2021-11-30,False,1308.8703476008477,11827,999.0,2324,2321676.0,1663322.1786241042,658353.8213758958 +2021-12-01,False,1441.4424169185088,11781,999.0,2399,2396601.0,1700951.3308379557,695649.6691620443 +2021-12-02,False,1455.7791635263466,11787,999.0,2389,2386611.0,1695960.0921959034,690650.9078040966 +2021-12-03,False,1188.0415443123625,11738,999.0,2366,2363634.0,1684205.412039857,679428.5879601431 +2021-12-04,False,1349.1576128743009,11644,999.0,2266,2263734.0,1634361.0621701973,629372.9378298027 +2021-12-05,False,1144.5984229194862,11559,999.0,2345,2342655.0,1673647.5095543964,669007.4904456036 +2021-12-06,False,1283.5879440728272,11779,999.0,2429,2426571.0,1715787.7940076017,710783.2059923983 +2021-12-07,False,1228.9334152186473,11667,999.0,2444,2441556.0,1723246.706952974,718309.293047026 +2021-12-08,False,1226.6002981814427,11451,999.0,2278,2275722.0,1640227.680763916,635494.3192360839 +2021-12-09,False,1293.0336966848404,11673,999.0,2411,2408589.0,1706795.6846955223,701793.3153044777 +2021-12-10,False,1391.931054211707,11660,999.0,2344,2341656.0,1673396.5256801324,668259.4743198676 +2021-12-11,False,1127.6730635169558,11504,999.0,2345,2342655.0,1673627.9418490443,669027.0581509557 +2021-12-12,False,1451.6693350749617,11838,999.0,2267,2264733.0,1634962.526370441,629770.4736295589 +2021-12-13,False,1393.9255098522244,11891,999.0,2362,2359638.0,1682400.1943872918,677237.8056127082 +2021-12-14,False,1170.5997555556241,11810,999.0,2326,2323674.0,1664184.589324382,659489.4106756181 +2021-12-15,True,2238.413280924058,22050,904.221424896248,6866,6208384.303337638,3935251.4511579336,2273132.8521797047 +2021-12-16,False,1302.5248896093553,11659,999.0,2273,2270727.0,1637805.0972427926,632921.9027572074 +2021-12-17,False,1499.923431246786,11689,999.0,2229,2226771.0,1616010.1182835633,610760.8817164367 +2021-12-18,False,1178.903789720295,11616,999.0,2245,2242755.0,1623695.3318820642,619059.6681179358 +2021-12-19,False,1313.9632793532805,11872,999.0,2392,2389608.0,1697318.3805364755,692289.6194635245 +2021-12-20,False,1216.0992170239713,11674,999.0,2263,2260737.0,1632717.942365422,628019.0576345781 +2021-12-21,False,1221.6694229556986,11857,999.0,2322,2319678.0,1662223.8803319852,657454.1196680148 +2021-12-22,False,1336.426152333596,11822,999.0,2347,2344653.0,1674844.6942876505,669808.3057123495 +2021-12-23,False,1468.6876267483333,11959,999.0,2415,2412585.0,1708973.1519430291,703611.8480569709 +2021-12-24,False,1422.10554223167,11833,999.0,2420,2417580.0,1711433.542322422,706146.4576775781 +2021-12-25,False,1389.5765594005304,11792,999.0,2374,2371626.0,1688390.5991592521,683235.4008407479 +2021-12-26,False,1323.669512840681,11719,999.0,2293,2290707.0,1647826.358651759,642880.6413482409 +2021-12-27,False,1468.919401466979,11910,999.0,2366,2363634.0,1684473.2148726361,679160.7851273639 +2021-12-28,False,1296.9445626763536,11708,999.0,2241,2238759.0,1621810.4931748111,616948.5068251889 +2021-12-29,False,1449.5328713338872,11758,999.0,2298,2295702.0,1650454.7438660879,645247.2561339121 +2021-12-30,False,1433.5926575506528,11636,999.0,2316,2313684.0,1659452.424299017,654231.5757009829 +2021-12-31,False,1185.5341387206347,11588,999.0,2319,2316681.0,1660686.8825992297,655994.1174007703 diff --git a/docs/source/example_notebooks/2022 First Day.csv b/docs/source/example_notebooks/2022 First Day.csv new file mode 100644 index 000000000..00edfbb3a --- /dev/null +++ b/docs/source/example_notebooks/2022 First Day.csv @@ -0,0 +1,2 @@ +Date,Shopping Event?,Ad Spend,Page Views,Unit Price,Sold Units,Revenue,Operational Cost,Profit +2022-01-01,False,1392.3358280937282,10018,899.1,2756,2477919.6,1879401.202414113,598518.397585887 diff --git a/docs/source/example_notebooks/2022 First Quarter.csv b/docs/source/example_notebooks/2022 First Quarter.csv new file mode 100644 index 000000000..eb260c4ef --- /dev/null +++ b/docs/source/example_notebooks/2022 First Quarter.csv @@ -0,0 +1,91 @@ +Date,Shopping Event?,Ad Spend,Page Views,Unit Price,Sold Units,Revenue,Operational Cost,Profit +2022-01-01,False,1392.3358280937282,10018,899.1,2756,2477919.6,1879401.202414113,598518.397585887 +2022-01-02,False,1391.3913808337466,10038,899.1,2726,2450946.6,1864399.9104804778,586546.6895195222 +2022-01-03,False,1293.990843338987,9941,899.1,2656,2388009.6,1829299.397053411,558710.2029465891 +2022-01-04,False,1212.5903975212161,9950,899.1,2741,2464433.1,1871716.1029819865,592716.9970180136 +2022-01-05,False,1182.4698371589263,9764,899.1,2697,2424872.7,1849701.0618950732,575171.638104927 +2022-01-06,False,1467.445551067856,10207,899.1,2738,2461735.8000000003,1870468.5168295426,591267.2831704577 +2022-01-07,True,2141.808717727631,17412,831.3573114052718,5643,4691349.308259949,3323643.689932692,1367705.6183272572 +2022-01-08,False,1234.829256168011,10071,899.1,2723,2448249.3000000003,1862749.2170296635,585500.0829703368 +2022-01-09,False,1376.020055104923,10129,899.1,2688,2416780.8000000003,1845378.2985341656,571402.5014658347 +2022-01-10,False,1340.02761092149,9984,899.1,2794,2512085.4,1898350.3293293247,613735.0706706753 +2022-01-11,False,1273.287440057397,9863,899.1,2696,2423973.6,1849280.0494022565,574693.5505977436 +2022-01-12,False,1141.693146346015,9916,899.1,2759,2480616.9,1880646.1331021162,599970.7668978837 +2022-01-13,False,1155.81122050363,10173,899.1,2831,2545352.1,1916660.5228116934,628691.5771883067 +2022-01-14,False,1378.6091490867877,10145,899.1,2825,2539957.5,1913893.7435477874,626063.7564522126 +2022-01-15,False,1293.478645787744,10082,899.1,2770,2490507.0,1886306.3993566553,604200.6006433447 +2022-01-16,False,1235.8202923804415,10099,899.1,2860,2571426.0,1931237.6707989252,640188.3292010748 +2022-01-17,False,1249.9174124330566,9907,899.1,2717,2442854.7,1859750.6417620734,583104.0582379268 +2022-01-18,False,1271.47439232518,9888,899.1,2677,2406890.7,1839773.284036592,567117.4159634081 +2022-01-19,False,1373.2226475584066,9764,899.1,2696,2423973.6,1849376.4607885955,574597.1392114046 +2022-01-20,False,1340.3791158099252,10054,899.1,2768,2488708.8000000003,1885345.0795596098,603363.7204403905 +2022-01-21,False,1128.1931917991249,9924,899.1,2764,2485112.4,1883130.7364539118,601981.6635460882 +2022-01-22,False,1162.9911436309628,9648,899.1,2627,2361935.7,1814674.633357068,547261.0666429321 +2022-01-23,False,1128.2222747689384,9842,899.1,2545,2288209.5,1773630.7895691658,514578.7104308342 +2022-01-24,False,1113.8360503017068,9802,899.1,2649,2381715.9,1825615.6047651214,556100.2952348785 +2022-01-25,False,1410.401967178016,10229,899.1,2770,2490507.0,1886417.1431889622,604089.8568110378 +2022-01-26,False,1440.3835630651943,9978,899.1,2791,2509388.1,1896940.9275888735,612447.1724111266 +2022-01-27,True,2988.4214329976066,17915,831.9998636067619,6240,5191679.148906195,3622996.5890260655,1568682.559880129 +2022-01-28,False,1487.5363138089551,9990,899.1,2741,2464433.1,1871993.5629440963,592439.5370559038 +2022-01-29,False,1445.4390808945325,9964,899.1,2696,2423973.6,1849447.010754491,574526.5892455091 +2022-01-30,False,1444.1540175500318,10197,899.1,2770,2490507.0,1886446.0023766824,604060.9976233176 +2022-01-31,False,1246.8737599731749,10033,899.1,2745,2468029.5,1873754.1199982178,594275.3800017822 +2022-02-01,False,1481.7388652417399,10066,899.1,2730,2454543.0,1866503.6552066077,588039.3447933923 +2022-02-02,False,1399.5719382535456,9997,899.1,2704,2431166.4,1853399.9672306762,577766.4327693237 +2022-02-03,False,1241.4769716430899,10070,899.1,2704,2431166.4,1853247.3622717985,577919.0377282014 +2022-02-04,False,1455.5331575779842,10091,899.1,2760,2481516.0,1881466.3955227518,600049.6044772482 +2022-02-05,False,1101.6449199860515,9895,899.1,2717,2442854.7,1859602.5783715304,583252.1216284698 +2022-02-06,False,1328.6364164935533,9962,899.1,2817,2532764.7,1909837.6106419214,622927.0893580788 +2022-02-07,False,1308.069117200877,10016,899.1,2775,2495002.5,1888820.615166294,606181.8848337061 +2022-02-08,False,1132.7159762121048,9861,899.1,2659,2390706.9,1830632.84014718,560074.0598528199 +2022-02-09,False,1444.9425958010747,9861,899.1,2716,2441955.6,1859473.3602692473,582482.2397307528 +2022-02-10,False,1212.684467045,9972,899.1,2750,2472525.0,1876230.156967209,596294.843032791 +2022-02-11,False,1250.5400317812196,9750,899.1,2718,2443753.8000000003,1860258.2671390085,583495.5328609918 +2022-02-12,False,1290.0613657717636,9946,899.1,2790,2508489.0,1896301.7101192577,612187.2898807423 +2022-02-13,False,1426.7739321889594,10233,899.1,2829,2543553.9,1915938.2627990264,627615.6372009735 +2022-02-14,False,1337.9752123091835,10053,899.1,2839,2552544.9,1920840.759277585,631704.140722415 +2022-02-15,True,2351.475059441982,18894,790.8822013542945,6744,5333709.565933362,3874358.9633387243,1459350.6025946373 +2022-02-16,False,1244.9510303702357,9871,899.1,2774,2494103.4,1888252.9386465398,605850.4613534601 +2022-02-17,False,1211.8738687166879,9910,899.1,2711,2437460.1,1856714.7898701457,580745.3101298544 +2022-02-18,False,1291.248092774871,9977,899.1,2701,2428469.1,1851817.548661015,576651.5513389851 +2022-02-19,False,1202.2934128126344,10133,883.1651108098041,2780,2455199.0080512553,1891207.3343598437,563991.6736914115 +2022-02-20,False,1235.804575281713,10084,899.1,2696,2423973.6,1849246.6954483406,574726.9045516595 +2022-02-21,False,1276.1505339787307,10085,899.1,2656,2388009.6,1829286.22085432,558723.37914568 +2022-02-22,False,1437.4003457574522,9904,899.1,2799,2516580.9,1900942.7903318,615638.1096681999 +2022-02-23,False,1472.2042466986154,9964,899.1,2673,2403294.3000000003,1837976.7032677638,565317.5967322364 +2022-02-24,False,1431.896547822394,10172,899.1,2743,2466231.3000000003,1872944.902847496,593286.3971525042 +2022-02-25,False,1310.2798859572426,10076,899.1,2702,2429368.2,1852330.7801247423,577037.4198752579 +2022-02-26,False,1384.62290131771,10043,899.1,2648,2380816.8000000003,1825387.4752716604,555429.3247283399 +2022-02-27,False,1234.0834436842747,9702,899.1,2657,2388908.7,1829743.9021500424,559164.7978499578 +2022-02-28,False,1283.678769021713,9910,899.1,2682,2411386.2,1842284.07082779,569102.1291722101 +2022-03-01,False,1476.1958625388818,10020,899.1,2709,2435661.9,1855990.3574499364,579671.5425500635 +2022-03-02,False,1241.9789919979662,9898,899.1,2682,2411386.2,1842256.0852074374,569130.1147925628 +2022-03-03,False,1169.1942709029515,9892,899.1,2745,2468029.5,1873673.4418196054,594356.0581803946 +2022-03-04,False,1288.837622807191,10030,899.1,2698,2425771.8000000003,1850296.6598978532,575475.1401021471 +2022-03-05,False,1361.0366475166352,10010,899.1,2789,2507589.9,1895865.5077794136,611724.3922205863 +2022-03-06,False,1150.6057039233983,10086,899.1,2773,2493204.3000000003,1887675.9748459037,605528.3251540966 +2022-03-07,False,1148.8405674690443,9990,899.1,2773,2493204.3000000003,1887650.6458073962,605553.6541926041 +2022-03-08,False,1221.47795637576,9850,899.1,2726,2450946.6,1864229.4841102757,586717.1158897243 +2022-03-09,False,1463.0596405593335,10060,899.1,2781,2500397.1,1891973.8578367615,608423.2421632386 +2022-03-10,False,1369.841540397185,10100,899.1,2678,2407789.8000000003,1840391.6702139727,567398.1297860276 +2022-03-11,False,1188.773662552044,9895,899.1,2834,2548049.4,1918191.6567640717,629857.7432359282 +2022-03-12,False,1341.3950242487674,9934,899.1,2660,2391606.0,1831345.182388721,560260.817611279 +2022-03-13,False,1364.0959335247649,10107,899.1,2812,2528269.2,1907376.925745633,620892.2742543672 +2022-03-14,False,1309.221871963138,10024,899.1,2726,2450946.6,1864309.6853946745,586636.9146053256 +2022-03-15,False,1403.7529842149315,10026,899.1,2746,2468928.6,1874411.3054106305,594517.2945893696 +2022-03-16,False,1109.8955954636629,10165,899.1,2802,2519278.2,1902111.2872151928,617166.9127848074 +2022-03-17,False,1176.4468908415815,9992,899.1,2683,2412285.3000000003,1842689.52860202,569595.7713979804 +2022-03-18,False,1486.5486977700477,10155,899.1,2747,2469827.7,1875005.0228379683,594822.6771620319 +2022-03-19,False,1299.096000702733,9897,899.1,2750,2472525.0,1876301.3950001332,596223.6049998668 +2022-03-20,True,2959.005898764264,18781,852.3176505002403,5582,4757637.125092342,3293965.8953605895,1463671.229731752 +2022-03-21,False,1223.2718760871978,9911,899.1,2742,2465332.2,1872229.5640445976,593102.6359554026 +2022-03-22,False,1100.7089544693627,9934,899.1,2697,2424872.7,1849605.1051355922,575267.594864408 +2022-03-23,False,1331.7656967542457,9836,899.1,2683,2412285.3000000003,1842832.6021656336,569452.6978343667 +2022-03-24,False,1499.7913000398273,10077,899.1,2754,2476121.4,1878519.0568463928,597602.3431536071 +2022-03-25,False,1336.0397990084284,10141,899.1,2767,2487809.7,1884850.7572144207,602958.9427855795 +2022-03-26,False,1344.0291715257779,9881,899.1,2807,2523773.7,1904848.162184592,618925.5378154081 +2022-03-27,False,1231.0906450912316,9917,899.1,2755,2477020.5,1878736.1803134407,598284.3196865593 +2022-03-28,False,1194.813018241124,10016,899.1,2799,2516580.9,1900707.1235184686,615873.7764815313 +2022-03-29,False,1303.2626288160477,10058,899.1,2790,2508489.0,1896304.5482847781,612184.4517152219 +2022-03-30,False,1459.914466790956,10093,899.1,2845,2557939.5,1923968.4508365616,633971.0491634384 +2022-03-31,False,1103.9004416458804,9839,899.1,2756,2477919.6,1879111.1779584847,598808.4220415154 diff --git a/docs/source/example_notebooks/gcm_online_shop.ipynb b/docs/source/example_notebooks/gcm_online_shop.ipynb new file mode 100644 index 000000000..ff46385f1 --- /dev/null +++ b/docs/source/example_notebooks/gcm_online_shop.ipynb @@ -0,0 +1,702 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "1c74ae7a-e77a-4b38-be41-7fb82e6930a5", + "metadata": {}, + "source": [ + "# Causal attribution and root-cause analysis of an online shop" + ] + }, + { + "cell_type": "markdown", + "id": "52343f86-2a11-4785-ab98-e92687369566", + "metadata": {}, + "source": [ + "This notebook is an extended and updated version of the corresponding blog post: [Root Cause Analysis with DoWhy, an Open Source Python Library for Causal Machine Learning](https://aws.amazon.com/blogs/opensource/root-cause-analysis-with-dowhy-an-open-source-python-library-for-causal-machine-learning/)\n", + "\n", + "In this example, we look at an online store and analyze how different factors influence our profit. In particular, we want to analyze an unexpected drop in profit and identify the potential root cause of it. For this, we can make use of Graphical Causal Models (GCM)." + ] + }, + { + "cell_type": "markdown", + "id": "d1879d7f-73dc-4625-be07-b89abb4c5e46", + "metadata": {}, + "source": [ + "## The scenario" + ] + }, + { + "cell_type": "markdown", + "id": "6abcab21-f78e-4129-b37f-611271e2860b", + "metadata": {}, + "source": [ + "Suppose we are selling a smartphone in an online shop with a retail price of $999. The overall profit from the product depends on several factors, such as the number of sold units, operational costs or ad spending. On the other hand, the number of sold units, for instance, depends on the number of visitors on the product page, the price itself and potential ongoing promotions. Suppose we observe a steady profit of our product over the year 2021, but suddenly, there is a significant drop in profit at the beginning of 2022. Why?\n", + "\n", + "In the following scenario, we will use DoWhy to get a better understanding of the causal impacts of factors influencing the profit and to identify the causes for the profit drop. To analyze our problem at hand, we first need to define our belief about the causal relationships. For this, we collect daily records of the different factors affecting profit. These factors are:\n", + "\n", + "- **Shopping Event?**: A binary value indicating whether a special shopping event took place, such as Black Friday or Cyber Monday sales.\n", + "- **Ad Spend**: Spending on ad campaigns.\n", + "- **Page Views**: Number of visits on the product detail page.\n", + "- **Unit Price**: Price of the device, which could vary due to temporary discounts.\n", + "- **Sold Units**: Number of sold phones.\n", + "- **Revenue**: Daily revenue.\n", + "- **Operational Cost**: Daily operational expenses which includes production costs, spending on ads, administrative expenses, etc.\n", + "- **Profit**: Daily profit.\n", + "\n", + "Looking at these attributes, we can use our domain knowledge to describe the cause-effect relationships in the form of a directed acyclic graph, which represents our causal graph in the following. The graph is shown here:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "3e2cc4f9-539c-415d-98a5-3a35ebe226a8", + "metadata": {}, + "outputs": [], + "source": [ + "from IPython.display import Image\n", + "Image('online-shop-graph.png') " + ] + }, + { + "cell_type": "markdown", + "id": "83b77156-7395-4285-8d5d-6bb34cdcec76", + "metadata": {}, + "source": [ + "In this scenario we know the following:\n", + "\n", + "**Shopping Event?** impacts: \n", + "→ Ad Spend: To promote the product on special shopping events, we require additional ad spending. \n", + "→ Page Views: Shopping events typically attract a large number of visitors to an online retailer due to discounts and various offers. \n", + "→ Unit Price: Typically, retailers offer some discount on the usual retail price on days with a shopping event. \n", + "→ Sold Units: Shopping events often take place during annual celebrations like Christmas, Father’s day, etc, when people often buy more than usual. \n", + "\n", + "**Ad Spend** impacts: \n", + "→ Page Views: The more we spend on ads, the more likely people will visit the product page. \n", + "→ Operational Cost: Ad spending is part of the operational cost. \n", + "\n", + "**Page Views** impacts: \n", + "→ Sold Units: The more people visiting the product page, the more likely the product is bought. This is quite obvious seeing that if no one would visit the page, there wouldn’t be any sale. \n", + "\n", + "**Unit Price** impacts: \n", + "→ Sold Units: The higher/lower the price, the less/more units are sold. \n", + "→ Revenue: The daily revenue typically consist of the product of the number of sold units and unit price. \n", + "\n", + "**Sold Units** impacts: \n", + "→ Sold Units: Same argument as before, the number of sold units heavily influences the revenue. \n", + "→ Operational Cost: There is a manufacturing cost for each unit we produce and sell. The more units we well the higher the revenue, but also the higher the manufacturing costs. \n", + "\n", + "**Operational Cost** impacts: \n", + "→ Profit: The profit is based on the generated revenue minus the operational cost. \n", + "\n", + "**Revenue** impacts: \n", + "→ Profit: Same reason as for the operational cost." + ] + }, + { + "cell_type": "markdown", + "id": "ffcb5b7f-d5cb-4747-a558-125d889fdace", + "metadata": {}, + "source": [ + "## Step 1: Define causal model" + ] + }, + { + "cell_type": "markdown", + "id": "7c67d73a-e834-4dcf-9c61-7190ae82ba6a", + "metadata": {}, + "source": [ + "Now, let us model these causal relationships. In the first step, we need to define a so-called structural causal model (SCM), which is a combination of the causal graph and the underlying generative models describing the data generation process.\n", + "\n", + "The causal graph can be defined via:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "49665408-6239-4d17-ab3f-fca7a8bfbbd3", + "metadata": {}, + "outputs": [], + "source": [ + "import networkx as nx\n", + "\n", + "causal_graph = nx.DiGraph([('Page Views', 'Sold Units'),\n", + " ('Revenue', 'Profit'),\n", + " ('Unit Price', 'Sold Units'),\n", + " ('Unit Price', 'Revenue'),\n", + " ('Shopping Event?', 'Page Views'),\n", + " ('Shopping Event?', 'Sold Units'),\n", + " ('Shopping Event?', 'Unit Price'),\n", + " ('Shopping Event?', 'Ad Spend'),\n", + " ('Ad Spend', 'Page Views'),\n", + " ('Ad Spend', 'Operational Cost'),\n", + " ('Sold Units', 'Revenue'),\n", + " ('Sold Units', 'Operational Cost'),\n", + " ('Operational Cost', 'Profit')])" + ] + }, + { + "cell_type": "markdown", + "id": "22030101-2a98-42a0-80bc-c2aa3c1dd41a", + "metadata": {}, + "source": [ + "To verify that we did not forget an edge, we can plot this graph:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "47243f27-c8ef-40e2-9d88-ac9418a96393", + "metadata": {}, + "outputs": [], + "source": [ + "from dowhy.utils import plot\n", + "\n", + "plot(causal_graph)" + ] + }, + { + "cell_type": "markdown", + "id": "564df483-0f6c-4dfc-9075-13a6a175ee64", + "metadata": {}, + "source": [ + "Next, we look at the data from 2021:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "9d4f5efd-5873-46ed-9c3a-d5b644380f84", + "metadata": {}, + "outputs": [], + "source": [ + "import pandas as pd\n", + "import numpy as np\n", + "\n", + "pd.options.display.float_format = '${:,.2f}'.format # Format dollar columns\n", + "\n", + "data_2021 = pd.read_csv('2021 Data.csv', index_col='Date')\n", + "data_2021.head()" + ] + }, + { + "cell_type": "markdown", + "id": "7d00cb09-cc78-4a25-80c0-debca854beb9", + "metadata": {}, + "source": [ + "As we see, we have one sample for each day in 2021 with all the variables in the causal graph. Note that in the synthetic data we consider here, shopping events were also generated randomly.\n", + "\n", + "We defined the causal graph, but we still need to assign generative models to the nodes. We can either manually specify those models, and configure them if needed, or automatically infer “appropriate” models using heuristics from data. We will leverage the latter here:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "ffe4eb1d-3bf5-486b-947d-5d25115b5ab3", + "metadata": {}, + "outputs": [], + "source": [ + "from dowhy import gcm\n", + "\n", + "# Create the structural causal model object\n", + "scm = gcm.StructuralCausalModel(causal_graph)\n", + "\n", + "# Automatically assign generative models to each node based on the given data\n", + "auto_assignment_summary = gcm.auto.assign_causal_mechanisms(scm, data_2021, override_models=True, quality=gcm.auto.AssignmentQuality.GOOD)" + ] + }, + { + "cell_type": "markdown", + "id": "f4715b95-cf69-4f08-8d46-fafcd8daf5e8", + "metadata": {}, + "source": [ + "Whenever available, we recommend assigning models based on prior knowledge as then models would closely mimic the physics of the domain, and not rely on nuances of the data. However, here we asked DoWhy to do this for us instead.\n", + "\n", + "After automatically assign the models, we can print a summary to obtain some insights into the selected models:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "941a24d8-cb6c-442e-81d9-0d64bb5ec933", + "metadata": {}, + "outputs": [], + "source": [ + "print(auto_assignment_summary)" + ] + }, + { + "cell_type": "markdown", + "id": "107af355-2702-4ebc-aed7-620f40af1435", + "metadata": {}, + "source": [ + "As we see, while the auto assignment also considered non-linear models, a linear model is sufficient for most relationships, except for Revenue, which is the product of Sold Units and Unit Price." + ] + }, + { + "cell_type": "markdown", + "id": "23d6cb3b-c87f-4167-b7d8-7cb3a5ea3695", + "metadata": {}, + "source": [ + "## Step 2: Fit causal models to data" + ] + }, + { + "cell_type": "markdown", + "id": "26c28b4a-0bdc-4f69-92c1-d399fa9ad8af", + "metadata": {}, + "source": [ + "After assigning a model to each node, we need to learn the parameters of the model:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "2b032fa2-9348-418c-b62b-9ae77f49c342", + "metadata": {}, + "outputs": [], + "source": [ + "gcm.fit(scm, data_2021)" + ] + }, + { + "cell_type": "markdown", + "id": "dbcd704e-c5a2-4e9a-977a-1642039de03a", + "metadata": {}, + "source": [ + "The fit method learns the parameters of the generative models in each node. Before we continue, let's have a quick look into the performance of the causal mechanisms and how well they capture the distribution:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "ab315928-4d60-4008-abb9-a9030e4cad44", + "metadata": {}, + "outputs": [], + "source": [ + "print(gcm.evaluate_causal_model(scm, data_2021, compare_mechanism_baselines=True, evaluate_invertibility_assumptions=False, evaluate_causal_structure=False))" + ] + }, + { + "cell_type": "markdown", + "id": "b65c73b6-28af-4b57-b05f-c6c6245a714a", + "metadata": {}, + "source": [ + "The fitted causal mechanisms are fairly good representations of the data generation process, with some minor inaccuracies. However, this is to be expected given the small sample size and relatively small signal-to-noise ratio for many nodes. Most importantly, all the baseline mechanisms did not perform better, which is a good indicator that our model selection is appropriate. Note that even if the models have some inaccuracies, most of the GCM-based algorithms are generally robust against this." + ] + }, + { + "cell_type": "markdown", + "id": "a2e5acb0-f40e-4478-bee8-db3ff58bea21", + "metadata": {}, + "source": [ + "
\n", + "The selection of baseline models change be configured as well. For more details, take a look at the corresponding evaluate_causal_model documentation.\n", + "
" + ] + }, + { + "cell_type": "markdown", + "id": "38f4f1b8-6b22-4fc7-b824-a9cc60d48acc", + "metadata": {}, + "source": [ + "## Step 3: Answer causal questions\n", + "### What are the key factors influencing the variance in profit?" + ] + }, + { + "cell_type": "markdown", + "id": "05da7b43-cf79-439a-b1df-dc1052b5f41b", + "metadata": {}, + "source": [ + "At this point, we want to understand which factors drive changes in the Profit. Let us first have a closer look at the Profit over time. For this, we plot the Profit over time for 2021, where the produced plot shows the Profit in dollars on the Y-axis and the time on the X-axis." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "efe77b22-e99c-43e9-876f-4f7198d5b112", + "metadata": {}, + "outputs": [], + "source": [ + "data_2021['Profit'].plot(ylabel='Profit in $', figsize=(15,5), rot=45)" + ] + }, + { + "cell_type": "markdown", + "id": "1a3abec8-5615-47cf-a68d-cb9332ad3570", + "metadata": {}, + "source": [ + "We see some significant spikes in the Profit across the year. We can further quantify this by looking at the standard deviation:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "b3ff0966-ddaf-4b19-b9ba-1fe854092f43", + "metadata": {}, + "outputs": [], + "source": [ + "data_2021['Profit'].std()" + ] + }, + { + "cell_type": "markdown", + "id": "991220b2-dc3e-4d80-b8cf-1d7e02c42bdc", + "metadata": {}, + "source": [ + "The estimated standard deviation of ~259247 dollars is quite significant. Looking at the causal graph, we see that Revenue and Operational Cost have a direct impact on the Profit, but which of them contribute the most to the variance? To find this out, we can make use of the direct arrow strength algorithm that quantifies the causal influence of a specific arrow in the graph:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "ecef5abd-f551-444b-8ec4-53e224f6d529", + "metadata": {}, + "outputs": [], + "source": [ + "import numpy as np\n", + "\n", + "# Note: The percentage conversion only makes sense for purely positive attributions.\n", + "def convert_to_percentage(value_dictionary):\n", + " total_absolute_sum = np.sum([abs(v) for v in value_dictionary.values()])\n", + " return {k: abs(v) / total_absolute_sum * 100 for k, v in value_dictionary.items()}\n", + "\n", + "\n", + "arrow_strengths = gcm.arrow_strength(scm, target_node='Profit')\n", + "\n", + "plot(causal_graph, \n", + " causal_strengths=convert_to_percentage(arrow_strengths), \n", + " figure_size=[15, 10])" + ] + }, + { + "cell_type": "markdown", + "id": "e430b106-f341-4cae-9e80-80d5b543f805", + "metadata": {}, + "source": [ + "In this causal graph, we see how much each node contributes to the variance in Profit. For simplicity, the contributions are converted to percentages. Since Profit itself is only the difference between Revenue and Operational Cost, we do not expect further factors influencing the variance. As we see, Revenue has more impact than Operational Cost. This makes sense seeing that Revenue typically varies more than Operational Cost due to the stronger dependency on the number of sold units. Note that the direct arrow strength method also supports the use of other kinds of measures, for instance, KL divergence. \n", + "\n", + "While the direct influences are helpful in understanding which direct parents influence the most on the variance in Profit, this mostly confirms our prior belief. The question of which factor is ultimately responsible for this high variance is, however, still unclear. For instance, Revenue itself is based on Sold Units and the Unit Price. Although we could recursively apply the direct arrow strength to all nodes, we would not get a correctly weighted insight into the influence of upstream nodes on the variance.\n", + "\n", + "What are the important causal factors contributing to the variance in Profit? To find this out, we can use the intrinsic causal contribution method that attributes the variance in Profit to the upstream nodes in the causal graph by only considering information that is newly added by a node and not just inherited from its parents. For instance, a node that is simply a rescaled version of its parent would not have any intrinsic contribution. See the corresponding [research paper](https://arxiv.org/abs/2007.00714) for more details.\n", + "\n", + "Let's apply the method to the data:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "43e49972-b137-4cae-9ee7-5c5879ff01ed", + "metadata": {}, + "outputs": [], + "source": [ + "iccs = gcm.intrinsic_causal_influence(scm, target_node='Profit', num_samples_randomization=500)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "29424e87-5b18-49bc-9690-f09cd111bcd7", + "metadata": {}, + "outputs": [], + "source": [ + "from dowhy.utils import bar_plot\n", + "\n", + "bar_plot(convert_to_percentage(iccs), ylabel='Variance attribution in %')" + ] + }, + { + "cell_type": "markdown", + "id": "7b447b63-3bcc-4dae-80af-7f1c0daf1a1c", + "metadata": {}, + "source": [ + "The scores shown in this bar chart are percentages indicating how much variance each node is contributing to Profit — without inheriting the variance from its parents in the causal graph. As we see quite clearly, the Shopping Event has by far the biggest influence on the variance in our Profit. This makes sense, seeing that the sales are heavily impacted during promotion periods like Black Friday or Prime Day and, thus, impact the overall profit. Surprisingly, we also see that factors such as the number of sold units or number of page views have a rather small influence, i.e., the large variance in profit can be almost completely explained by the shopping events. Let’s check this visually by marking the days where we had a shopping event. To do so, we use the pandas plot function again, but additionally mark all points in the plot with a vertical red bar where a shopping event occured:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "a3853007-fb0c-4a1d-bcca-f7bdd4dcef13", + "metadata": {}, + "outputs": [], + "source": [ + "import matplotlib.pyplot as plt\n", + "\n", + "data_2021['Profit'].plot(ylabel='Profit in $', figsize=(15,5), rot=45)\n", + "plt.vlines(np.arange(0, data_2021.shape[0])[data_2021['Shopping Event?']], data_2021['Profit'].min(), data_2021['Profit'].max(), linewidth=10, alpha=0.3, color='r')" + ] + }, + { + "cell_type": "markdown", + "id": "53c60147-b7a5-4759-b9a5-ab5dffccf4e2", + "metadata": {}, + "source": [ + "We clearly see that the shopping events coincide with the high peaks in profit. While we could have investigated this manually by looking at all kinds of different relationships or using domain knowledge, the tasks gets much more difficult as the complexity of the system increases. With a few lines of code, we obtained these insights from DoWhy." + ] + }, + { + "cell_type": "markdown", + "id": "49d9e8a4-208a-490c-99d7-71faf9f53319", + "metadata": {}, + "source": [ + "### What are the key factors explaining the Profit drop on a particular day?" + ] + }, + { + "cell_type": "markdown", + "id": "1c55bcca-6c74-4302-942d-41308b4d931c", + "metadata": {}, + "source": [ + "After a successful year in terms of profit, newer technologies come to the market and, thus, we want to keep the profit up and get rid of excess inventory by selling more devices. In order to increase the demand, we therefore lower the retail price by 10% at the beginning of 2022. Based on a prior analysis, we know that a decrease of 10% in the price would roughly increase the demand by 13.75%, a slight surplus. Following the price elasticity of demand model, we expect an increase of around 37.5% in number of Sold Units. Let us take a look if this is true by loading the data for the first day in 2022 and taking the fraction between the numbers of Sold Units from both years for that day:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "c9be4254-9ac2-4abc-a3f3-906925dac53d", + "metadata": {}, + "outputs": [], + "source": [ + "first_day_2022 = pd.read_csv('2022 First Day.csv', index_col='Date')\n", + "(first_day_2022['Sold Units'][0] / data_2021['Sold Units'][0] - 1) * 100" + ] + }, + { + "cell_type": "markdown", + "id": "54b14bc7-6ca5-4492-896c-06f922d1198e", + "metadata": {}, + "source": [ + "Surprisingly, we only increased the number of sold units by ~19%. This will certainly impact the profit given that the revenue is much smaller than expected. Let us compare it with the previous year at the same time:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "16215ca0-00c9-411c-b293-675a4cb595c2", + "metadata": {}, + "outputs": [], + "source": [ + "(1 - first_day_2022['Profit'][0] / data_2021['Profit'][0]) * 100" + ] + }, + { + "cell_type": "markdown", + "id": "d82b028a-604b-4f3a-8ef8-b438e5afd592", + "metadata": {}, + "source": [ + "Indeed, the profit dropped by ~8.5%. Why is this the case seeing that we would expect a much higher demand due to the decreased price? Let us investigate what is going on here.\n", + "\n", + "In order to figure out what contributed to the Profit drop, we can make use of DoWhy’s anomaly attribution feature. Here, we only need to specify the target node we are interested in (the Profit) and the anomaly sample we want to analyze (the first day of 2022). These results are then plotted in a bar chart indicating the attribution scores of each node for the given anomaly sample:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "00c6b5bf-e6b7-456f-84f6-91e2cbda62d6", + "metadata": {}, + "outputs": [], + "source": [ + "attributions = gcm.attribute_anomalies(scm, target_node='Profit', anomaly_samples=first_day_2022)\n", + "\n", + "bar_plot({k: v[0] for k, v in attributions.items()}, ylabel='Anomaly attribution score')" + ] + }, + { + "cell_type": "markdown", + "id": "c963e664-b0a8-4b3e-8e29-2226989da017", + "metadata": {}, + "source": [ + "A positive attribution score means that the corresponding node contributed to the observed anomaly, which is in our case the drop in Profit. A negative score of a node indicates that the observed value for the node is actually reducing the likelihood of the anomaly (e.g., a higher demand due to the decreased price should increase the profit). More details about the interpretation of the score can be found in the corresponding [reserach paper](https://proceedings.mlr.press/v162/budhathoki22a.html). Interestingly, the Page Views stand out as a factor explaining the Profit drop that day as indicated in the bar chart shown here.\n", + "\n", + "While this method gives us a point estimate of the attributions for the particular models and parameters we learned, we can also use DoWhy’s confidence interval feature, which incorporates uncertainties about the fitted model parameters and algorithmic approximations:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "e48b4b77-7ee6-4669-be82-05d0d15f4065", + "metadata": {}, + "outputs": [], + "source": [ + "gcm.config.disable_progress_bars() # We turn off the progress bars here to reduce the number of outputs.\n", + "\n", + "median_attributions, confidence_intervals, = gcm.confidence_intervals(\n", + " gcm.fit_and_compute(gcm.attribute_anomalies,\n", + " scm,\n", + " bootstrap_training_data=data_2021,\n", + " target_node='Profit',\n", + " anomaly_samples=first_day_2022),\n", + " num_bootstrap_resamples=10)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "4c7b083f-ef7f-47e0-b72f-2d0d1b9501e1", + "metadata": {}, + "outputs": [], + "source": [ + "bar_plot(median_attributions, confidence_intervals, 'Anomaly attribution score')" + ] + }, + { + "cell_type": "markdown", + "id": "4708283b-07a1-4bc1-8956-e2f2089b5313", + "metadata": {}, + "source": [ + "Note, in this bar chart we see the median attributions over multiple runs on smaller data sets, where each run re-fits the models and re-evaluates the attributions. We get a similar picture as before, but the confidence interval of the attribution to Sold Units also contains zero, meaning its contribution is insignificant. But some important questions still remain: Was this only a coincidence and, if not, which part in our system has changed? To find this out, we need to collect some more data." + ] + }, + { + "cell_type": "markdown", + "id": "c2c82783-9a69-43c3-820c-048a6f5860bf", + "metadata": {}, + "source": [ + "
\n", + "Note that the results differ depending on the selected data, since they are sample specific. On other days, other factors could be relevant. Furthermore, note that the analysis (including the confidence intervals) always relies on the modeling assumptions made. In other words, if the models change or have a poor fit, one would also expect different results.\n", + "
" + ] + }, + { + "cell_type": "markdown", + "id": "a0836200-9c93-41ee-985c-0e48be6036a7", + "metadata": {}, + "source": [ + "### What caused the profit drop in Q1 2022?" + ] + }, + { + "cell_type": "markdown", + "id": "3a33d9bf-d001-4aec-b84d-a2891fa2e7bb", + "metadata": {}, + "source": [ + "While the previous analysis is based on a single observation, let us see if this was just coincidence or if this is a persistent issue. When preparing the quarterly business report, we have some more data available from the first three months. We first check if the profit dropped on average in the first quarter of 2022 as compared to 2021. Similar as before, we can do this by taking the fraction between the average Profit of 2022 and 2021 for the first quarter:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "d70a7edb-9374-4fce-b8d3-e9ef9f53f328", + "metadata": {}, + "outputs": [], + "source": [ + "data_first_quarter_2021 = data_2021[data_2021.index <= '2021-03-31']\n", + "data_first_quarter_2022 = pd.read_csv(\"2022 First Quarter.csv\", index_col='Date')\n", + "\n", + "(1 - data_first_quarter_2022['Profit'].mean() / data_first_quarter_2021['Profit'].mean()) * 100" + ] + }, + { + "cell_type": "markdown", + "id": "d29fd8e5-bacc-4ade-b1bd-af5c351bc4a8", + "metadata": {}, + "source": [ + "Indeed, the profit drop is persistent in the first quarter of 2022. Now, what is the root cause of this? Let us apply the [distribution change method](https://proceedings.mlr.press/v130/budhathoki21a.html) to identify the part in the system that has changed:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "7f4a5065-e436-46cd-be5e-e6c1274fc3b7", + "metadata": {}, + "outputs": [], + "source": [ + "median_attributions, confidence_intervals = gcm.confidence_intervals(\n", + " lambda: gcm.distribution_change(scm,\n", + " data_first_quarter_2021,\n", + " data_first_quarter_2022,\n", + " target_node='Profit',\n", + " # Here, we are intersted in explaining the differences in the mean.\n", + " difference_estimation_func=lambda x, y: np.mean(y) - np.mean(x)) \n", + ")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "fc2467b0-eb84-4f72-b895-954f5a8634e6", + "metadata": {}, + "outputs": [], + "source": [ + "bar_plot(median_attributions, confidence_intervals, 'Profit change attribution in $')" + ] + }, + { + "cell_type": "markdown", + "id": "5849dc6d-107b-4236-a31d-f4ac6f1b060a", + "metadata": {}, + "source": [ + "In our case, the distribution change method explains the change in the mean of Profit, i.e., a negative value indicates that a node contributes to a decrease and a positive value to an increase of the mean. Using the bar chart, we get now a very clear picture that the change in Unit Price has actually a slightly positive contribution to the expected Profit due to the increase of Sold Units, but it seems that the issue is coming from the Page Views which has a negative value. While we already understood this as a main driver of the drop at the beginning of 2022, we have now isolated and confirmed that something changed for the Page Views as well. Let’s compare the average Page Views with the previous year." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "34b11c19-1256-4ae0-9067-2eb374ce5147", + "metadata": {}, + "outputs": [], + "source": [ + "(1 - data_first_quarter_2022['Page Views'].mean() / data_first_quarter_2021['Page Views'].mean()) * 100" + ] + }, + { + "cell_type": "markdown", + "id": "9aa5baf0-ffd2-4eb1-8c47-e05f00351edd", + "metadata": {}, + "source": [ + "Indeed, the number of Page Views dropped by ~14%. Since we eliminated all other potential factors, we can now dive deeper into the Page Views and see what is going on there. This is a hypothetical scenario, but we could imagine it could be due to a change in the search algorithm which ranks this product lower in the results and therefore drives fewer customers to the product page. Knowing this, we could now start mitigating the issue." + ] + }, + { + "cell_type": "markdown", + "id": "fb9d91f2-ca4c-43cd-9499-245db5c9a577", + "metadata": {}, + "source": [ + "# Data generation process" + ] + }, + { + "cell_type": "markdown", + "id": "9053f3c6-5629-47c1-95b6-c7a3f3349ae5", + "metadata": {}, + "source": [ + "While the exact same data cannot be reproduced, the following dataset generator should provide quite similar types of data and has various parameters to adjust:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "1c4785f9-5ec1-4340-8837-6d0cdaf4c406", + "metadata": {}, + "outputs": [], + "source": [ + "from dowhy.datasets import sales_dataset\n", + "\n", + "data_2021 = sales_dataset(start_date=\"2021-01-01\", end_date=\"2021-12-31\")\n", + "data_2022 = sales_dataset(start_date=\"2022-01-01\", end_date=\"2022-12-31\", change_of_price=0.9)" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.9.16" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/docs/source/example_notebooks/nb_index.rst b/docs/source/example_notebooks/nb_index.rst index 030317b66..5452d452f 100644 --- a/docs/source/example_notebooks/nb_index.rst +++ b/docs/source/example_notebooks/nb_index.rst @@ -101,6 +101,15 @@ Real world-inspired examples .. grid:: 2 + .. grid-item-card:: :doc:`gcm_online_shop` + + .. image:: ../_static/online-shop.png + :height: 120px + :align: center + +++ + | **Level:** Beginner + | **Task:** Quantify causal effects and root cause analysis via GCM + .. grid-item-card:: :doc:`gcm_rca_microservice_architecture` .. image:: ../_static/microservice-architecture.png @@ -110,6 +119,8 @@ Real world-inspired examples | **Level:** Beginner | **Task:** Root cause analysis, intervention, counterfactual via GCM +.. grid:: 2 + .. grid-item-card:: :doc:`gcm_401k_analysis` .. image:: ../_static/401k-example.png @@ -119,8 +130,6 @@ Real world-inspired examples | **Level:** Advanced | **Task:** Intervention via GCM -.. grid:: 2 - .. grid-item-card:: :doc:`gcm_supply_chain_dist_change` .. image:: ../_static/supply-chain.png @@ -130,6 +139,8 @@ Real world-inspired examples | **Level:** Advanced | **Task:** Root cause analysis via GCM +.. grid:: 2 + .. grid-item-card:: :doc:`gcm_counterfactual_medical_dry_eyes` .. image:: ../_static/gcm-counterfactual-example.png @@ -139,8 +150,6 @@ Real world-inspired examples | **Level:** Advanced | **Task:** Counterfactuals via GCM -.. grid:: 2 - .. grid-item-card:: :doc:`gcm_falsify_dag` .. image:: ../_static/gcm-falsify-example.png @@ -328,6 +337,7 @@ Miscellaneous DoWhy-The Causal Story Behind Hotel Booking Cancellations dowhy_example_effect_of_memberrewards_program + gcm_online_shop gcm_rca_microservice_architecture gcm_401k_analysis gcm_supply_chain_dist_change diff --git a/docs/source/example_notebooks/online-shop-graph.png b/docs/source/example_notebooks/online-shop-graph.png new file mode 100644 index 000000000..dc0d72ab2 Binary files /dev/null and b/docs/source/example_notebooks/online-shop-graph.png differ