diff --git "a/Time series transformer Bitcoin.ipynb" "b/Time series transformer Bitcoin.ipynb" new file mode 100644--- /dev/null +++ "b/Time series transformer Bitcoin.ipynb" @@ -0,0 +1,2216 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "id": "2e104b86", + "metadata": {}, + "outputs": [], + "source": [ + "# Author: Yongcheng Zhan\n", + "# The purpose of this code is to use time series transformer to forecast bitcoin price in 2022\n", + "\n", + "# Steps:\n", + "# Step 1: Obtain bitcoin price\n", + "# Step 2: prepare data to the correct format\n", + "# Step 3: run the transformer program copied from the tutorial\n", + "# Step 4: calculate the performance" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "10cde338", + "metadata": {}, + "outputs": [], + "source": [ + "# Step 1: obtain bitcoin price\n", + "\n", + "from cryptocmd import CmcScraper\n", + "from datetime import datetime" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "id": "fbca9b69", + "metadata": {}, + "outputs": [], + "source": [ + "scraper = CmcScraper(\"BTC\")\n", + "headers, data = scraper.get_data()\n", + "start_date = datetime.strptime(\"01-01-2022\", r\"%d-%m-%Y\")\n", + "end_date = datetime.strptime(\"31-12-2022\", r\"%d-%m-%Y\")\n", + "\n", + "bitcoin_price_list = []\n", + "date_list = []\n", + "\n", + "for record in data:\n", + " date = datetime.strptime(record[0], r\"%d-%m-%Y\")\n", + " if(date >= start_date and date <= end_date):\n", + " date_list.append(date)\n", + " bitcoin_price_list.append(record[1])\n", + "\n", + " \n", + "date_list.reverse()\n", + "bitcoin_price_list.reverse()" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "id": "076493bb", + "metadata": {}, + "outputs": [], + "source": [ + "# compare with the huggingface example\n", + "\n", + "from datasets import load_dataset" + ] + }, + { + "cell_type": "code", + "execution_count": 19, + "id": "8043e4c8", + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "Using the latest cached version of the module from C:\\Users\\yozhan\\.cache\\huggingface\\modules\\datasets_modules\\datasets\\monash_tsf\\fc869f3ae1577c9def2a919ab1dd0c3d4a7a44826b8e0e8fa423bb0161b629e2 (last modified on Thu Jul 6 17:26:37 2023) since it couldn't be found locally at monash_tsf., or remotely on the Hugging Face Hub.\n", + "Found cached dataset monash_tsf (C:/Users/yozhan/.cache/huggingface/datasets/monash_tsf/tourism_monthly/1.0.0/fc869f3ae1577c9def2a919ab1dd0c3d4a7a44826b8e0e8fa423bb0161b629e2)\n" + ] + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "716a24321dcf419f967246a1e76d34de", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + " 0%| | 0/3 [00:00= start_date and date <= train_end_date):\n", + " train[\"target\"].append(record[1])\n", + " \n", + " if(date >= start_date and date <= val_end_date):\n", + " val[\"target\"].append(record[1])\n", + " \n", + " if(date >= start_date and date <= test_end_date):\n", + " test[\"target\"].append(record[1])\n", + "\n", + "\n", + " if(date < start_date):\n", + " break\n", + " \n", + " \n", + " train[\"feat_static_cat\"] = [i]\n", + " val[\"feat_static_cat\"] = [i]\n", + " test[\"feat_static_cat\"] = [i]\n", + " \n", + " train[\"item_id\"] = \"T{0}\".format(i+1)\n", + " val[\"item_id\"] = \"T{0}\".format(i+1)\n", + " test[\"item_id\"] = \"T{0}\".format(i+1)\n", + " \n", + " crypto_train.append(train)\n", + " crypto_val.append(val)\n", + " crypto_test.append(test)" + ] + }, + { + "cell_type": "code", + "execution_count": 62, + "id": "5fa40297", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'start': datetime.datetime(1979, 1, 1, 0, 0), 'target': [1149.8699951171875, 1053.8001708984375, 1388.8797607421875, 1783.3702392578125, 1921.025146484375, 2704.94482421875, 4184.41357421875, 4148.35400390625, 2620.72509765625, 1650.300048828125, 1115.9200439453125, 1370.6251220703125, 1096.31494140625, 978.4600219726562, 1294.68505859375, 1480.465087890625, 1748.865234375, 2216.920166015625, 4690.5185546875, 4682.8642578125, 2459.579833984375, 1484.4901123046875, 1028.985107421875, 1109.3648681640625, 960.8751220703125, 896.35009765625, 1118.6551513671875, 1619.9949951171875, 1847.994873046875, 2367.044921875, 4991.16015625, 4772.9443359375, 2894.678466796875, 1860.4801025390625, 1185.150146484375, 1313.659912109375, 1160.9150390625, 1061.5048828125, 1301.77001953125, 1794.3797607421875, 2106.455078125, 2789.034912109375, 4917.8466796875, 4994.4833984375, 3016.754150390625, 1941.505126953125, 1234.135009765625, 1378.72021484375, 1182.9749755859375, 1081.6600341796875, 1424.110107421875, 1774.5350341796875, 2115.420166015625, 2804.840087890625, 4849.498046875, 4937.47509765625, 3074.2236328125, 2063.42529296875, 1297.355224609375, 1350.710205078125, 1224.360107421875, 1165.815185546875, 1409.3299560546875, 2116.5498046875, 2357.135009765625, 2995.0703125, 5295.2119140625, 4957.90478515625, 3321.959228515625, 2221.18017578125, 1345.9000244140625, 1514.01513671875, 1239.5501708984375, 1172.159912109375, 1518.9752197265625, 1996.8751220703125, 2248.68505859375, 3053.440185546875, 5019.45361328125, 5466.7802734375, 3235.167724609375, 2157.97998046875, 1379.7252197265625, 1728.0400390625, 1350.10986328125, 1216.014892578125, 1751.3251953125, 1805.320068359375, 2570.02490234375, 3204.240234375, 5395.72021484375, 6078.82861328125, 3587.098388671875, 2285.195068359375, 1582.18994140625, 1787.4298095703125, 1554.8701171875, 1409.8648681640625, 1612.125, 2286.239990234375, 2913.755126953125, 3645.908447265625, 5956.70849609375, 6326.97509765625, 3914.66015625, 2617.675048828125, 1675.1650390625, 2139.219970703125, 1715.4898681640625, 1663.5799560546875, 2053.699951171875, 2354.929931640625, 3038.591796875, 3470.609375, 6606.18359375, 6587.63671875, 4133.78271484375, 2960.0244140625, 1762.5849609375, 2125.64013671875, 1815.9150390625, 1632.31494140625, 2210.39501953125, 2210.215087890625, 3099.269287109375, 3468.77783203125, 6482.92529296875, 6665.48486328125, 4006.36181640625, 2882.3349609375, 1775.2498779296875, 2171.64990234375, 1796.4749755859375, 1692.349853515625, 1949.78515625, 2680.630126953125, 2645.949951171875, 3414.742919921875, 5772.876953125], 'feat_static_cat': [0], 'feat_dynamic_real': None, 'item_id': 'T1'}\n" + ] + } + ], + "source": [ + "print(dataset[\"train\"][0])" + ] + }, + { + "cell_type": "code", + "execution_count": 72, + "id": "928125c8", + "metadata": { + "scrolled": true + }, + "outputs": [ + { + "ename": "TypeError", + "evalue": "'Dataset' object doesn't support item deletion", + "output_type": "error", + "traceback": [ + "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[1;31mTypeError\u001b[0m Traceback (most recent call last)", + "Cell \u001b[1;32mIn[72], line 17\u001b[0m\n\u001b[0;32m 12\u001b[0m dataset[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mtest\u001b[39m\u001b[38;5;124m\"\u001b[39m][i][attr] \u001b[38;5;241m=\u001b[39m crypto_test[i][attr]\n\u001b[0;32m 16\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m i \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mrange\u001b[39m(top_n, \u001b[38;5;28mlen\u001b[39m(dataset[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mtrain\u001b[39m\u001b[38;5;124m\"\u001b[39m])):\n\u001b[1;32m---> 17\u001b[0m \u001b[38;5;28;01mdel\u001b[39;00m dataset[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mtrain\u001b[39m\u001b[38;5;124m\"\u001b[39m][top_n]\n\u001b[0;32m 18\u001b[0m \u001b[38;5;28;01mdel\u001b[39;00m dataset[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mval\u001b[39m\u001b[38;5;124m\"\u001b[39m][top_n]\n\u001b[0;32m 19\u001b[0m \u001b[38;5;28;01mdel\u001b[39;00m dataset[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mtest\u001b[39m\u001b[38;5;124m\"\u001b[39m][top_n]\n", + "\u001b[1;31mTypeError\u001b[0m: 'Dataset' object doesn't support item deletion" + ] + } + ], + "source": [ + "# now replace\n", + "\n", + "# Okay this does not work, the next thing to try is to use load_dataset to load it to huggingface\n", + "\n", + "top_n = 10\n", + "attr_list = [\"start\", \"target\", \"feat_static_cat\", \"feat_dynamic_real\", \"item_id\"]\n", + "\n", + "\n", + "for i in range(top_n):\n", + " for attr in attr_list:\n", + " \n", + " dataset[\"train\"][i][attr] = crypto_train[i][attr]\n", + " dataset[\"validation\"][i][attr] = crypto_val[i][attr]\n", + " dataset[\"test\"][i][attr] = crypto_test[i][attr]\n", + " \n", + " \n", + "\n", + "for i in range(top_n, len(dataset[\"train\"])):\n", + " del dataset[\"train\"][top_n]\n", + " del dataset[\"val\"][top_n]\n", + " del dataset[\"test\"][top_n]" + ] + }, + { + "cell_type": "code", + "execution_count": 73, + "id": "16fc8681", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[{'start': datetime.datetime(2022, 1, 1, 0, 0), 'target': [20633.696071095317, 20817.982251842404, 20595.103841969667, 20287.956094786256, 20772.803027102687, 20092.23718809519, 19344.96442021395, 19567.769580384924, 19207.734650775248, 19172.380608580974, 19053.203045616505, 19138.08505687014, 19335.02644145188, 19550.466742932043, 19268.562102307453, 19068.91355993786, 19185.437303811446, 19382.53397217804, 19156.96661332697, 19052.64578600759, 19138.999877483147, 19446.416225133773, 19417.479411166132, 19546.328837739784, 19957.55908041741, 20161.03843820979, 20335.899579376473, 19623.584689448744, 19044.067849811498, 19311.848708225836, 19431.10494591723, 19573.431421230798, 19427.780190523128, 19104.620789502645, 19221.84071275122, 18803.90063289787, 18936.31151524196, 19296.990703569038, 19412.39992542163, 18534.64959547727, 18891.282889531798, 19545.591275415263, 19418.571421509565, 20127.23394762749, 19777.03402833151, 19704.005440526256, 20242.289908387913, 20184.555325164954, 22371.48063978407, 21770.14813305873, 21678.543569706628, 21376.91171453879, 19328.139929463316, 19289.940569121, 18837.683320773453, 19817.724065572373, 19988.789818433175, 19832.47129556646, 19969.718346916892, 20126.072780901522, 20050.498669841865, 19799.581315787203, 20298.61208082999, 19615.153362859797, 20041.03480395418, 20262.480311022402, 21596.085314556974, 21395.458389989148, 21526.455593085484, 21401.045669959727, 21531.46384880662, 21160.392783176445, 20872.842173501398, 23213.31324159989, 23341.038978010583, 23881.315512357407, 24126.136482577618, 24318.31548303852, 24429.05743708156, 24402.18747061798, 23957.20306053137, 23948.34612720597, 23162.89884942404, 23811.483521591905, 23179.527049985405, 22963.506243621858, 23291.42406079369, 22626.833391275144, 22848.214384500436, 22981.302705754573, 23308.43417279304, 23336.71805186043, 23652.069662121907, 23796.81861062155, 23845.212373894152, 22933.641248968772, 21244.16955918891, 21361.12187130348, 22607.155546771657, 22465.509266066096, 22706.983427210867, 23163.75206257678, 23233.20197091283, 23393.192011630057, 22467.85009614443, 20781.911503996675, 21195.041213834647, 20834.10412942899, 20573.156297917543, 20211.465955545355, 19325.972724650128, 19970.475022939816, 20856.35296768496, 21591.080802162654, 21716.82858548147, 21637.15505158262, 20547.81424115234, 20194.61949892409, 20225.353436423593, 19297.314185582756, 19242.094762817593, 19274.836282974753, 19820.4704741998, 20108.312337630447, 20281.16946117985, 20731.544346385122, 21028.238226728357, 21496.494739785347, 21233.60987142278, 21084.648061790565, 19986.60710158103, 20719.413927210015, 20594.29483720139, 20553.37025443907, 19010.902084120167, 20473.424978931507, 20385.718710143447, 22576.30534618698, 22196.730183479227, 22487.98717509208, 26737.577660148556, 28373.514252249453, 29084.666534527954, 30110.329519902793, 30215.278974580273, 31151.47989466442, 31371.741259994265, 29910.283723596356, 29835.118131770243, 29706.13957253697, 30467.806839606732, 29794.890079780234, 31792.553808712884, 31723.865101541804, 29443.365710983147, 29019.867414131473, 28842.10384461052, 29251.14086372044, 29564.77651079689, 29653.13529361965, 29101.125294324578, 30309.39648000864, 29432.47239860644, 29199.859006567556, 30311.1193461763, 28720.358563128946, 30424.479222550304, 29862.408192941577, 31304.37414424804, 30098.5866261369, 29285.643002871293, 29030.910391071633, 28936.7339259087, 31016.18275233353, 30273.65421884102, 34060.01548161972, 35502.940203830294, 36042.503693993414, 36573.18235500367, 39695.74635071903, 37748.0118484619, 38528.110038067374, 38472.1871454262, 37713.26508974102, 38605.858805370524, 39768.61581999673, 39241.42852522164, 38120.302630877784, 40448.42267445845, 39472.60737229702, 39478.37343720399, 39738.723269661496, 40525.861918239076, 41371.51504679231, 41501.744242424924, 40828.174203435905, 39721.202915300324, 40417.77626722159, 40552.31769418768, 39939.40395993831, 41160.21914540542, 40123.569761918385, 39533.71330624112, 42201.038230331425, 42781.09046341356, 42282.07939459544, 43505.13680265104, 43207.49887037383, 45544.35561952329, 46624.50707545264, 46445.271619629675, 45859.12870068277, 46285.49805877043, 45554.16381205456, 47062.14656183097, 47456.89702971699, 47100.43859807688, 46821.85024693429, 44505.35710237063, 44349.85843334273, 43964.54622463837, 42886.65421682143, 42364.3780528832, 41074.10451849765, 41246.13284847771, 42191.40531212776, 41794.64783390654, 40944.84167953429, 41140.84481577167, 39335.569403715985, 39664.25002606368, 37846.316439623675, 38884.7248489191, 38794.46318889842, 39439.96953161491, 41974.06923817848, 38742.81608045671, 38059.904292538864, 38429.30278301694, 39404.19892431593, 39148.44970501965, 42458.1411201421, 43925.195064951615, 44357.615244967536, 43194.504211304244, 37706.001266645675, 39098.69891124532, 39213.08378308136, 38333.74714480872, 37278.5650718651, 38285.28261421084, 37068.771436199466, 38423.209871915555, 40118.100621485086, 40026.02250608061, 40552.13257469959, 43937.07161828148, 44578.276206938615, 42586.464611620926, 42157.39915316259, 42236.56642632817, 42412.30031147502, 43571.13046337891, 44347.79883452384, 44096.704492042554, 43854.6536157814, 42406.7813264058, 41441.12079033813, 41501.480571936794, 37149.26414150606, 36944.805239029825, 38743.71342572458, 38481.765368511944, 37920.28099097226, 38151.918823373366, 37780.713786273285, 37128.444198943034, 36841.88060894733, 36950.51482868812, 36654.80592442568, 36275.732948124925, 35047.360289671895, 36471.58999992482, 40699.60698392732, 41744.02805917337, 42374.04061202849, 42250.07314461258, 43118.12010150989, 43172.038894674435, 43101.89961076399, 42598.87288897501, 43946.741717735065, 42742.17840595137, 41819.506970621274, 41910.2308272178, 41734.72756293196, 41561.46586768905, 43153.57087575333, 43565.51172706792, 45899.35873958258, 46458.85144441394, 47343.54376514904, 47680.926624830136, 46311.744663040976], 'feat_static_cat': [0], 'feat_dynamic_real': None, 'item_id': 'T1'}, {'start': datetime.datetime(2022, 1, 1, 0, 0), 'target': [1590.481270539271, 1619.697894352127, 1555.2746686159778, 1514.323161018284, 1566.841382393162, 1461.133194254422, 1344.7113448504042, 1363.4918066525345, 1314.2494524739777, 1299.902334592188, 1283.1880659091175, 1285.6602977072132, 1310.5631247277463, 1331.669920962133, 1306.309604668048, 1275.0055418167535, 1297.3059342987806, 1288.048713049968, 1294.9173837441601, 1279.7323077331587, 1291.1096715644455, 1322.6186703696521, 1315.4601836525053, 1332.3713375571574, 1351.8364466400985, 1352.8066306333058, 1361.9728718988222, 1323.2782963789423, 1276.163411650395, 1311.753422749603, 1328.1937206527582, 1335.6464707731384, 1337.5544530856334, 1329.5413435315777, 1335.3370295982977, 1294.386153951727, 1317.938519911025, 1328.24467283583, 1327.481169976172, 1251.5673910489745, 1324.2155942366371, 1377.6189623633902, 1335.2707285244724, 1469.7054512968161, 1432.8765064118675, 1471.9283652547956, 1635.0830291984064, 1574.8581446754465, 1713.962556385664, 1762.0848742134647, 1775.9760395663213, 1718.9613151355713, 1635.187757777287, 1629.8051395675518, 1560.9067726242395, 1617.240234875064, 1577.8840180830987, 1556.8959076585418, 1577.2137287900846, 1586.0179021807505, 1553.756391159599, 1524.2864673280128, 1553.188924850538, 1430.4394923917187, 1491.2068336172786, 1508.1570215664628, 1696.3246227233049, 1657.336514396027, 1662.695378856491, 1622.9393498092468, 1619.166813109356, 1576.5436232346658, 1612.650604689569, 1847.0953099595424, 1833.7155297434488, 1877.9342982164806, 1902.833139286399, 1936.7604877889612, 1981.7824124815077, 1957.3340422930657, 1880.8991913725793, 1851.82835513071, 1702.9064482914366, 1776.0713497470188, 1699.693431575998, 1691.7779509026886, 1732.6610906428295, 1607.5239348376886, 1618.8867212585917, 1633.0513165891366, 1634.645845292566, 1681.4455627267114, 1695.8847743025296, 1727.061942056886, 1725.6239155439503, 1636.231991326151, 1443.7268186612387, 1445.1511049337373, 1599.1572770220632, 1549.2225655788072, 1536.4573938265744, 1576.7453815608126, 1520.3744655335447, 1542.9543406284133, 1578.3838959310865, 1338.8060134638004, 1353.2050532184878, 1232.7916537880537, 1191.6747810387958, 1113.515759432295, 1038.186584567932, 1097.2592084326748, 1168.1390293968223, 1216.904363106791, 1222.3068438519879, 1237.5803684034133, 1186.9608986754013, 1134.8222934844712, 1150.509823405239, 1073.7942676360988, 1066.4674424234483, 1060.1212194119078, 1068.316818000208, 1099.3530920434682, 1144.5243643630229, 1193.253970589182, 1199.713077131478, 1242.9875673311815, 1226.7246799598265, 1143.2046590968714, 1051.3292849755123, 1125.372902209857, 1127.5118917723757, 1127.6562680704765, 993.4006602935043, 1086.3779599430145, 1067.9877175496733, 1233.6034660916775, 1211.3659620920544, 1204.5553442318271, 1443.8354737062982, 1530.1896952144793, 1665.21793701738, 1789.689939573479, 1793.512806862918, 1814.1006537465569, 1859.3337559904094, 1805.6360182342873, 1801.8190083175557, 1775.2208247890328, 1834.1350208550564, 1822.412115550511, 1942.0506177248408, 1996.4080538851465, 1811.8860421101833, 1792.1844451290387, 1762.4821598245408, 1802.5438652760563, 1945.033359536731, 1978.6770417607845, 1972.3908707353557, 2042.344786179666, 1974.670603919785, 1961.0179963528697, 2018.000129870723, 1916.1495138509135, 2090.459885553642, 2022.8823537738633, 2145.8368067731053, 2056.1832217104757, 2014.2806657431474, 1960.1225470264421, 2072.5045784196136, 2342.7542519691524, 2242.650344690437, 2518.508380528894, 2636.121782691565, 2694.99184556283, 2748.931576804914, 2940.226646817108, 2783.1312098217845, 2857.1522977457503, 2827.61399644621, 2729.994198702286, 2815.53341994947, 2936.7765387601476, 2888.8497890382296, 2808.64608851381, 3008.946342750078, 2922.9901873350395, 2937.3471671524317, 2964.802310414419, 2986.9387268138157, 3077.8293698809234, 3103.9349763576315, 3057.5702607438043, 2993.4838088844936, 3061.8819276333156, 3041.123198912779, 3020.134530768363, 3117.8217454627797, 3029.877916167813, 2981.4206935274856, 3209.576992525944, 3261.291416623483, 3191.9760162094085, 3233.2724023532446, 3172.1973614503872, 3411.672097476066, 3521.2397830665295, 3522.3649308715867, 3444.8106629310482, 3449.7886623859326, 3282.5761675899967, 3385.2893589839086, 3401.5262172196585, 3335.0211544606664, 3292.322394119644, 3143.795603403364, 3106.405395018773, 3108.4490361844128, 3031.0608259816645, 2973.1450502842395, 2897.7740978843085, 2860.103182092205, 2946.5476548411452, 2944.7217436815426, 2814.434669620251, 2771.9640191501067, 2620.0284850657113, 2590.668933852167, 2518.486310962477, 2573.487982305509, 2559.660726166692, 2608.271174522674, 2729.1165507057603, 2577.1653630691885, 2497.7214311429725, 2555.297578232919, 2664.943597268984, 2618.4735331241145, 2834.9874030791343, 2950.156661786821, 2972.471971041683, 2919.775877952208, 2621.1721497980047, 2780.5043817430683, 2764.989506707563, 2598.4362908278863, 2588.166182727787, 2639.447010232523, 2572.898566932548, 2627.665450650613, 2763.7566583663634, 2784.872899261173, 2884.340648342292, 3126.8584998524475, 3180.4468041023815, 2933.7291030565552, 2880.187675544802, 2916.7894701585146, 2927.386411050631, 3077.413063393154, 3240.1131442525516, 3121.1825430252843, 3143.0084647843964, 3057.4219983770454, 3014.9597560598777, 2984.44600116913, 2681.057587755385, 2682.2260400518285, 2791.958877885991, 2687.89895169732, 2603.263396351181, 2598.5649902951563, 2546.590514494874, 2421.6469102964784, 2467.188459547473, 2455.57907188928, 2440.3934604949613, 2535.891002185269, 2406.9244157031853, 2561.145322027309, 3002.956891275347, 3095.2716123862688, 3163.8502713069984, 3212.287601923892, 3350.9471774776275, 3330.3870946805046, 3309.8442103283305, 3248.648801333647, 3372.104952721625, 3238.4499924874444, 3082.9909615475603, 3157.570466972131, 3091.69637194102, 3193.5025462263275, 3417.8378749353446, 3549.7091041060817, 3794.2691446284102, 3761.361569175725, 3829.535741146812, 3769.2984373233558, 3683.0471559385887], 'feat_static_cat': [1], 'feat_dynamic_real': None, 'item_id': 'T2'}, {'start': datetime.datetime(2022, 1, 1, 0, 0), 'target': [313.67136628825887, 304.2299115476837, 298.0037869915752, 286.841147341349, 290.39200714742657, 284.3562116370403, 273.9513544696673, 276.00076757001926, 270.4799658832751, 270.03308693286147, 269.24490184276476, 271.95372718520304, 273.2234571967892, 275.5345169356507, 272.50193683144147, 268.4115804977468, 269.55903327104454, 271.8459266131074, 270.95872025684594, 271.40662588243316, 271.73153108519534, 278.2445744243328, 276.4495473724911, 282.99418745156197, 286.77193152903374, 294.15526535000953, 296.28945258766544, 287.0241821484564, 284.4148809730451, 282.8950617426524, 284.273408144076, 283.83429043124363, 281.76666404908843, 272.33443907408383, 275.9259562547846, 274.1417922989435, 275.104333958941, 276.6270557789035, 275.4935111398298, 264.60777142476894, 266.39474279943084, 272.1305576186701, 266.2519302425153, 279.22072461820215, 274.73000951321785, 270.81224242384553, 279.38305343784486, 277.41331054967935, 293.6492443922747, 295.174093451079, 296.91972887398714, 293.39508802492577, 280.53703147975295, 278.760236441755, 262.6126259561502, 276.7518680079798, 278.8544921665001, 277.7819225142169, 277.43110659530106, 278.38796025626465, 279.25132978954474, 281.4564859837996, 286.2152822684137, 276.28060866561367, 277.80342403261704, 279.57182750700025, 301.5560117491421, 296.4873149603562, 299.015106912741, 300.5709109008865, 302.03419439564976, 283.63910137152817, 279.62012400024446, 298.15275947858737, 306.79647085833363, 316.40159723668506, 319.7127549877299, 318.03247950448105, 323.9740904763649, 327.57416965710854, 323.772140455303, 328.46020892139956, 324.85903907782966, 324.83636602469693, 322.95479565157495, 315.1231020057738, 315.19697880370626, 310.693617200276, 298.3701114633993, 283.8738430730697, 283.4763394494164, 283.629495145828, 287.57725028749053, 293.91510090027583, 277.3141056169573, 271.51534104229194, 249.01580191264762, 245.12366989095062, 261.84101348602644, 259.47387353324217, 262.7201399437281, 265.4770257353444, 258.34010889898354, 268.77269523098477, 264.49494291812704, 247.83446597930643, 249.64080067750803, 238.55906945075876, 238.22662594114956, 230.5123346234994, 220.49241391871166, 225.86839862610748, 234.59936111620414, 243.25093662660433, 240.75657163595613, 241.54443892172048, 238.5029624458091, 230.9110885992744, 231.4841223738742, 218.97861211218776, 218.04757817568918, 216.2319813074463, 219.5289969502981, 219.38757333119, 226.90460499282497, 233.57284537955866, 233.83366469236458, 239.6125787626895, 240.26216883912312, 228.92286455926933, 214.23103465932232, 219.6733958422424, 216.9011120589775, 214.87973958702244, 196.95580141393495, 215.8156132274474, 209.7086749148143, 233.467859262343, 223.1894360721179, 222.5521996640876, 255.66772000347413, 269.66255908614613, 286.1053717121522, 289.88857379357967, 288.61754151507864, 290.2988417166576, 295.37340432462173, 298.98460183423055, 301.5979103050157, 298.5028294951011, 308.19417614694976, 300.4664641601799, 320.47203049158554, 321.7203074521428, 305.9440890247269, 307.75253502489045, 302.43501637196925, 304.7908214720677, 325.7552907475704, 328.19568834430873, 316.8508326727037, 319.5171331156382, 312.4880427828628, 302.36592307510637, 306.7810729143085, 287.4504850018503, 305.98987722541426, 297.6993210351457, 312.0841453734091, 297.39735846106515, 290.61807697366373, 269.14273821861923, 269.8880071712337, 319.122782140709, 298.82072140741934, 355.3774116840808, 365.73301341012916, 379.2881845279942, 378.75675318569796, 402.46521287792996, 383.4835433013598, 389.63415037564147, 390.26126792941704, 377.7656539100758, 392.99853561231356, 406.6417339452092, 391.43864753915966, 385.5621789442328, 404.26884858021185, 399.1298993432591, 401.52501039210676, 406.9933589761907, 404.96698173948124, 418.3168515060548, 422.36427374028597, 417.00766015088294, 407.4329316632499, 417.4115328912259, 417.293880499674, 414.66711172627896, 423.0670215564939, 413.8126654492081, 394.2887910773808, 418.65844426425565, 427.1497599458156, 421.6653411190104, 436.9345033436796, 420.1826553007935, 445.0011199419172, 447.6300228013563, 450.26456899841594, 436.86580808117594, 446.8442102684223, 429.12403162262376, 442.65886480458965, 434.4297122576953, 430.0749009238436, 430.5468075837259, 415.93136644505006, 410.81624958909146, 414.148240502879, 408.55427071299226, 404.3272704675081, 396.35558163153195, 390.73894267106385, 399.91973771584014, 397.561645740046, 391.7787848705817, 385.45955766441966, 371.5427845308665, 373.4724237022874, 361.83453485886565, 372.6088988166816, 372.1861897528607, 372.1961219702258, 393.48036946273356, 382.0426413167543, 381.2547569044289, 375.07160923394736, 384.9117900019062, 374.44166115612416, 402.57520886241207, 409.03273134827305, 408.51853824705296, 395.6241248128741, 360.38216248133057, 373.5999763018496, 374.8885698072493, 361.21600774313464, 366.3491879712487, 374.2992772275978, 356.7254791799168, 380.7365289475192, 400.00337388695624, 399.5214226307383, 402.64985223427567, 427.54991579796655, 432.4919394715267, 403.6642062785254, 398.64313340570453, 403.2715621484547, 400.4990320539179, 415.18718024863296, 422.5140421012781, 408.5169061991509, 433.45911097580023, 419.66643894262455, 414.21724110322805, 399.1488677904192, 370.7108505708097, 367.37086056725786, 385.48877077501766, 375.099167637429, 377.649002006088, 389.20220280613285, 386.06572393240907, 390.0006758083818, 375.5421804327546, 384.58623022823707, 371.3868503318323, 384.0406232196313, 358.32658669460324, 383.47455082193267, 440.067140617496, 462.85697221694693, 471.9172047163861, 475.73640563377216, 498.50615927462457, 494.9240939504661, 489.91800774996653, 475.1271834068579, 487.0425827365211, 463.5627407146006, 424.8912140564702, 438.78565052311006, 430.25312515560256, 447.8568043662897, 473.00007138095987, 475.0790560160165, 507.59780987935517, 512.1303320167277, 531.388837432606, 527.2916510291448, 511.91035590059], 'feat_static_cat': [2], 'feat_dynamic_real': None, 'item_id': 'T3'}, {'start': datetime.datetime(2022, 1, 1, 0, 0), 'target': [0.45840073177176166, 0.4704073826389083, 0.47398410103636784, 0.4624273737218989, 0.4693945933306549, 0.4614663539018822, 0.4538067426186708, 0.46903710786074765, 0.4654899482118339, 0.4610865814464122, 0.4480039121926002, 0.45122286343540363, 0.4659877403095364, 0.47991776696601784, 0.47701107747029486, 0.48152971277470064, 0.48895674583061627, 0.480806177967671, 0.48835270831256405, 0.4854125557830225, 0.4966607908266544, 0.5340287496779325, 0.5171489683380924, 0.5182248462641567, 0.49327699624358534, 0.4896992174546192, 0.4801206582383841, 0.4628784174077835, 0.44886773094314836, 0.4751191539681062, 0.47982184207167805, 0.4854345615040766, 0.4505935234645277, 0.4486359047025912, 0.46776409750448517, 0.49268135831878407, 0.4887321183790524, 0.5072002026852322, 0.48513688415784106, 0.3965384529154803, 0.4151655586693515, 0.38695800036587624, 0.35833689373753197, 0.37686751129112983, 0.35664743628391854, 0.3263842531125852, 0.3420747143464157, 0.332960222021604, 0.3594643311890497, 0.3551452507614001, 0.3576826232823959, 0.3574676929379069, 0.34022693250383473, 0.33733713542577703, 0.3221581139356575, 0.332968092065238, 0.3317992837195269, 0.3299592308304404, 0.33126398627056236, 0.33317302459500425, 0.3278670237313168, 0.3268865306488063, 0.3337794345599893, 0.3230550231066117, 0.33532943022105643, 0.3384333778716363, 0.34946391802664917, 0.3461793484718464, 0.3470743504881416, 0.34473373641275107, 0.3452821873563804, 0.3374750356358147, 0.33501972799597807, 0.37096905531468305, 0.37971082368107706, 0.3772268289981921, 0.3756656458464028, 0.3764509251198046, 0.3779985085253843, 0.3799738263790152, 0.380538267421551, 0.381098180436394, 0.3680800335278969, 0.37877708337058147, 0.3725146077450732, 0.3715940800249368, 0.3766049957447208, 0.3712778544482004, 0.3698616383474389, 0.37203924241499076, 0.3799112430090702, 0.3803517300765245, 0.3877751100352612, 0.368668421483287, 0.3733866895742964, 0.35914342229965035, 0.33782567000429925, 0.3373053436161792, 0.3592269146885782, 0.3595334911602153, 0.3585219534350945, 0.3670332299278272, 0.36066159452856655, 0.3732569970113353, 0.36602516337066454, 0.343424126813208, 0.3508517061065839, 0.33449320939936733, 0.33321373474013266, 0.32375011876994914, 0.31165892166751363, 0.3142961117765632, 0.3256586031493474, 0.3449302453424206, 0.34159852070758684, 0.34216709963329867, 0.3322632085748952, 0.3254604388937889, 0.3287028209704552, 0.32168841292491823, 0.31557348342989566, 0.31372427555193944, 0.3316452612704142, 0.32900195096196744, 0.33737166646121564, 0.3532345451126196, 0.3588627865053846, 0.36753314966566963, 0.3676233072437729, 0.33550878959211294, 0.32259134743196116, 0.32872859758238526, 0.3232839502553133, 0.32602029374786107, 0.30803292443508146, 0.321331238252605, 0.31214530032390353, 0.34368352016037973, 0.32209896743401367, 0.3108213810172932, 0.34540910193701563, 0.35909081919109875, 0.3817643640895207, 0.4003160802174593, 0.40065765071771353, 0.4076909044246038, 0.4030086521939821, 0.39540169746274123, 0.39232412383434273, 0.39078059516432173, 0.40531475863500316, 0.39807935861745375, 0.4218885583038591, 0.41812619222826547, 0.38901945818551265, 0.3863307169858439, 0.38658733209526286, 0.3930759875221602, 0.40579871378115145, 0.4087001760018018, 0.40468105704074664, 0.42225951292789243, 0.414691143848318, 0.411127960805514, 0.41992696460462353, 0.4060619720143269, 0.4376361170424177, 0.42245735222780395, 0.44740716178870965, 0.42768675099129255, 0.42341888207528444, 0.3851784038663123, 0.41339884751438843, 0.5135434643655599, 0.49244019703338954, 0.5665190266363499, 0.5823985939491462, 0.6025610895452694, 0.5988319004193036, 0.6464627145240798, 0.6048043265391796, 0.614217957942642, 0.6078193716897123, 0.5870855642316054, 0.6114048241432196, 0.6442844939306628, 0.6523128329226768, 0.6417944909257027, 0.6943344809827049, 0.6987566401409182, 0.7074867025643361, 0.7191442719842578, 0.733160140105266, 0.7521774340298554, 0.7750548101152985, 0.7680421980409418, 0.7531869036170633, 0.781792396537245, 0.7856534269718516, 0.7267961934733781, 0.7237379907080067, 0.7165117729502013, 0.6951693418300102, 0.7564220765930513, 0.7636037388028978, 0.7540405288573846, 0.7879965597717483, 0.761361075693168, 0.8176269837677523, 0.8272272411985763, 0.8429234629668109, 0.8248906096042109, 0.8277351439414455, 0.814709085825951, 0.8608799806724232, 0.8579417282232603, 0.8630889994137481, 0.8574084206710081, 0.8328145673012808, 0.8251532797895204, 0.8429677343720862, 0.8378573379192148, 0.8371335352900691, 0.8380351199863507, 0.8059627632011033, 0.8193790460627228, 0.7981267870782569, 0.7934507915161123, 0.7934358567359513, 0.7667473757835948, 0.7746373085956011, 0.7613759698582896, 0.7865376000277492, 0.8022294602288614, 0.7375057894256797, 0.7670268443375291, 0.721005963967619, 0.7232308363101128, 0.7260110175267238, 0.754923390184515, 0.7127899120296147, 0.7522955832387689, 0.7685323427681594, 0.7848759012497777, 0.7820701918048202, 0.7219307451045744, 0.750965954314652, 0.7686452674054116, 0.6962579307550214, 0.6985802831843683, 0.7228520831666679, 0.703332871369184, 0.7781600062964261, 0.8225378951252112, 0.7858648846948734, 0.767285872998878, 0.8387141634927026, 0.8523770618332898, 0.8022463863481049, 0.8098727174111698, 0.8222333020304279, 0.7602496997245921, 0.8299411055190062, 0.8708756365694895, 0.8775149755502539, 0.8283767771595594, 0.6835920635041834, 0.6671265445984295, 0.6558309285117385, 0.6076196474026964, 0.6014147656383583, 0.6292399818592249, 0.6190061463431678, 0.6030625347666009, 0.6170055963442225, 0.612490889519255, 0.6086187907738414, 0.6219448390608042, 0.6175441440796035, 0.6121439066073472, 0.6287699275563453, 0.5961931259537564, 0.6360062021055599, 0.7196089347290647, 0.7397255721821748, 0.7526142240698576, 0.7627691314811033, 0.7789993420933025, 0.7813081697514365, 0.77430899344728, 0.7683577122788915, 0.7994549766071192, 0.770607506243306, 0.7393564165851635, 0.7544278865582394, 0.7477330587988819, 0.7631056922020168, 0.7812695426672468, 0.7742999928228982, 0.824714308319222, 0.8328512727441308, 0.8591072786227029, 0.8494420683611206, 0.8312811799593212], 'feat_static_cat': [3], 'feat_dynamic_real': None, 'item_id': 'T4'}, {'start': datetime.datetime(2022, 1, 1, 0, 0), 'target': [0.40603008920145206, 0.41986364642359686, 0.40450790904523765, 0.3886714389982977, 0.40351086727030167, 0.401672190307465, 0.35783776066058165, 0.3620961476779107, 0.3513981517091106, 0.3490976302265782, 0.3402510916991275, 0.3500437273854767, 0.36189239815191854, 0.3723425464542073, 0.3702710709207616, 0.3638127724486792, 0.3668491661617425, 0.3776290829584588, 0.3813226794942883, 0.39058275719933916, 0.40173484783622176, 0.423054054621014, 0.4217913167990483, 0.4242534085658341, 0.4286930536702479, 0.43126508936055336, 0.43577675688127665, 0.42800343664122986, 0.4196436650011792, 0.43028402395919646, 0.43442878358117293, 0.4381827834612255, 0.4373081757853876, 0.4417824305847151, 0.4468189056281826, 0.4462988359545457, 0.45159854506858904, 0.46182971159295216, 0.45895082084843336, 0.4408759980020715, 0.4419508420139572, 0.45354267303846524, 0.4472834764154345, 0.4870910070324361, 0.4742205339120961, 0.46570344123608204, 0.48137358781552325, 0.46391221842574876, 0.5014950094057153, 0.5097513177027725, 0.5123800393940334, 0.5028416657041498, 0.47925335776814426, 0.47927448639142745, 0.46301070924836546, 0.4990911653881262, 0.5031675061680635, 0.4803717734213424, 0.4545335858931402, 0.4574643553202426, 0.4466772826242873, 0.45226280352540216, 0.45073625401051903, 0.4300701505380056, 0.44971927612189255, 0.43103862609225835, 0.46495864937651327, 0.4581081750180748, 0.46518173640707333, 0.4614832675864238, 0.463535826840019, 0.45126613452749337, 0.4508745836732884, 0.5126979268499811, 0.5373000854662728, 0.5579208035900172, 0.5510043681099751, 0.5703856399193394, 0.5598187348147016, 0.5407084494740162, 0.5311949078496727, 0.5371037736472087, 0.5139920997967113, 0.5366562861034242, 0.5274884577535979, 0.5113722815568464, 0.5175641680920663, 0.49958210328315683, 0.5009754327055174, 0.4968659059063659, 0.5139073660366744, 0.5170513016649273, 0.5255932642552552, 0.5232188090263201, 0.5132279019368977, 0.5105796142113717, 0.46771324709981144, 0.4762980277232775, 0.5137628339867741, 0.5173597473884282, 0.4837271219135847, 0.50009069548786, 0.4910706629179186, 0.5158006744167185, 0.4920777490426512, 0.44741494810844923, 0.45731784577820994, 0.4424453416751551, 0.4411149392086515, 0.4380571588078916, 0.4178813048558941, 0.4355809369018094, 0.4631805517440273, 0.4787710669796251, 0.467289865617156, 0.4778169665418062, 0.4622100246882674, 0.4576675256878333, 0.46956897063319736, 0.4556124040192984, 0.45632114183017375, 0.4481798693971585, 0.45931227974270855, 0.46560202737773004, 0.46967341400916296, 0.48557120000409354, 0.48955807413283314, 0.4988764508315748, 0.499233306677794, 0.4801989510126378, 0.4586515686079207, 0.47950613618442217, 0.4922700705732403, 0.48440339136337335, 0.45597049416891855, 0.48736658428020313, 0.4751833583185362, 0.5335286351020961, 0.48415979353091537, 0.46325105693990115, 0.4961004139444031, 0.552976516887457, 0.5742682871447641, 0.6328628166069399, 0.6416487771161301, 0.6154851579758839, 0.6093399715346223, 0.5672068784781844, 0.5660912119158443, 0.5599570546560687, 0.5878361508202106, 0.552635887884544, 0.6254165823063333, 0.5699998565073773, 0.4811341997706527, 0.4647323884169443, 0.45817576989905756, 0.4806429082166517, 0.5139527740927707, 0.5212424889680809, 0.5126867706583635, 0.5424835682328544, 0.5283443692453309, 0.5179049367584414, 0.5333642072102729, 0.5054987151826827, 0.5780570026488379, 0.5566957821921056, 0.597568812707074, 0.5393861173497325, 0.5289423974134696, 0.4734180394611871, 0.5129989971307671, 0.6287721688301248, 0.6099715320303427, 0.7395091069426819, 0.7620531739678592, 0.783352497047961, 0.7910645184868247, 0.8970609197666127, 0.7711069405753566, 0.7814303587213223, 0.7902788765145387, 0.7567005979774043, 0.8050556683765902, 0.8439298664293072, 0.8406147282706066, 0.8275408077677582, 0.8985767824349142, 0.8863779310696387, 0.8882792324282256, 0.9071848039113395, 0.9103347831432691, 0.9372715810255392, 0.9533253610385563, 0.9367624741050767, 0.9175094764805484, 0.9525309927035729, 0.9547035363935367, 0.9325288803842237, 0.9745689094448063, 0.9551219106250328, 0.9205987334999252, 1.0306713327343524, 1.0450118431519713, 1.0259121300158198, 1.091631643238567, 1.053129015189873, 1.1707918095775434, 1.2130285384959658, 1.185799552820922, 1.1559089876914888, 1.1654443611378333, 1.1419518289427875, 1.1902990608942245, 1.1909803634426583, 1.1692852831510938, 1.1823335454761408, 1.151005807086162, 1.098015316431158, 1.1302279556280266, 1.10720443165298, 0.9761624489949023, 0.9168883719048277, 0.8772006811703453, 0.9013221075186806, 0.8532736304456344, 0.8366565480265523, 0.8383615626508443, 0.8000239728686269, 0.8038405648346786, 0.7904115034664386, 0.7905672377138812, 0.7900731610172109, 0.8063024855238844, 0.8493548865334265, 0.8014845504996148, 0.7971738168376623, 0.8237378753966462, 0.8656884496932291, 0.8431747433668789, 0.9027925376952379, 0.9387223760732917, 0.9624247276484685, 0.9598862804543077, 0.8578699969333216, 0.8877884221096054, 0.8979956382306533, 0.8535716089193942, 0.8685154090718036, 0.8889886549289442, 0.8581302752954626, 0.9324517842592952, 0.9976287429456929, 0.9970054502548551, 1.0202231150395564, 1.0843180626320006, 1.107631115610464, 1.0502180063111983, 1.0454687879300288, 1.0580081201331655, 1.080510785292284, 1.1525714636766458, 1.1946361777621375, 1.1779581697872732, 1.1976501002894622, 1.1443557301610896, 1.1272353105563022, 1.1360613336861731, 1.0562425913540292, 1.0286876385824568, 1.090309075315384, 1.0522356063974156, 1.0376151936297142, 1.0597484867706686, 1.0504923810018825, 1.0432341388760513, 1.0787353459227838, 1.0436200962672082, 1.0665188564034196, 1.122781975525002, 1.0676614632637829, 1.1230787851310067, 1.2588027134169926, 1.341654351997339, 1.4649460223357604, 1.5964799797992335, 1.4082101201562365, 1.2959334773176563, 1.2910887374724749, 1.2333695885851226, 1.3046563265412598, 1.1855505660425354, 1.1278571432530977, 1.1737859412643412, 1.1876927891019102, 1.2114675843542884, 1.2799171096110533, 1.235209197221993, 1.3119437112928563, 1.3215079272197183, 1.377598865470389, 1.377017194473451, 1.3101303640971815], 'feat_static_cat': [4], 'feat_dynamic_real': None, 'item_id': 'T5'}, {'start': datetime.datetime(2022, 1, 1, 0, 0), 'target': [0.1177519226606898, 0.12164383000770787, 0.08393274872681554, 0.07702769580969053, 0.07279878594500197, 0.0628561869564354, 0.059501571059415094, 0.060341439368721626, 0.05968279338906195, 0.05933692231335689, 0.05952623562158866, 0.058710711186164846, 0.05977854149014922, 0.05993522539807766, 0.058913239769340306, 0.0585832722314478, 0.058637890919850194, 0.05966577017675208, 0.05987132690236985, 0.06025910993279209, 0.05950823846067238, 0.062150974613714445, 0.061671736556905415, 0.06241363766940094, 0.06344885985003934, 0.06473988160022963, 0.06593826533619089, 0.06038126493002444, 0.05928735625656301, 0.060628065013834796, 0.06164957967130463, 0.060737941547977604, 0.06062385317715555, 0.06059653278395085, 0.061083858983581055, 0.06116736490198857, 0.06322342542475971, 0.06333285399958949, 0.059593324659554504, 0.05738582198493917, 0.05842339165868152, 0.05861203370384155, 0.05751881305141982, 0.062209898855708816, 0.06043047594871761, 0.05879177201301703, 0.061167825842689774, 0.05971672101812697, 0.06390298946301654, 0.06371527937418649, 0.06477113902320543, 0.06400920621946937, 0.060973710530232934, 0.061088548182052, 0.05896439995163275, 0.06275020385602299, 0.06322985404266793, 0.06269660898397969, 0.061628675981788186, 0.06237243797187028, 0.06133600882267392, 0.06153396605741837, 0.0638989293530682, 0.06175303199437727, 0.06355769276834677, 0.06357052044780533, 0.0690820294371226, 0.06799121646262136, 0.06877133269266728, 0.0683945566706234, 0.06944143014642766, 0.06952921133836654, 0.06789727017327579, 0.07504456705834929, 0.08017352666872617, 0.08693252253645593, 0.07669506302784718, 0.08169766606295635, 0.07285606282644472, 0.07234378643882675, 0.07093071520586146, 0.07120524217851444, 0.06911904582837221, 0.07006141139195313, 0.06894639339684082, 0.06866907086348478, 0.06976607151804176, 0.06733349285477958, 0.06619747244913253, 0.06669219927434991, 0.06870802416241863, 0.06826619217495883, 0.06964226172535032, 0.06890536223484411, 0.06910367870009872, 0.0670311266391845, 0.06251411668765494, 0.06231946569528974, 0.06771561955697847, 0.06811620216300138, 0.0675309104273868, 0.06997038384330402, 0.0701239341809915, 0.06901533750967387, 0.06768994728823158, 0.06311420022223632, 0.06428818830673563, 0.06303697973802362, 0.06240034776419716, 0.061932553116884614, 0.06008505610689662, 0.06185068227483634, 0.06726842502220062, 0.0695089747985236, 0.06922384501696943, 0.07061805947825184, 0.06857881974623464, 0.06717168929977041, 0.06943108580782728, 0.06717433242285291, 0.0666981648399527, 0.0662051917510711, 0.06620849751149958, 0.06948129814562087, 0.06599635455694043, 0.07222117910252078, 0.07315403852730885, 0.06848772948465755, 0.06710991267855053, 0.06401872774033127, 0.061702649707685395, 0.06560642296717324, 0.06017496571668506, 0.0603985213148969, 0.0530072912220283, 0.05697860522765189, 0.055046834202293324, 0.06297714434613007, 0.05557691264417983, 0.05394097748572516, 0.06427501066026757, 0.06991912275567486, 0.07547229604511066, 0.07933547873619115, 0.07943634800439289, 0.08049232551403834, 0.08253024528546458, 0.08122518755151559, 0.08177568142487536, 0.08045399739232911, 0.08277682710614404, 0.0810520322755403, 0.08585532036438477, 0.08786546226325385, 0.08268411583541746, 0.08183776097823199, 0.08224819490104099, 0.07821054584165825, 0.08299444311858013, 0.08362783034884497, 0.08326666103685844, 0.08608352796910743, 0.08444826276786017, 0.08397177740175661, 0.08671875601661744, 0.08363490299117085, 0.0902209771571814, 0.08783602857183936, 0.09286668238983552, 0.08978452026892277, 0.0883412521552776, 0.08263852125578125, 0.08463601337390982, 0.10844857246474998, 0.10470831475345954, 0.1242001168109914, 0.12752655187221104, 0.1278897372859061, 0.128403339256934, 0.13581252154152132, 0.12951442486001735, 0.13093482476726287, 0.13279420586843635, 0.12758863385549565, 0.13503291007350474, 0.13737620558691735, 0.1396910817703083, 0.13784745809645021, 0.1577774847160479, 0.13193588508828463, 0.13420183875515979, 0.13638677852109118, 0.1363570561966381, 0.1408680598750816, 0.14267740353602096, 0.1402967106152925, 0.13947098925014487, 0.14369336393035653, 0.1460165872817323, 0.14391722805870813, 0.14005284257443246, 0.13806993257821334, 0.13465194085758156, 0.14937449511314235, 0.1443041700970794, 0.142543652332759, 0.14610565069849074, 0.14343249721206655, 0.17248479723660937, 0.14861403591085484, 0.1464134466572974, 0.1389030014934414, 0.14131002827823436, 0.13792167777469105, 0.1431838112059399, 0.14445643159252067, 0.14255699475797332, 0.14472519495426225, 0.13590046805371428, 0.1310103613896418, 0.13660274799245484, 0.12972197231552338, 0.12248653146009827, 0.11933267499305467, 0.11914563292731707, 0.1235788707420141, 0.11927752130098068, 0.11649011545369503, 0.1169065531417788, 0.11277924302197201, 0.11404291347924819, 0.11160702747046551, 0.11508028632801316, 0.11560780955206384, 0.11689331825374624, 0.12157164533578978, 0.11704701811806206, 0.1171063759175096, 0.12076914309505216, 0.12502471217079347, 0.12261387245204829, 0.1296308704395601, 0.13299795844071405, 0.13396425161017844, 0.1331736815485473, 0.12311780617656289, 0.12763855641088803, 0.12756849117206873, 0.12384261161704302, 0.12782135083383594, 0.13156079635854936, 0.12848819976669865, 0.13683783781804068, 0.14119666196152966, 0.13876415451981863, 0.13859362747775705, 0.149049514386613, 0.15177924723117944, 0.14599562969552013, 0.1488694158487719, 0.1443786295449331, 0.14485647762800657, 0.15189542976922715, 0.15914511534145145, 0.15835683751468113, 0.16560602928268137, 0.1538030910399291, 0.14714007892563696, 0.14753292523708117, 0.13752294539979495, 0.13721280884391124, 0.14262555367481444, 0.14180483842961705, 0.139469488691895, 0.14305722676919624, 0.14164948694289622, 0.1412440800917374, 0.14375586003715482, 0.14301415870484097, 0.1377835793511962, 0.14188110608566565, 0.13295993765359873, 0.1426509219668281, 0.15526331450760245, 0.16234636365921515, 0.16548505739968233, 0.17108647620016298, 0.17718723166882186, 0.1850927628673133, 0.18364391967807153, 0.1720525136557963, 0.16156186916468437, 0.15345815843287103, 0.14335073802367357, 0.15107278555899836, 0.15195920081353653, 0.1550307471504216, 0.1602045474808524, 0.1594360084333683, 0.16883462330290358, 0.17015128996382764, 0.17440601865396502, 0.17302684675126584, 0.1705104823749019], 'feat_static_cat': [5], 'feat_dynamic_real': None, 'item_id': 'T6'}, {'start': datetime.datetime(2022, 1, 1, 0, 0), 'target': [32.96102177100325, 32.857777833177494, 32.1090615013578, 30.63079351595863, 31.287026765660723, 30.928864939264376, 28.30999023292394, 29.27251995219789, 28.01367578334443, 28.108327689252107, 28.08042953209092, 28.89457108198253, 30.16461705139049, 31.224253235691645, 30.168089755217718, 29.578842935569075, 30.006133314484565, 30.542488344210028, 31.164413811436276, 30.779691079543916, 31.9660323090013, 32.91293778412627, 32.57801269838808, 33.000068205372266, 33.34446769226818, 34.073752211635224, 34.11719226162946, 32.95677218385321, 32.05711048309511, 32.47042085187277, 33.21569003138126, 33.951779808829336, 33.23528205055874, 32.73825328327344, 33.87862815811972, 32.33634779351221, 33.46106224987174, 33.67512951053258, 32.40623679601136, 30.815771504608676, 31.433791216553185, 32.68706391806844, 31.053613258864225, 33.748274628600186, 32.21224495262979, 33.0445931869151, 34.09429255241698, 33.018278406307225, 37.4216083687523, 34.967442070597436, 35.12284010644147, 34.7328555642083, 33.60664510040985, 32.708031152680654, 30.88389888925162, 32.199669222777295, 32.10802746963588, 31.10893975317547, 31.22819267690313, 31.584987000988985, 31.475082368056295, 31.416514771721683, 32.460041770873374, 30.393859135578847, 31.538863824332957, 31.713828480005056, 35.313257097150924, 34.959102077280356, 35.64565616897747, 35.475305894976636, 36.52580631232133, 35.264178114967294, 35.876611783754456, 39.54132859066167, 40.426508052077764, 43.153056897990496, 43.80609519046727, 44.92244092716158, 46.505985390211805, 45.34074268144022, 42.820530619423515, 42.37364947297439, 40.37052512861601, 42.17539239511583, 40.609640705438814, 40.06004707154964, 40.56116833338932, 38.82399166525089, 38.544638430237605, 39.754862875953165, 41.774146011224374, 42.40155410147458, 43.76065927632532, 41.923416568808115, 42.87696970440752, 40.30208228679017, 36.20374464353241, 36.715423712152635, 41.00948132364836, 40.03881111633537, 40.59116891927147, 43.18901115335266, 42.08842332064214, 44.89685432423069, 43.6685430306873, 38.64695834721782, 39.57989218651562, 37.412757083786815, 37.11223981258459, 34.9122611189988, 32.74802856746148, 33.465028899663785, 36.69319574562677, 38.0710832196881, 38.2924341240472, 38.51742991956803, 37.07526711868892, 35.40472167401285, 36.761268554687476, 33.385268233452464, 33.35625983543413, 32.81100319302448, 33.645652314215724, 33.908782783885734, 35.32723634988002, 38.44542814354147, 39.409088078853635, 42.30241913229984, 42.20299784224027, 38.20144442002586, 34.120805219460735, 36.182723822040856, 35.39715609720185, 34.238365707412875, 31.809134432900972, 30.740924348969326, 30.002502254636862, 34.50612168770865, 29.695768623898413, 28.18289599936814, 30.730292992774025, 33.8374898530108, 37.09238074283469, 39.967624312101165, 38.84558630489596, 39.434051992903846, 42.42977559702059, 38.50159993925965, 38.93410252068897, 38.27455052144034, 40.89575164719481, 40.25528119518926, 45.76512940438746, 47.18132726758931, 44.908668309264215, 44.33879066007339, 41.49373310844747, 43.47437942584902, 47.98397482762423, 49.648419938971806, 49.06423089601785, 52.73608643614739, 50.32065862015939, 49.535450169708426, 52.21197145378115, 49.79486258072461, 57.116316240226226, 53.656005349654784, 58.8039140989315, 52.431341598635065, 48.67664328971503, 44.633572489882596, 50.23923256892103, 66.73474670718312, 63.369312874994556, 75.23445586201817, 78.98763558441706, 81.7666667492934, 84.58849732085166, 92.76979241467573, 85.8417308308532, 87.56274423311139, 89.67205770020651, 85.09469010306027, 94.01355514986516, 98.18296139897028, 98.38214658657239, 95.78552084370254, 101.22487912385773, 99.24141122935578, 100.72718654703593, 100.61978131691703, 101.75742225167603, 105.49767049538457, 108.60219779720339, 102.20238189906242, 100.40794839199721, 102.24843887092545, 101.29869416003514, 100.70652827248173, 104.94060315611004, 103.28101294987005, 99.38467731813168, 111.69898994515484, 112.9727114843254, 109.79876284390153, 118.81621218380415, 112.93579936822539, 126.85795747828183, 132.38786148983306, 136.76078294142744, 132.24107403001852, 134.45357670600387, 122.73610385219088, 120.68155630313936, 111.6902575171793, 106.3279863476465, 107.07796653400344, 101.77369482082939, 98.66674609474022, 102.23835611338026, 95.02090064057349, 90.5139281710675, 88.74190303658186, 88.60500459867337, 92.41366275321492, 89.8204613570049, 87.866264040936, 87.8624566479126, 82.9516746524046, 81.17006172072998, 78.92557783512397, 81.53121574455443, 80.74751936821781, 82.94073909254924, 88.19039614323796, 82.27991928043487, 82.11260450652212, 84.5528708691756, 89.64858743184132, 88.29053526802034, 95.56703662008367, 100.65377063036706, 98.64907091922294, 99.54046318191149, 85.5011098016925, 90.12463713172889, 92.60886291659705, 89.22813053677233, 84.8635819351099, 86.47079715442035, 83.10639633994376, 90.8830225426654, 91.4443231225004, 90.05188186492691, 93.46298308080073, 101.89823271275964, 104.92503846439845, 96.43740773167308, 93.19368913166213, 95.89258749904157, 96.40149051622952, 106.22976730321291, 114.02164431351959, 113.53403239748792, 117.40891252904989, 115.27619376718947, 113.90282556864172, 112.20548199750489, 101.34093741329251, 101.82810203746403, 110.01945765200455, 99.72594166947884, 93.30117306805175, 96.24900094103377, 91.35469476022648, 89.52909292319087, 92.21805318882059, 94.71883076152479, 91.66015619187435, 99.6175174931234, 94.30760051928418, 111.9765411552512, 127.33333526251951, 135.79133312115678, 141.54699560192628, 139.93277391933526, 147.87678586288197, 147.78660781046815, 146.18002055799698, 146.0259047398014, 151.69059710475963, 140.20375445535805, 135.94090914908108, 140.83362928575025, 142.54311705235767, 136.40016155908168, 150.41340648424924, 155.10592114792857, 167.94033213378427, 170.28611554205224, 176.3863054579407, 178.53241561715492, 170.31083852315987], 'feat_static_cat': [6], 'feat_dynamic_real': None, 'item_id': 'T7'}, {'start': datetime.datetime(2022, 1, 1, 0, 0), 'target': [0.06313514135353915, 0.06417700736933038, 0.06356303735366133, 0.0629790244957064, 0.06343527279724444, 0.06240437829237493, 0.0613622257041221, 0.06188068654134143, 0.06163931135393319, 0.06166123302495953, 0.06221080064271893, 0.06177769024461025, 0.06216831599871877, 0.06266667608281706, 0.06182148173268521, 0.061823844497683474, 0.06396594870356523, 0.061007236177869004, 0.061769624760446014, 0.06163318903827656, 0.06282351593189636, 0.06242755777998316, 0.06206933027958003, 0.062498329290596594, 0.06278551003105916, 0.062429536038892744, 0.06231690760593847, 0.06139221311522951, 0.060882603635825046, 0.060477397848832826, 0.061008114028382625, 0.06103384879110622, 0.05959678934517077, 0.05940078667840818, 0.05954724767661277, 0.059732422899119, 0.05986833911479738, 0.06044580998792157, 0.060260416525260145, 0.05918059818399651, 0.05974817826150631, 0.06032119503070197, 0.060868909755914614, 0.06228627186537411, 0.06129488934994389, 0.06125734926514561, 0.06160673797082271, 0.06072731692583519, 0.063820353173065, 0.06409629097822059, 0.06466807499927128, 0.06341847511817117, 0.06122967407301295, 0.061814929937895606, 0.06075677492081591, 0.06295946108343137, 0.06351856307849173, 0.0631208098303018, 0.06259019512854087, 0.0632434647201255, 0.06341119983284761, 0.06470051374521356, 0.0633621934838142, 0.0614689461231642, 0.06290199877436335, 0.061650225676694405, 0.06549270968536221, 0.06485649120119902, 0.06625349069445365, 0.06556047615665957, 0.06598172934317355, 0.06578107070091976, 0.06407927666358644, 0.06743988469797005, 0.06823541407916776, 0.06971853985659854, 0.06892293270913469, 0.07040305759283474, 0.06991052582152497, 0.07045371827725286, 0.07032795942379712, 0.07031651564240253, 0.06847477396299104, 0.0701063922508732, 0.06963332379500853, 0.06947852166783555, 0.06982771470904964, 0.06893863582724323, 0.06782339407046747, 0.06837742917160487, 0.06993865388093677, 0.06893644478135122, 0.06915138094181543, 0.06929050747615735, 0.06975251365906363, 0.0686658868297523, 0.06534127426189758, 0.06383479611368756, 0.06694795677524662, 0.06696049969501175, 0.0670475713565233, 0.06802835961003807, 0.06760643675652882, 0.06914320105651223, 0.069039248900157, 0.0674307059992182, 0.06890734365667693, 0.0670723098381956, 0.06687657759633106, 0.06624419502951069, 0.06464566014899109, 0.06471741315040104, 0.06762683237362976, 0.069835244117599, 0.06902896486359114, 0.06864230570214087, 0.0675856540185684, 0.0682026515962223, 0.0672443889009251, 0.06624180706859867, 0.06476946870815294, 0.06496783449925059, 0.06479185202745703, 0.06483278501838742, 0.06603356329310628, 0.06706542769140617, 0.06497226835791, 0.06490247422588424, 0.0659059075233408, 0.06374258357277571, 0.06312055055900871, 0.064874580172039, 0.061144471931987, 0.06145210999204705, 0.06090707865676291, 0.05987631639915308, 0.05909504898338913, 0.06294017639517674, 0.05575355958021285, 0.06380419652099101, 0.07641010989984766, 0.07598254841299114, 0.0789539852309844, 0.08097283514401331, 0.08064064707699134, 0.0820067272827422, 0.08170171304107034, 0.08143411619049447, 0.08036971997963202, 0.08115356898255209, 0.08423141133496166, 0.08347114973875328, 0.0841724880981294, 0.08324963750174495, 0.0805054910824007, 0.08125521237547205, 0.08022280131253177, 0.08233586124546541, 0.08466512608766127, 0.08059622075404949, 0.07628041074237041, 0.07812785591202669, 0.07407124048851459, 0.07135416139435496, 0.0736102375002498, 0.07097790664322329, 0.07227829994378418, 0.06910743489646694, 0.07236083317250795, 0.07249089918037573, 0.07421141222682565, 0.06737848594756533, 0.07447410264424813, 0.07697193681901028, 0.07324668444325627, 0.08754984838600449, 0.0832949163745602, 0.08624346390396948, 0.07457967954981029, 0.08625401531725814, 0.07235069116185223, 0.06879403315710172, 0.07090261666646912, 0.06276541796136287, 0.06353818175505122, 0.06374389893804315, 0.06321457193976207, 0.061925825924363596, 0.06532251444418334, 0.06570200063762578, 0.06765393280781261, 0.066782558273855, 0.07140014795488361, 0.06263875546118279, 0.06334148652024495, 0.06156051301715352, 0.06024236471719643, 0.061955003725502424, 0.06189189568415768, 0.060133802344396844, 0.061504246570377584, 0.0599472581266541, 0.058242768638761926, 0.06251649734154421, 0.06396572902003023, 0.06252317251092417, 0.0644260549673727, 0.06329067736767931, 0.06942229399445118, 0.0708095285595925, 0.07314570495701071, 0.0732370468321282, 0.07489851173360099, 0.07391025460147915, 0.07311472808769255, 0.06938491410260032, 0.06904021748891698, 0.06915086361321743, 0.06617317195878764, 0.06446757716332406, 0.06557504627880967, 0.06433541132758903, 0.0634131195014912, 0.06177545330141351, 0.061440128209470826, 0.06189728356659574, 0.061679370158423785, 0.06079135700413162, 0.06108636090249452, 0.06049786932185353, 0.060141609576718394, 0.05935734512009914, 0.0596680983182502, 0.060269051925093936, 0.059871480958186764, 0.06084022730534234, 0.06055245394514956, 0.05867828186371227, 0.05891744064630337, 0.0604353884650999, 0.05820534114226849, 0.059975357377600645, 0.06151025945510584, 0.06212864850833281, 0.06175174941532314, 0.05803834685797306, 0.0595328968632333, 0.05950219300993421, 0.06112710728205033, 0.060956411859318695, 0.06266013154552455, 0.05962280241807181, 0.06205826055171793, 0.06354828470213325, 0.06314734512458585, 0.06250281696560142, 0.06644891260125413, 0.0668532120372488, 0.06454411930606188, 0.0644312868043095, 0.06347587482002975, 0.06404593658899621, 0.06865900590328929, 0.06982447252463346, 0.06813220884434547, 0.06857661262792925, 0.0662051087135861, 0.0647586414898476, 0.06441087249062426, 0.059654535212375785, 0.05862706710777694, 0.05986563923595819, 0.059137499517676634, 0.058734727915708974, 0.06028627373060609, 0.057591726785500195, 0.0564038996922125, 0.05625262569060483, 0.05586788020836503, 0.0550468347237014, 0.05757871431641491, 0.0567058866505497, 0.06094543110103054, 0.06775565889806032, 0.06926103546383133, 0.06849477595624882, 0.07080082843849304, 0.06988114344393181, 0.06853717076533115, 0.06766955361822773, 0.06627205607669681, 0.06806567426673861, 0.06493622534891676, 0.06355117914879309, 0.06626691407680634, 0.06572659542459354, 0.06814781440843505, 0.07110606906364018, 0.07137340122568629, 0.0762044907225112, 0.07708074323157353, 0.07777808959266456, 0.07660953131113812, 0.07539874595606924], 'feat_static_cat': [7], 'feat_dynamic_real': None, 'item_id': 'T8'}, {'start': datetime.datetime(2022, 1, 1, 0, 0), 'target': [55.38230884510532, 56.51261454315506, 55.00160443698405, 54.80946328455271, 56.39434003810443, 56.01229039559105, 52.56521938529414, 53.95068952492465, 52.18155525503334, 51.62375684767222, 51.19440131055927, 50.98496018240611, 51.878693945454565, 51.843729644816335, 51.47489923897357, 50.46696839600983, 51.31436869548105, 51.240758807332995, 52.22258846373273, 52.020788641605954, 52.74790265451962, 53.9139762979843, 52.796819123761196, 52.86622019281265, 53.49896344309032, 54.58013729927848, 55.297164364545225, 54.172318188278496, 51.916431353034326, 52.9046147704875, 53.403040861696184, 53.914840750085, 53.307693419530835, 52.73012057216505, 53.434762860127584, 52.63922997901971, 53.5197857457763, 55.09682707464822, 53.51188723560638, 51.233232525582686, 52.35625096200453, 52.884252238324414, 52.83251566415466, 57.81219382579235, 55.85560532568176, 56.35547709314618, 60.14997014130617, 59.06136854618083, 61.36082209378594, 62.2461566503907, 63.42702427071944, 61.225060119694795, 58.00151977879037, 57.41305807189702, 54.30258996768678, 60.41395101364879, 60.9015973981264, 60.14294011739799, 61.03767669456877, 57.52489839122833, 53.85836409233651, 53.057660397436884, 55.775098862912124, 53.61078219241812, 53.047720051604564, 52.7586296702904, 56.782242113157864, 56.47560581857392, 57.07799026083648, 57.24626900958223, 55.49743990814339, 54.180012463854, 54.02425867172751, 60.041903599182426, 60.39040025979622, 61.337976117334975, 60.80707210066691, 63.30583382314917, 63.75997694643514, 62.93435037560392, 61.90418512784067, 61.606344931392876, 59.25986757607917, 62.59898021600599, 61.10433604465659, 60.92059133914916, 62.40816249552858, 59.83948330673218, 57.80523212459897, 58.23983266314102, 59.530258238171555, 59.91562087057642, 60.44405579830974, 60.91704904208721, 63.46463979306059, 58.95376297369396, 53.7988284183397, 54.35359869826105, 58.483294234489996, 56.42780900706296, 56.1636480618105, 58.100523730370114, 57.24059806361539, 57.98867635239821, 58.611267569094124, 55.72326668802828, 55.12351830807288, 51.79474389311967, 51.22144500870841, 49.55903740508603, 47.54443919012076, 48.77489096772262, 52.165336403704345, 54.159841286211176, 51.55635642511024, 52.14044746424059, 50.36018972085579, 49.83580353322058, 52.23873923389113, 50.971881772001694, 50.48486637311594, 51.13259444896031, 53.69903088288022, 53.44741204296737, 52.80720237009923, 55.91389167233012, 56.862956029794894, 58.95540785323159, 55.99024278102765, 55.761625419340355, 52.10919513257979, 53.520716525116015, 52.89878287498386, 54.32199173460218, 47.23798758042039, 47.68170220982707, 44.706155809403114, 50.515754421713, 46.133480999565386, 43.314002195634856, 48.21331763268822, 52.30757431828002, 56.6656215072695, 60.213543517410116, 61.543855112035665, 63.8984093510421, 64.41806585357297, 63.214748158217745, 63.74975556494986, 62.65883449288183, 64.45580271028474, 62.96444237634769, 68.41702187749365, 69.11026658663762, 63.745798618005196, 63.06359551391342, 62.65355972448526, 63.80058017524525, 68.31511005942279, 70.31922193497131, 69.01382519626331, 71.76394488589425, 69.70726775093628, 68.65456104394534, 72.07717181778541, 66.38670784114375, 72.96766893591597, 67.21218553838732, 71.51973858173922, 68.93971334942641, 67.94560656494536, 64.38304731338357, 66.40777641663341, 80.21155101517851, 77.83116811933203, 93.97541496914009, 94.57154906775578, 96.79420923295635, 96.90928217029726, 106.27081724234552, 99.33873344579398, 100.69755105634945, 99.43371610016528, 96.16787126415976, 100.3787529887234, 103.31861857522489, 100.5424098497033, 98.41316836006831, 104.67106916485174, 104.6203968184674, 105.49246409996016, 105.60206342472078, 106.99688711388913, 111.9753294339292, 113.81502989471383, 111.22910296717568, 109.0355252961834, 114.40483018585361, 111.10593627333618, 107.41422463202606, 110.4795001761876, 104.82459943122247, 102.64373289556552, 111.1531425937833, 112.77835589133329, 110.87825524274936, 114.23804799095795, 112.47104573148953, 123.20003164894227, 124.85991010786978, 128.90709026194327, 124.90180904809492, 124.88238141971276, 123.7316997859832, 131.1663620759623, 130.05473736978178, 127.91148631154469, 129.40063599015403, 124.88927156952997, 124.07106745739958, 126.58252017526168, 122.46805962093715, 122.9225126952278, 116.15018198073037, 114.8343052718661, 116.35651275207299, 112.08791102974435, 110.30344394203411, 111.35095718117567, 106.97649227199142, 105.66586612238955, 102.1112116184778, 105.8122724891484, 104.96476184500473, 102.64948099449201, 106.9341996212238, 100.62169545739268, 98.86157181845725, 101.59587905767152, 104.98061966147682, 101.40839864236999, 111.41283069659951, 110.35635160793537, 112.54029522946514, 113.47608074353367, 103.10042666375762, 108.23714671237614, 109.2640549124827, 104.23491441665544, 105.94164743561599, 107.51874997411227, 103.4308275218451, 110.83516648736108, 115.70782240344545, 115.19397403716823, 116.33308113319933, 128.10466273083117, 131.7605222367168, 124.79279543753158, 126.13479036794689, 126.67078039906369, 126.01291021222374, 135.09285045976867, 140.17390772731312, 133.96218063174618, 137.1423890230183, 127.44465353856862, 121.91934896861038, 120.92329717951526, 110.2910976380461, 108.53465560071693, 115.4045008427484, 109.58944321365493, 108.79916784178242, 110.83002541755059, 109.4311955214021, 106.92748155885107, 107.26136272278755, 108.06230316920465, 109.59247900070146, 112.10081468790973, 108.46219714927645, 114.42323704058579, 130.39228434118232, 136.89677022663682, 141.88826318260215, 151.65389461904428, 146.5348320859597, 147.9322599464307, 144.72025198098797, 136.64692089554808, 141.73686670245792, 131.5546829232923, 126.82604723318391, 131.3038823157355, 130.13734562678638, 131.49483907294083, 136.49186062402737, 136.07732030343186, 146.81130121154595, 148.46777094134876, 151.2633949208683, 150.68530165277951, 146.53686630048895], 'feat_static_cat': [8], 'feat_dynamic_real': None, 'item_id': 'T9'}, {'start': datetime.datetime(2022, 1, 1, 0, 0), 'target': [0.9087275545635903, 0.9338191968172025, 0.9447720263553973, 0.9048495536838147, 0.9381255736029885, 0.9194622665766591, 0.8938199722901116, 0.8997886875083623, 0.8323699458085382, 0.8320643369166123, 0.8101015353234499, 0.846003029839718, 0.8645285096151052, 0.8473063910526103, 0.7994750820349774, 0.7900427270902555, 0.7927191535071839, 0.7757867025674318, 0.7842926525835981, 0.7906216535394457, 0.8151257292765629, 0.8253347147405075, 0.8136537102769099, 0.8318160488696271, 0.8331349896802214, 0.8513504300345962, 0.8360582079188493, 0.8016991540902177, 0.7642968853962836, 0.7660143537691189, 0.7774390183513012, 0.7633573887736667, 0.7474520726501468, 0.7401886851998551, 0.754892801514311, 0.7402630921407659, 0.7540686001103842, 0.7787154937442062, 0.7527765006478898, 0.7041467834471866, 0.7333216394489818, 0.7661641153823251, 0.7535803125017692, 0.829353684664803, 0.8061498527125107, 0.8243817745723087, 0.8647927527714518, 0.8462330290264785, 0.9300407243932649, 0.8943199043669618, 0.906193188872134, 0.8914543670101871, 0.8441706991676869, 0.8407390419716965, 0.818570199036863, 0.8815508221177938, 0.89428606263722, 0.8891977386124742, 0.8719695491026733, 0.885372860470761, 0.8318737072813377, 0.8145971378334095, 0.8174155417130992, 0.7840295814451367, 0.8052653984239995, 0.7638354544255637, 0.8187191229877, 0.8136559981128756, 0.8317565524292935, 0.8103583040805701, 0.8202021616387467, 0.7867210106057736, 0.7719382436209903, 0.8595614440619158, 0.8833836821170913, 0.9357379194367217, 0.9517732301568439, 1.0008463919272441, 1.0251220006742165, 0.9339023463587721, 0.9214397301416503, 0.9373516066353831, 0.8904173061312429, 0.9216198850431618, 0.9067301451686713, 0.9075273160006672, 0.9277121666784366, 0.8916454734725293, 0.8878165974360621, 0.8791904764338021, 0.8945394258826989, 0.9282728453091756, 0.9296102355041274, 0.938640296802392, 0.935817153260074, 0.8957486519026868, 0.7807732739572295, 0.7760139717396587, 0.8811613822446115, 0.875014165470559, 0.8530337738577126, 0.9071331518659129, 0.8328050773291552, 0.9260168254918939, 0.9613779280985374, 0.7531577257006129, 0.7270444272439277, 0.7045506382279927, 0.7078033518599225, 0.6361575402676575, 0.5393822676046827, 0.5635142914149096, 0.571173816746401, 0.589567228751994, 0.6062439759568481, 0.562500344203582, 0.5252839168068141, 0.5123906249656615, 0.49139585325499735, 0.46089656059580214, 0.49277831331656574, 0.46139585096576663, 0.4781042079243676, 0.49551352158311485, 0.5110000293363542, 0.5324854944575445, 0.5603760591291029, 0.6003936146837833, 0.6122332183341447, 0.5613840842151376, 0.45658661776605375, 0.4190695799836516, 0.40076645576453523, 0.3831173091593482, 0.3465954261420536, 0.39979830177987774, 0.38204506505230995, 0.4377853110484892, 0.4156881705852988, 0.4281438783292063, 0.5014866220242925, 0.5387786880714588, 0.5949858262485538, 0.6336367981126898, 0.6074482392498743, 0.6165559174955227, 0.6325338021987701, 0.5980144573821002, 0.5956713328201702, 0.5899917916156823, 0.6194338537948204, 0.6014867198053161, 0.6621127782406405, 0.6571413199304394, 0.598521808531301, 0.5878931772504093, 0.5839358865817618, 0.6007559747264658, 0.6460416321264306, 0.661673304449871, 0.6420338043141065, 0.6779735608639736, 0.6494992712423286, 0.6364305803693102, 0.6586935221963637, 0.6272803647365474, 0.7269474136800104, 0.6773128750859617, 0.7375113338940931, 0.6860843974190368, 0.6676359956475028, 0.6009411233660442, 0.6668757660167012, 0.8901958878398034, 0.8207692288616901, 0.9744056895318244, 1.021218760655227, 1.0441490605071693, 1.064479137107102, 1.170986162821605, 1.0759280682648127, 1.0776415312988366, 1.1011111988555229, 1.0356572180259682, 1.1406645966483557, 1.238752002995137, 1.2576738882643308, 1.2432751086911666, 1.3525217315238354, 1.3442325277786815, 1.3657528167435387, 1.3991060733226945, 1.3796972307505622, 1.4177120422129768, 1.4282326676568389, 1.421117556913491, 1.3401027354994697, 1.390764951133434, 1.3962802423618073, 1.3727163376128202, 1.4197577606401992, 1.39273291146372, 1.3335255093276905, 1.4326463097649098, 1.4642593201238678, 1.4357689183852564, 1.513931121598682, 1.4589033622215024, 1.5928999635046635, 1.6499841583961976, 1.688619040526366, 1.6538078955191504, 1.6940196181459388, 1.617751685797808, 1.6842207405532734, 1.6747596080994762, 1.6596747467407196, 1.6935599203965734, 1.6108315667100086, 1.5796006266631442, 1.6287668216843596, 1.556207405123158, 1.5054983353308997, 1.4662542344711595, 1.4638518930815907, 1.528184392936637, 1.4993133661657334, 1.448697433552086, 1.4682333492439366, 1.380056361507885, 1.377846083222403, 1.362735589403232, 1.3990650283313704, 1.4065085421351429, 1.4390967159918437, 1.5065533649913787, 1.4456489156552117, 1.4162642931278648, 1.4368175390244178, 1.5083173849796288, 1.4754496943986275, 1.584856407563326, 1.6354967088384322, 1.621319295096533, 1.6114539848622091, 1.452539707093046, 1.5150846283852752, 1.550655875218307, 1.4398401661755318, 1.4412293385318853, 1.4642527353431918, 1.408425005240291, 1.5151272500774926, 1.6318464451419, 1.5953828446515914, 1.658498165622768, 1.8379046472126657, 1.863287323514166, 1.6588448981996313, 1.6681609149594014, 1.6991929593445567, 1.7146905240043455, 1.896300491694783, 2.042493142974607, 1.9471713771513688, 2.0201997467847286, 1.7397651089415531, 1.7144424082753118, 1.6911449773410396, 1.549636928887721, 1.5415372269267382, 1.6477561298503107, 1.6439133223396298, 1.60561486671551, 1.695255363345891, 1.6787339444645417, 1.590580528087578, 1.5906686989299221, 1.5583405910659183, 1.507711009992672, 1.6163324559508299, 1.5318520709430417, 1.6995911978688367, 1.9613339110322283, 2.0356991785794127, 2.12797409659433, 2.2218392164389984, 2.3302498473875772, 2.3529086498412406, 2.337607257162068, 2.2638148082516802, 2.392826767761895, 2.3578211430026643, 2.071872547887667, 2.1154311184465335, 1.9955150651068125, 2.0538210605200304, 2.2501825783753855, 2.194927298110091, 2.3671985243413722, 2.4342344421116597, 2.549155958302948, 2.5742608662952877, 2.5278181531828166], 'feat_static_cat': [9], 'feat_dynamic_real': None, 'item_id': 'T10'}]\n" + ] + } + ], + "source": [ + "print(crypto_train)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "a75bf6b9", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": 101, + "id": "98786206", + "metadata": {}, + "outputs": [], + "source": [ + "# reverse to get the right price order\n", + "\n", + "for i in range(10):\n", + "\n", + " crypto_train[i][\"target\"].reverse()\n", + " crypto_val[i][\"target\"].reverse()\n", + " crypto_test[i][\"target\"].reverse()" + ] + }, + { + "cell_type": "code", + "execution_count": 109, + "id": "2a6d1bae", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "2022-01-01 00:00:00\n" + ] + } + ], + "source": [ + "print(crypto_train[0][\"start\"])" + ] + }, + { + "cell_type": "code", + "execution_count": 116, + "id": "84ec91a5", + "metadata": { + "scrolled": true + }, + "outputs": [], + "source": [ + "for i in range(10):\n", + "\n", + " crypto_train[i][\"start\"] = crypto_train[i][\"start\"].strftime(\"%Y-%m-%d %H:%M:%S\")\n", + " crypto_val[i][\"start\"] = crypto_val[i][\"start\"].strftime(\"%Y-%m-%d %H:%M:%S\")\n", + " crypto_test[i][\"start\"] = crypto_test[i][\"start\"].strftime(\"%Y-%m-%d %H:%M:%S\")" + ] + }, + { + "cell_type": "code", + "execution_count": 118, + "id": "04532184", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'start': '2022-01-01 00:00:00', 'target': [46311.744663040976, 47680.926624830136, 47343.54376514904, 46458.85144441394, 45899.35873958258, 43565.51172706792, 43153.57087575333, 41561.46586768905, 41734.72756293196, 41910.2308272178, 41819.506970621274, 42742.17840595137, 43946.741717735065, 42598.87288897501, 43101.89961076399, 43172.038894674435, 43118.12010150989, 42250.07314461258, 42374.04061202849, 41744.02805917337, 40699.60698392732, 36471.58999992482, 35047.360289671895, 36275.732948124925, 36654.80592442568, 36950.51482868812, 36841.88060894733, 37128.444198943034, 37780.713786273285, 38151.918823373366, 37920.28099097226, 38481.765368511944, 38743.71342572458, 36944.805239029825, 37149.26414150606, 41501.480571936794, 41441.12079033813, 42406.7813264058, 43854.6536157814, 44096.704492042554, 44347.79883452384, 43571.13046337891, 42412.30031147502, 42236.56642632817, 42157.39915316259, 42586.464611620926, 44578.276206938615, 43937.07161828148, 40552.13257469959, 40026.02250608061, 40118.100621485086, 38423.209871915555, 37068.771436199466, 38285.28261421084, 37278.5650718651, 38333.74714480872, 39213.08378308136, 39098.69891124532, 37706.001266645675, 43194.504211304244, 44357.615244967536, 43925.195064951615, 42458.1411201421, 39148.44970501965, 39404.19892431593, 38429.30278301694, 38059.904292538864, 38742.81608045671, 41974.06923817848, 39439.96953161491, 38794.46318889842, 38884.7248489191, 37846.316439623675, 39664.25002606368, 39335.569403715985, 41140.84481577167, 40944.84167953429, 41794.64783390654, 42191.40531212776, 41246.13284847771, 41074.10451849765, 42364.3780528832, 42886.65421682143, 43964.54622463837, 44349.85843334273, 44505.35710237063, 46821.85024693429, 47100.43859807688, 47456.89702971699, 47062.14656183097, 45554.16381205456, 46285.49805877043, 45859.12870068277, 46445.271619629675, 46624.50707545264, 45544.35561952329, 43207.49887037383, 43505.13680265104, 42282.07939459544, 42781.09046341356, 42201.038230331425, 39533.71330624112, 40123.569761918385, 41160.21914540542, 39939.40395993831, 40552.31769418768, 40417.77626722159, 39721.202915300324, 40828.174203435905, 41501.744242424924, 41371.51504679231, 40525.861918239076, 39738.723269661496, 39478.37343720399, 39472.60737229702, 40448.42267445845, 38120.302630877784, 39241.42852522164, 39768.61581999673, 38605.858805370524, 37713.26508974102, 38472.1871454262, 38528.110038067374, 37748.0118484619, 39695.74635071903, 36573.18235500367, 36042.503693993414, 35502.940203830294, 34060.01548161972, 30273.65421884102, 31016.18275233353, 28936.7339259087, 29030.910391071633, 29285.643002871293, 30098.5866261369, 31304.37414424804, 29862.408192941577, 30424.479222550304, 28720.358563128946, 30311.1193461763, 29199.859006567556, 29432.47239860644, 30309.39648000864, 29101.125294324578, 29653.13529361965, 29564.77651079689, 29251.14086372044, 28842.10384461052, 29019.867414131473, 29443.365710983147, 31723.865101541804, 31792.553808712884, 29794.890079780234, 30467.806839606732, 29706.13957253697, 29835.118131770243, 29910.283723596356, 31371.741259994265, 31151.47989466442, 30215.278974580273, 30110.329519902793, 29084.666534527954, 28373.514252249453, 26737.577660148556, 22487.98717509208, 22196.730183479227, 22576.30534618698, 20385.718710143447, 20473.424978931507, 19010.902084120167, 20553.37025443907, 20594.29483720139, 20719.413927210015, 19986.60710158103, 21084.648061790565, 21233.60987142278, 21496.494739785347, 21028.238226728357, 20731.544346385122, 20281.16946117985, 20108.312337630447, 19820.4704741998, 19274.836282974753, 19242.094762817593, 19297.314185582756, 20225.353436423593, 20194.61949892409, 20547.81424115234, 21637.15505158262, 21716.82858548147, 21591.080802162654, 20856.35296768496, 19970.475022939816, 19325.972724650128, 20211.465955545355, 20573.156297917543, 20834.10412942899, 21195.041213834647, 20781.911503996675, 22467.85009614443, 23393.192011630057, 23233.20197091283, 23163.75206257678, 22706.983427210867, 22465.509266066096, 22607.155546771657, 21361.12187130348, 21244.16955918891, 22933.641248968772, 23845.212373894152, 23796.81861062155, 23652.069662121907, 23336.71805186043, 23308.43417279304, 22981.302705754573, 22848.214384500436, 22626.833391275144, 23291.42406079369, 22963.506243621858, 23179.527049985405, 23811.483521591905, 23162.89884942404, 23948.34612720597, 23957.20306053137, 24402.18747061798, 24429.05743708156, 24318.31548303852, 24126.136482577618, 23881.315512357407, 23341.038978010583, 23213.31324159989, 20872.842173501398, 21160.392783176445, 21531.46384880662, 21401.045669959727, 21526.455593085484, 21395.458389989148, 21596.085314556974, 20262.480311022402, 20041.03480395418, 19615.153362859797, 20298.61208082999, 19799.581315787203, 20050.498669841865, 20126.072780901522, 19969.718346916892, 19832.47129556646, 19988.789818433175, 19817.724065572373, 18837.683320773453, 19289.940569121, 19328.139929463316, 21376.91171453879, 21678.543569706628, 21770.14813305873, 22371.48063978407, 20184.555325164954, 20242.289908387913, 19704.005440526256, 19777.03402833151, 20127.23394762749, 19418.571421509565, 19545.591275415263, 18891.282889531798, 18534.64959547727, 19412.39992542163, 19296.990703569038, 18936.31151524196, 18803.90063289787, 19221.84071275122, 19104.620789502645, 19427.780190523128, 19573.431421230798, 19431.10494591723, 19311.848708225836, 19044.067849811498, 19623.584689448744, 20335.899579376473, 20161.03843820979, 19957.55908041741, 19546.328837739784, 19417.479411166132, 19446.416225133773, 19138.999877483147, 19052.64578600759, 19156.96661332697, 19382.53397217804, 19185.437303811446, 19068.91355993786, 19268.562102307453, 19550.466742932043, 19335.02644145188, 19138.08505687014, 19053.203045616505, 19172.380608580974, 19207.734650775248, 19567.769580384924, 19344.96442021395, 20092.23718809519, 20772.803027102687, 20287.956094786256, 20595.103841969667, 20817.982251842404, 20633.696071095317, 20494.897622939236, 20482.959693755372, 20162.689227896553, 20208.7694981217, 21144.83146578881, 21285.056663911386, 20924.62048404909, 20600.67274715879, 18543.761249619893, 15883.15822691518, 17583.252430510052, 17036.875408441774, 16799.722291055714, 16352.028563420386, 16617.484737989726, 16884.341187944265, 16670.426756200326, 16687.911575071244, 16696.219905182574, 16712.920458367662, 16291.223799578982, 15782.301230536288, 16195.588669774414, 16611.637672358618, 16602.269516497403, 16521.577024910126, 16463.883171590274, 16440.222087898794, 16217.639903770933, 16445.47748855228], 'feat_static_cat': [0], 'feat_dynamic_real': None, 'item_id': 'T1'}\n" + ] + } + ], + "source": [ + "print(crypto_val[0])" + ] + }, + { + "cell_type": "code", + "execution_count": 74, + "id": "fb8fb015", + "metadata": {}, + "outputs": [], + "source": [ + "import pandas as pd" + ] + }, + { + "cell_type": "code", + "execution_count": 122, + "id": "23a70d1f", + "metadata": {}, + "outputs": [], + "source": [ + "df = pd.DataFrame(crypto_train)\n", + "df.to_json(r\"C:\\Users\\yozhan\\cryptocurrency\\crypto_data\\train.jsonl\", orient=\"records\", lines=True)\n", + "\n", + "df = pd.DataFrame(crypto_val)\n", + "df.to_json(r\"C:\\Users\\yozhan\\cryptocurrency\\crypto_data\\val.jsonl\", orient=\"records\", lines=True)\n", + "\n", + "df = pd.DataFrame(crypto_test)\n", + "df.to_json(r\"C:\\Users\\yozhan\\cryptocurrency\\crypto_data\\test.jsonl\", orient=\"records\", lines=True)" + ] + }, + { + "cell_type": "code", + "execution_count": 85, + "id": "d0543542", + "metadata": {}, + "outputs": [], + "source": [ + "import os\n", + "os.chdir(r\"C:\\Users\\yozhan\\cryptocurrency\")" + ] + }, + { + "cell_type": "code", + "execution_count": 123, + "id": "3e173898", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Downloading and preparing dataset json/crypto_data to C:/Users/yozhan/.cache/huggingface/datasets/json/crypto_data-4fed3bed476685c7/0.0.0/8bb11242116d547c741b2e8a1f18598ffdd40a1d4f2a2872c7a28b697434bc96...\n" + ] + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "6f2adf5ed58a4dec9be6e2fb24f59894", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "Downloading data files: 0%| | 0/3 [00:00" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "import matplotlib.pyplot as plt\n", + "\n", + "figure, axes = plt.subplots()\n", + "axes.plot(train_example[\"target\"], color=\"blue\")\n", + "axes.plot(validation_example[\"target\"], color=\"red\", alpha=0.5)\n", + "\n", + "plt.show()" + ] + }, + { + "cell_type": "code", + "execution_count": 133, + "id": "ac24be01", + "metadata": {}, + "outputs": [], + "source": [ + "train_dataset = dataset[\"train\"]\n", + "test_dataset = dataset[\"test\"]" + ] + }, + { + "cell_type": "code", + "execution_count": 134, + "id": "8eded590", + "metadata": {}, + "outputs": [], + "source": [ + "from functools import lru_cache\n", + "\n", + "import pandas as pd\n", + "import numpy as np\n", + "\n", + "\n", + "@lru_cache(10_000)\n", + "def convert_to_pandas_period(date, freq):\n", + " return pd.Period(date, freq)\n", + "\n", + "def transform_start_field(batch, freq):\n", + " batch[\"start\"] = [convert_to_pandas_period(date, freq) for date in batch[\"start\"]]\n", + " return batch" + ] + }, + { + "cell_type": "code", + "execution_count": 135, + "id": "e27f7621", + "metadata": {}, + "outputs": [], + "source": [ + "from functools import partial\n", + "\n", + "train_dataset.set_transform(partial(transform_start_field, freq=freq))\n", + "test_dataset.set_transform(partial(transform_start_field, freq=freq))" + ] + }, + { + "cell_type": "code", + "execution_count": 136, + "id": "d224f2ab", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[1, 2, 3, 4, 5, 6, 7, 8, 13, 14, 15, 20, 21, 22, 27, 28, 29, 30, 31, 56, 84, 363, 364, 365, 727, 728, 729, 1091, 1092, 1093]\n" + ] + } + ], + "source": [ + "from gluonts.time_feature import get_lags_for_frequency\n", + "\n", + "lags_sequence = get_lags_for_frequency(freq)\n", + "print(lags_sequence)" + ] + }, + { + "cell_type": "code", + "execution_count": 137, + "id": "439f37be", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[, , ]\n" + ] + } + ], + "source": [ + "from gluonts.time_feature import time_features_from_frequency_str\n", + "\n", + "time_features = time_features_from_frequency_str(freq)\n", + "print(time_features)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "d02ad18c", + "metadata": {}, + "outputs": [], + "source": [ + "# 3 features; thus the following code needs some customization" + ] + }, + { + "cell_type": "code", + "execution_count": 138, + "id": "78ce200c", + "metadata": {}, + "outputs": [], + "source": [ + "from transformers import TimeSeriesTransformerConfig, TimeSeriesTransformerForPrediction\n", + "\n", + "config = TimeSeriesTransformerConfig(\n", + " prediction_length=prediction_length,\n", + " # context length:\n", + " context_length=prediction_length * 2,\n", + " # lags coming from helper given the freq:\n", + " lags_sequence=lags_sequence,\n", + " # we'll add 4 time features (\"day_of_week\", \"day_of_month\", \"day of year\" and \"age\", see further):\n", + " num_time_features=len(time_features) + 1,\n", + " # we have a single static categorical feature, namely time series ID:\n", + " num_static_categorical_features=1,\n", + " # it has 10 possible values:\n", + " cardinality=[len(train_dataset)],\n", + " # the model will learn an embedding of size 4 for each of the 366 possible values:\n", + " embedding_dimension=[4],\n", + " \n", + " # transformer params:\n", + " encoder_layers=4,\n", + " decoder_layers=4,\n", + " d_model=32,\n", + " \n", + ")\n", + "\n", + "model = TimeSeriesTransformerForPrediction(config)" + ] + }, + { + "cell_type": "code", + "execution_count": 139, + "id": "ec101977", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'student_t'" + ] + }, + "execution_count": 139, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "model.config.distribution_output" + ] + }, + { + "cell_type": "code", + "execution_count": 140, + "id": "57bdf9ce", + "metadata": {}, + "outputs": [], + "source": [ + "from gluonts.time_feature import (\n", + " time_features_from_frequency_str,\n", + " TimeFeature,\n", + " get_lags_for_frequency,\n", + ")\n", + "from gluonts.dataset.field_names import FieldName\n", + "from gluonts.transform import (\n", + " AddAgeFeature,\n", + " AddObservedValuesIndicator,\n", + " AddTimeFeatures,\n", + " AsNumpyArray,\n", + " Chain,\n", + " ExpectedNumInstanceSampler,\n", + " InstanceSplitter,\n", + " RemoveFields,\n", + " SelectFields,\n", + " SetField,\n", + " TestSplitSampler,\n", + " Transformation,\n", + " ValidationSplitSampler,\n", + " VstackFeatures,\n", + " RenameFields,\n", + ")" + ] + }, + { + "cell_type": "code", + "execution_count": 141, + "id": "fac6a466", + "metadata": {}, + "outputs": [], + "source": [ + "from transformers import PretrainedConfig\n", + "\n", + "def create_transformation(freq: str, config: PretrainedConfig) -> Transformation:\n", + " remove_field_names = []\n", + " if config.num_static_real_features == 0:\n", + " remove_field_names.append(FieldName.FEAT_STATIC_REAL)\n", + " if config.num_dynamic_real_features == 0:\n", + " remove_field_names.append(FieldName.FEAT_DYNAMIC_REAL)\n", + " if config.num_static_categorical_features == 0:\n", + " remove_field_names.append(FieldName.FEAT_STATIC_CAT)\n", + " print(remove_field_names)\n", + "\n", + " # a bit like torchvision.transforms.Compose\n", + " return Chain(\n", + " # step 1: remove static/dynamic fields if not specified\n", + " [RemoveFields(field_names=remove_field_names)]\n", + " # step 2: convert the data to NumPy (potentially not needed)\n", + " + (\n", + " [\n", + " AsNumpyArray(\n", + " field=FieldName.FEAT_STATIC_CAT,\n", + " expected_ndim=1,\n", + " dtype=int,\n", + " )\n", + " ]\n", + " if config.num_static_categorical_features > 0\n", + " else []\n", + " )\n", + " + (\n", + " [\n", + " AsNumpyArray(\n", + " field=FieldName.FEAT_STATIC_REAL,\n", + " expected_ndim=1,\n", + " )\n", + " ]\n", + " if config.num_static_real_features > 0\n", + " else []\n", + " )\n", + " + [\n", + " AsNumpyArray(\n", + " field=FieldName.TARGET,\n", + " # we expect an extra dim for the multivariate case:\n", + " expected_ndim=1 if config.input_size == 1 else 2,\n", + " ),\n", + " # step 3: handle the NaN's by filling in the target with zero\n", + " # and return the mask (which is in the observed values)\n", + " # true for observed values, false for nan's\n", + " # the decoder uses this mask (no loss is incurred for unobserved values)\n", + " # see loss_weights inside the xxxForPrediction model\n", + " AddObservedValuesIndicator(\n", + " target_field=FieldName.TARGET,\n", + " output_field=FieldName.OBSERVED_VALUES,\n", + " ),\n", + " # step 4: add temporal features based on freq of the dataset\n", + " # month of year in the case when freq=\"M\"\n", + " # these serve as positional encodings\n", + " AddTimeFeatures(\n", + " start_field=FieldName.START,\n", + " target_field=FieldName.TARGET,\n", + " output_field=FieldName.FEAT_TIME,\n", + " time_features=time_features_from_frequency_str(freq),\n", + " pred_length=config.prediction_length,\n", + " ),\n", + " # step 5: add another temporal feature (just a single number)\n", + " # tells the model where in its life the value of the time series is,\n", + " # sort of a running counter\n", + " AddAgeFeature(\n", + " target_field=FieldName.TARGET,\n", + " output_field=FieldName.FEAT_AGE,\n", + " pred_length=config.prediction_length,\n", + " log_scale=True,\n", + " ),\n", + " # step 6: vertically stack all the temporal features into the key FEAT_TIME\n", + " VstackFeatures(\n", + " output_field=FieldName.FEAT_TIME,\n", + " input_fields=[FieldName.FEAT_TIME, FieldName.FEAT_AGE]\n", + " + (\n", + " [FieldName.FEAT_DYNAMIC_REAL]\n", + " if config.num_dynamic_real_features > 0\n", + " else []\n", + " ),\n", + " ),\n", + " # step 7: rename to match HuggingFace names\n", + " RenameFields(\n", + " mapping={\n", + " FieldName.FEAT_STATIC_CAT: \"static_categorical_features\",\n", + " FieldName.FEAT_STATIC_REAL: \"static_real_features\",\n", + " FieldName.FEAT_TIME: \"time_features\",\n", + " FieldName.TARGET: \"values\",\n", + " FieldName.OBSERVED_VALUES: \"observed_mask\",\n", + " }\n", + " ),\n", + " ]\n", + " )" + ] + }, + { + "cell_type": "code", + "execution_count": 142, + "id": "fd44808d", + "metadata": {}, + "outputs": [], + "source": [ + "from gluonts.transform.sampler import InstanceSampler\n", + "from typing import Optional\n", + "\n", + "def create_instance_splitter(\n", + " config: PretrainedConfig,\n", + " mode: str,\n", + " train_sampler: Optional[InstanceSampler] = None,\n", + " validation_sampler: Optional[InstanceSampler] = None,\n", + ") -> Transformation:\n", + " assert mode in [\"train\", \"validation\", \"test\"]\n", + "\n", + " instance_sampler = {\n", + " \"train\": train_sampler\n", + " or ExpectedNumInstanceSampler(\n", + " num_instances=1.0, min_future=config.prediction_length\n", + " ),\n", + " \"validation\": validation_sampler\n", + " or ValidationSplitSampler(min_future=config.prediction_length),\n", + " \"test\": TestSplitSampler(),\n", + " }[mode]\n", + "\n", + " return InstanceSplitter(\n", + " target_field=\"values\",\n", + " is_pad_field=FieldName.IS_PAD,\n", + " start_field=FieldName.START,\n", + " forecast_start_field=FieldName.FORECAST_START,\n", + " instance_sampler=instance_sampler,\n", + " past_length=config.context_length + max(config.lags_sequence),\n", + " future_length=config.prediction_length,\n", + " time_series_fields=[\"time_features\", \"observed_mask\"],\n", + " )" + ] + }, + { + "cell_type": "code", + "execution_count": 143, + "id": "dc2b0720", + "metadata": {}, + "outputs": [], + "source": [ + "from typing import Iterable\n", + "\n", + "import torch\n", + "from gluonts.itertools import Cached, Cyclic\n", + "from gluonts.dataset.loader import as_stacked_batches\n", + "\n", + "\n", + "def create_train_dataloader(\n", + " config: PretrainedConfig,\n", + " freq,\n", + " data,\n", + " batch_size: int,\n", + " num_batches_per_epoch: int,\n", + " shuffle_buffer_length: Optional[int] = None,\n", + " cache_data: bool = True,\n", + " **kwargs,\n", + ") -> Iterable:\n", + " PREDICTION_INPUT_NAMES = [\n", + " \"past_time_features\",\n", + " \"past_values\",\n", + " \"past_observed_mask\",\n", + " \"future_time_features\",\n", + " ]\n", + " if config.num_static_categorical_features > 0:\n", + " PREDICTION_INPUT_NAMES.append(\"static_categorical_features\")\n", + "\n", + " if config.num_static_real_features > 0:\n", + " PREDICTION_INPUT_NAMES.append(\"static_real_features\")\n", + "\n", + " TRAINING_INPUT_NAMES = PREDICTION_INPUT_NAMES + [\n", + " \"future_values\",\n", + " \"future_observed_mask\",\n", + " ]\n", + "\n", + " transformation = create_transformation(freq, config)\n", + " transformed_data = transformation.apply(data, is_train=True)\n", + " if cache_data:\n", + " transformed_data = Cached(transformed_data)\n", + "\n", + " # we initialize a Training instance\n", + " instance_splitter = create_instance_splitter(config, \"train\")\n", + "\n", + " # the instance splitter will sample a window of\n", + " # context length + lags + prediction length (from the 366 possible transformed time series)\n", + " # randomly from within the target time series and return an iterator.\n", + " stream = Cyclic(transformed_data).stream()\n", + " training_instances = instance_splitter.apply(\n", + " stream, is_train=True\n", + " )\n", + " \n", + " return as_stacked_batches(\n", + " training_instances,\n", + " batch_size=batch_size,\n", + " shuffle_buffer_length=shuffle_buffer_length,\n", + " field_names=TRAINING_INPUT_NAMES,\n", + " output_type=torch.tensor,\n", + " num_batches_per_epoch=num_batches_per_epoch,\n", + " )" + ] + }, + { + "cell_type": "code", + "execution_count": 144, + "id": "f42d7b4d", + "metadata": {}, + "outputs": [], + "source": [ + "def create_test_dataloader(\n", + " config: PretrainedConfig,\n", + " freq,\n", + " data,\n", + " batch_size: int,\n", + " **kwargs,\n", + "):\n", + " PREDICTION_INPUT_NAMES = [\n", + " \"past_time_features\",\n", + " \"past_values\",\n", + " \"past_observed_mask\",\n", + " \"future_time_features\",\n", + " ]\n", + " if config.num_static_categorical_features > 0:\n", + " PREDICTION_INPUT_NAMES.append(\"static_categorical_features\")\n", + "\n", + " if config.num_static_real_features > 0:\n", + " PREDICTION_INPUT_NAMES.append(\"static_real_features\")\n", + "\n", + " transformation = create_transformation(freq, config)\n", + " transformed_data = transformation.apply(data, is_train=False)\n", + "\n", + " # we create a Test Instance splitter which will sample the very last\n", + " # context window seen during training only for the encoder.\n", + " instance_sampler = create_instance_splitter(config, \"test\")\n", + "\n", + " # we apply the transformations in test mode\n", + " testing_instances = instance_sampler.apply(transformed_data, is_train=False)\n", + " \n", + " return as_stacked_batches(\n", + " testing_instances,\n", + " batch_size=batch_size,\n", + " output_type=torch.tensor,\n", + " field_names=PREDICTION_INPUT_NAMES,\n", + " )" + ] + }, + { + "cell_type": "code", + "execution_count": 145, + "id": "7bfa4bf9", + "metadata": { + "scrolled": true + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "['feat_static_real', 'feat_dynamic_real']\n", + "['feat_static_real', 'feat_dynamic_real']\n" + ] + } + ], + "source": [ + "train_dataloader = create_train_dataloader(\n", + " config=config,\n", + " freq=freq,\n", + " data=train_dataset,\n", + " batch_size=256,\n", + " num_batches_per_epoch=100,\n", + ")\n", + "\n", + "test_dataloader = create_test_dataloader(\n", + " config=config,\n", + " freq=freq,\n", + " data=test_dataset,\n", + " batch_size=64,\n", + ")" + ] + }, + { + "cell_type": "code", + "execution_count": 146, + "id": "97f7d9ce", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "past_time_features torch.Size([256, 1153, 4]) torch.FloatTensor\n", + "past_values torch.Size([256, 1153]) torch.FloatTensor\n", + "past_observed_mask torch.Size([256, 1153]) torch.FloatTensor\n", + "future_time_features torch.Size([256, 30, 4]) torch.FloatTensor\n", + "static_categorical_features torch.Size([256, 1]) torch.IntTensor\n", + "future_values torch.Size([256, 30]) torch.FloatTensor\n", + "future_observed_mask torch.Size([256, 30]) torch.FloatTensor\n" + ] + } + ], + "source": [ + "batch = next(iter(train_dataloader))\n", + "for k, v in batch.items():\n", + " print(k, v.shape, v.type())" + ] + }, + { + "cell_type": "code", + "execution_count": 147, + "id": "f2eb62a1", + "metadata": {}, + "outputs": [], + "source": [ + "# perform forward pass\n", + "outputs = model(\n", + " past_values=batch[\"past_values\"],\n", + " past_time_features=batch[\"past_time_features\"],\n", + " past_observed_mask=batch[\"past_observed_mask\"],\n", + " static_categorical_features=batch[\"static_categorical_features\"]\n", + " if config.num_static_categorical_features > 0\n", + " else None,\n", + " static_real_features=batch[\"static_real_features\"]\n", + " if config.num_static_real_features > 0\n", + " else None,\n", + " future_values=batch[\"future_values\"],\n", + " future_time_features=batch[\"future_time_features\"],\n", + " future_observed_mask=batch[\"future_observed_mask\"],\n", + " output_hidden_states=True,\n", + ")" + ] + }, + { + "cell_type": "code", + "execution_count": 148, + "id": "d8cb3e86", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Loss: 9.362533569335938\n", + "CPU times: total: 0 ns\n", + "Wall time: 0 ns\n" + ] + } + ], + "source": [ + "%%time\n", + "\n", + "print(\"Loss:\", outputs.loss.item())" + ] + }, + { + "cell_type": "code", + "execution_count": 149, + "id": "b6a07f1e", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "9.260628700256348\n", + "8.101223945617676\n", + "CPU times: total: 1h 29min 14s\n", + "Wall time: 12min 33s\n" + ] + } + ], + "source": [ + "%%time\n", + "\n", + "from accelerate import Accelerator\n", + "from torch.optim import AdamW\n", + "\n", + "accelerator = Accelerator()\n", + "device = accelerator.device\n", + "\n", + "model.to(device)\n", + "optimizer = AdamW(model.parameters(), lr=6e-4, betas=(0.9, 0.95), weight_decay=1e-1)\n", + "\n", + "model, optimizer, train_dataloader = accelerator.prepare(\n", + " model,\n", + " optimizer,\n", + " train_dataloader,\n", + ")\n", + "\n", + "model.train()\n", + "for epoch in range(2):\n", + " for idx, batch in enumerate(train_dataloader):\n", + " optimizer.zero_grad()\n", + " outputs = model(\n", + " static_categorical_features=batch[\"static_categorical_features\"].to(device)\n", + " if config.num_static_categorical_features > 0\n", + " else None,\n", + " static_real_features=batch[\"static_real_features\"].to(device)\n", + " if config.num_static_real_features > 0\n", + " else None,\n", + " past_time_features=batch[\"past_time_features\"].to(device),\n", + " past_values=batch[\"past_values\"].to(device),\n", + " future_time_features=batch[\"future_time_features\"].to(device),\n", + " future_values=batch[\"future_values\"].to(device),\n", + " past_observed_mask=batch[\"past_observed_mask\"].to(device),\n", + " future_observed_mask=batch[\"future_observed_mask\"].to(device),\n", + " )\n", + " loss = outputs.loss\n", + "\n", + " # Backpropagation\n", + " accelerator.backward(loss)\n", + " optimizer.step()\n", + "\n", + " if idx % 100 == 0:\n", + " print(loss.item())" + ] + }, + { + "cell_type": "code", + "execution_count": 155, + "id": "6e823ff1", + "metadata": {}, + "outputs": [ + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "32f2b756884c4e7f8d772aaed0304e8d", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "VBox(children=(HTML(value='
3\u001b[0m \u001b[43mapi\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mupload_file\u001b[49m\u001b[43m(\u001b[49m\u001b[43mpath_or_fileobj\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;124;43mr\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mC:\u001b[39;49m\u001b[38;5;124;43m\\\u001b[39;49m\u001b[38;5;124;43mUsers\u001b[39;49m\u001b[38;5;124;43m\\\u001b[39;49m\u001b[38;5;124;43myozhan\u001b[39;49m\u001b[38;5;124;43m\\\u001b[39;49m\u001b[38;5;124;43mcryptocurrency\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\n\u001b[0;32m 4\u001b[0m \u001b[43m \u001b[49m\u001b[43mrepo_id\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mcryptocurrency\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\n", + "File \u001b[1;32m~\\AppData\\Local\\anaconda3\\lib\\site-packages\\huggingface_hub\\utils\\_validators.py:118\u001b[0m, in \u001b[0;36mvalidate_hf_hub_args.._inner_fn\u001b[1;34m(*args, **kwargs)\u001b[0m\n\u001b[0;32m 115\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m check_use_auth_token:\n\u001b[0;32m 116\u001b[0m kwargs \u001b[38;5;241m=\u001b[39m smoothly_deprecate_use_auth_token(fn_name\u001b[38;5;241m=\u001b[39mfn\u001b[38;5;241m.\u001b[39m\u001b[38;5;18m__name__\u001b[39m, has_token\u001b[38;5;241m=\u001b[39mhas_token, kwargs\u001b[38;5;241m=\u001b[39mkwargs)\n\u001b[1;32m--> 118\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m fn(\u001b[38;5;241m*\u001b[39margs, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs)\n", + "File \u001b[1;32m~\\AppData\\Local\\anaconda3\\lib\\site-packages\\huggingface_hub\\hf_api.py:828\u001b[0m, in \u001b[0;36mfuture_compatible.._inner\u001b[1;34m(self, *args, **kwargs)\u001b[0m\n\u001b[0;32m 825\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mrun_as_future(fn, \u001b[38;5;28mself\u001b[39m, \u001b[38;5;241m*\u001b[39margs, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs)\n\u001b[0;32m 827\u001b[0m \u001b[38;5;66;03m# Otherwise, call the function normally\u001b[39;00m\n\u001b[1;32m--> 828\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m fn(\u001b[38;5;28mself\u001b[39m, \u001b[38;5;241m*\u001b[39margs, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs)\n", + "\u001b[1;31mTypeError\u001b[0m: HfApi.upload_file() missing 1 required keyword-only argument: 'path_in_repo'" + ] + } + ], + "source": [ + "from huggingface_hub import HfApi\n", + "api = HfApi()\n", + "api.upload_folder(path_or_fileobj=r\"C:\\Users\\yozhan\\cryptocurrency\", \n", + " path_in_repo\n", + " repo_id=\"cryptocurrency\")" + ] + }, + { + "cell_type": "code", + "execution_count": 152, + "id": "2d531391", + "metadata": { + "scrolled": true + }, + "outputs": [ + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "6b4c2dc13c58453f8a4644f3fd556070", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "pytorch_model.bin: 0%| | 0.00/373k [00:00:7\u001b[0m\n", + "File \u001b[1;32m~\\AppData\\Local\\anaconda3\\lib\\site-packages\\torch\\autograd\\grad_mode.py:27\u001b[0m, in \u001b[0;36m_DecoratorContextManager.__call__..decorate_context\u001b[1;34m(*args, **kwargs)\u001b[0m\n\u001b[0;32m 24\u001b[0m \u001b[38;5;129m@functools\u001b[39m\u001b[38;5;241m.\u001b[39mwraps(func)\n\u001b[0;32m 25\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mdecorate_context\u001b[39m(\u001b[38;5;241m*\u001b[39margs, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs):\n\u001b[0;32m 26\u001b[0m \u001b[38;5;28;01mwith\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mclone():\n\u001b[1;32m---> 27\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m func(\u001b[38;5;241m*\u001b[39margs, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs)\n", + "File \u001b[1;32m~\\AppData\\Local\\anaconda3\\lib\\site-packages\\transformers\\models\\time_series_transformer\\modeling_time_series_transformer.py:1809\u001b[0m, in \u001b[0;36mTimeSeriesTransformerForPrediction.generate\u001b[1;34m(self, past_values, past_time_features, future_time_features, past_observed_mask, static_categorical_features, static_real_features, output_attentions, output_hidden_states)\u001b[0m\n\u001b[0;32m 1805\u001b[0m reshaped_lagged_sequence \u001b[38;5;241m=\u001b[39m lagged_sequence\u001b[38;5;241m.\u001b[39mreshape(lags_shape[\u001b[38;5;241m0\u001b[39m], lags_shape[\u001b[38;5;241m1\u001b[39m], \u001b[38;5;241m-\u001b[39m\u001b[38;5;241m1\u001b[39m)\n\u001b[0;32m 1807\u001b[0m decoder_input \u001b[38;5;241m=\u001b[39m torch\u001b[38;5;241m.\u001b[39mcat((reshaped_lagged_sequence, repeated_features[:, : k \u001b[38;5;241m+\u001b[39m \u001b[38;5;241m1\u001b[39m]), dim\u001b[38;5;241m=\u001b[39m\u001b[38;5;241m-\u001b[39m\u001b[38;5;241m1\u001b[39m)\n\u001b[1;32m-> 1809\u001b[0m dec_output \u001b[38;5;241m=\u001b[39m \u001b[43mdecoder\u001b[49m\u001b[43m(\u001b[49m\u001b[43minputs_embeds\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mdecoder_input\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mencoder_hidden_states\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mrepeated_enc_last_hidden\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 1810\u001b[0m dec_last_hidden \u001b[38;5;241m=\u001b[39m dec_output\u001b[38;5;241m.\u001b[39mlast_hidden_state\n\u001b[0;32m 1812\u001b[0m params \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mparameter_projection(dec_last_hidden[:, \u001b[38;5;241m-\u001b[39m\u001b[38;5;241m1\u001b[39m:])\n", + "File \u001b[1;32m~\\AppData\\Local\\anaconda3\\lib\\site-packages\\torch\\nn\\modules\\module.py:1130\u001b[0m, in \u001b[0;36mModule._call_impl\u001b[1;34m(self, *input, **kwargs)\u001b[0m\n\u001b[0;32m 1126\u001b[0m \u001b[38;5;66;03m# If we don't have any hooks, we want to skip the rest of the logic in\u001b[39;00m\n\u001b[0;32m 1127\u001b[0m \u001b[38;5;66;03m# this function, and just call forward.\u001b[39;00m\n\u001b[0;32m 1128\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m (\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_backward_hooks \u001b[38;5;129;01mor\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_forward_hooks \u001b[38;5;129;01mor\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_forward_pre_hooks \u001b[38;5;129;01mor\u001b[39;00m _global_backward_hooks\n\u001b[0;32m 1129\u001b[0m \u001b[38;5;129;01mor\u001b[39;00m _global_forward_hooks \u001b[38;5;129;01mor\u001b[39;00m _global_forward_pre_hooks):\n\u001b[1;32m-> 1130\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m forward_call(\u001b[38;5;241m*\u001b[39m\u001b[38;5;28minput\u001b[39m, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs)\n\u001b[0;32m 1131\u001b[0m \u001b[38;5;66;03m# Do not call functions when jit is used\u001b[39;00m\n\u001b[0;32m 1132\u001b[0m full_backward_hooks, non_full_backward_hooks \u001b[38;5;241m=\u001b[39m [], []\n", + "File \u001b[1;32m~\\AppData\\Local\\anaconda3\\lib\\site-packages\\transformers\\models\\time_series_transformer\\modeling_time_series_transformer.py:1178\u001b[0m, in \u001b[0;36mTimeSeriesTransformerDecoder.forward\u001b[1;34m(self, attention_mask, encoder_hidden_states, encoder_attention_mask, head_mask, cross_attn_head_mask, past_key_values, inputs_embeds, use_cache, output_attentions, output_hidden_states, return_dict)\u001b[0m\n\u001b[0;32m 1167\u001b[0m layer_outputs \u001b[38;5;241m=\u001b[39m torch\u001b[38;5;241m.\u001b[39mutils\u001b[38;5;241m.\u001b[39mcheckpoint\u001b[38;5;241m.\u001b[39mcheckpoint(\n\u001b[0;32m 1168\u001b[0m create_custom_forward(decoder_layer),\n\u001b[0;32m 1169\u001b[0m hidden_states,\n\u001b[1;32m (...)\u001b[0m\n\u001b[0;32m 1175\u001b[0m \u001b[38;5;28;01mNone\u001b[39;00m,\n\u001b[0;32m 1176\u001b[0m )\n\u001b[0;32m 1177\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[1;32m-> 1178\u001b[0m layer_outputs \u001b[38;5;241m=\u001b[39m \u001b[43mdecoder_layer\u001b[49m\u001b[43m(\u001b[49m\n\u001b[0;32m 1179\u001b[0m \u001b[43m \u001b[49m\u001b[43mhidden_states\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m 1180\u001b[0m \u001b[43m \u001b[49m\u001b[43mattention_mask\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mattention_mask\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m 1181\u001b[0m \u001b[43m \u001b[49m\u001b[43mencoder_hidden_states\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mencoder_hidden_states\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m 1182\u001b[0m \u001b[43m \u001b[49m\u001b[43mencoder_attention_mask\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mencoder_attention_mask\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m 1183\u001b[0m \u001b[43m \u001b[49m\u001b[43mlayer_head_mask\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43m(\u001b[49m\u001b[43mhead_mask\u001b[49m\u001b[43m[\u001b[49m\u001b[43midx\u001b[49m\u001b[43m]\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;28;43;01mif\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43mhead_mask\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;129;43;01mis\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[38;5;129;43;01mnot\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[38;5;28;43;01mNone\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[38;5;28;43;01melse\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[38;5;28;43;01mNone\u001b[39;49;00m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m 1184\u001b[0m \u001b[43m \u001b[49m\u001b[43mcross_attn_layer_head_mask\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43m(\u001b[49m\n\u001b[0;32m 1185\u001b[0m \u001b[43m \u001b[49m\u001b[43mcross_attn_head_mask\u001b[49m\u001b[43m[\u001b[49m\u001b[43midx\u001b[49m\u001b[43m]\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;28;43;01mif\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43mcross_attn_head_mask\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;129;43;01mis\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[38;5;129;43;01mnot\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[38;5;28;43;01mNone\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[38;5;28;43;01melse\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[38;5;28;43;01mNone\u001b[39;49;00m\n\u001b[0;32m 1186\u001b[0m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m 1187\u001b[0m \u001b[43m \u001b[49m\u001b[43mpast_key_value\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mpast_key_value\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m 1188\u001b[0m \u001b[43m \u001b[49m\u001b[43moutput_attentions\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43moutput_attentions\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m 1189\u001b[0m \u001b[43m \u001b[49m\u001b[43muse_cache\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43muse_cache\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m 1190\u001b[0m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 1191\u001b[0m hidden_states \u001b[38;5;241m=\u001b[39m layer_outputs[\u001b[38;5;241m0\u001b[39m]\n\u001b[0;32m 1193\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m use_cache:\n", + "File \u001b[1;32m~\\AppData\\Local\\anaconda3\\lib\\site-packages\\torch\\nn\\modules\\module.py:1130\u001b[0m, in \u001b[0;36mModule._call_impl\u001b[1;34m(self, *input, **kwargs)\u001b[0m\n\u001b[0;32m 1126\u001b[0m \u001b[38;5;66;03m# If we don't have any hooks, we want to skip the rest of the logic in\u001b[39;00m\n\u001b[0;32m 1127\u001b[0m \u001b[38;5;66;03m# this function, and just call forward.\u001b[39;00m\n\u001b[0;32m 1128\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m (\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_backward_hooks \u001b[38;5;129;01mor\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_forward_hooks \u001b[38;5;129;01mor\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_forward_pre_hooks \u001b[38;5;129;01mor\u001b[39;00m _global_backward_hooks\n\u001b[0;32m 1129\u001b[0m \u001b[38;5;129;01mor\u001b[39;00m _global_forward_hooks \u001b[38;5;129;01mor\u001b[39;00m _global_forward_pre_hooks):\n\u001b[1;32m-> 1130\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m forward_call(\u001b[38;5;241m*\u001b[39m\u001b[38;5;28minput\u001b[39m, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs)\n\u001b[0;32m 1131\u001b[0m \u001b[38;5;66;03m# Do not call functions when jit is used\u001b[39;00m\n\u001b[0;32m 1132\u001b[0m full_backward_hooks, non_full_backward_hooks \u001b[38;5;241m=\u001b[39m [], []\n", + "File \u001b[1;32m~\\AppData\\Local\\anaconda3\\lib\\site-packages\\transformers\\models\\time_series_transformer\\modeling_time_series_transformer.py:611\u001b[0m, in \u001b[0;36mTimeSeriesTransformerDecoderLayer.forward\u001b[1;34m(self, hidden_states, attention_mask, encoder_hidden_states, encoder_attention_mask, layer_head_mask, cross_attn_layer_head_mask, past_key_value, output_attentions, use_cache)\u001b[0m\n\u001b[0;32m 609\u001b[0m \u001b[38;5;66;03m# cross_attn cached key/values tuple is at positions 3,4 of present_key_value tuple\u001b[39;00m\n\u001b[0;32m 610\u001b[0m cross_attn_past_key_value \u001b[38;5;241m=\u001b[39m past_key_value[\u001b[38;5;241m-\u001b[39m\u001b[38;5;241m2\u001b[39m:] \u001b[38;5;28;01mif\u001b[39;00m past_key_value \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m \u001b[38;5;28;01melse\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m\n\u001b[1;32m--> 611\u001b[0m hidden_states, cross_attn_weights, cross_attn_present_key_value \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mencoder_attn\u001b[49m\u001b[43m(\u001b[49m\n\u001b[0;32m 612\u001b[0m \u001b[43m \u001b[49m\u001b[43mhidden_states\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mhidden_states\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m 613\u001b[0m \u001b[43m \u001b[49m\u001b[43mkey_value_states\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mencoder_hidden_states\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m 614\u001b[0m \u001b[43m \u001b[49m\u001b[43mattention_mask\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mencoder_attention_mask\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m 615\u001b[0m \u001b[43m \u001b[49m\u001b[43mlayer_head_mask\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mcross_attn_layer_head_mask\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m 616\u001b[0m \u001b[43m \u001b[49m\u001b[43mpast_key_value\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mcross_attn_past_key_value\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m 617\u001b[0m \u001b[43m \u001b[49m\u001b[43moutput_attentions\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43moutput_attentions\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m 618\u001b[0m \u001b[43m\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 619\u001b[0m hidden_states \u001b[38;5;241m=\u001b[39m nn\u001b[38;5;241m.\u001b[39mfunctional\u001b[38;5;241m.\u001b[39mdropout(hidden_states, p\u001b[38;5;241m=\u001b[39m\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mdropout, training\u001b[38;5;241m=\u001b[39m\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mtraining)\n\u001b[0;32m 620\u001b[0m hidden_states \u001b[38;5;241m=\u001b[39m residual \u001b[38;5;241m+\u001b[39m hidden_states\n", + "File \u001b[1;32m~\\AppData\\Local\\anaconda3\\lib\\site-packages\\torch\\nn\\modules\\module.py:1130\u001b[0m, in \u001b[0;36mModule._call_impl\u001b[1;34m(self, *input, **kwargs)\u001b[0m\n\u001b[0;32m 1126\u001b[0m \u001b[38;5;66;03m# If we don't have any hooks, we want to skip the rest of the logic in\u001b[39;00m\n\u001b[0;32m 1127\u001b[0m \u001b[38;5;66;03m# this function, and just call forward.\u001b[39;00m\n\u001b[0;32m 1128\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m (\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_backward_hooks \u001b[38;5;129;01mor\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_forward_hooks \u001b[38;5;129;01mor\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_forward_pre_hooks \u001b[38;5;129;01mor\u001b[39;00m _global_backward_hooks\n\u001b[0;32m 1129\u001b[0m \u001b[38;5;129;01mor\u001b[39;00m _global_forward_hooks \u001b[38;5;129;01mor\u001b[39;00m _global_forward_pre_hooks):\n\u001b[1;32m-> 1130\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m forward_call(\u001b[38;5;241m*\u001b[39m\u001b[38;5;28minput\u001b[39m, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs)\n\u001b[0;32m 1131\u001b[0m \u001b[38;5;66;03m# Do not call functions when jit is used\u001b[39;00m\n\u001b[0;32m 1132\u001b[0m full_backward_hooks, non_full_backward_hooks \u001b[38;5;241m=\u001b[39m [], []\n", + "File \u001b[1;32m~\\AppData\\Local\\anaconda3\\lib\\site-packages\\transformers\\models\\time_series_transformer\\modeling_time_series_transformer.py:400\u001b[0m, in \u001b[0;36mTimeSeriesTransformerAttention.forward\u001b[1;34m(self, hidden_states, key_value_states, past_key_value, attention_mask, layer_head_mask, output_attentions)\u001b[0m\n\u001b[0;32m 397\u001b[0m value_states \u001b[38;5;241m=\u001b[39m value_states\u001b[38;5;241m.\u001b[39mreshape(\u001b[38;5;241m*\u001b[39mproj_shape)\n\u001b[0;32m 399\u001b[0m src_len \u001b[38;5;241m=\u001b[39m key_states\u001b[38;5;241m.\u001b[39msize(\u001b[38;5;241m1\u001b[39m)\n\u001b[1;32m--> 400\u001b[0m attn_weights \u001b[38;5;241m=\u001b[39m \u001b[43mtorch\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mbmm\u001b[49m\u001b[43m(\u001b[49m\u001b[43mquery_states\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mkey_states\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mtranspose\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m1\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m2\u001b[39;49m\u001b[43m)\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 402\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m attn_weights\u001b[38;5;241m.\u001b[39msize() \u001b[38;5;241m!=\u001b[39m (bsz \u001b[38;5;241m*\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mnum_heads, tgt_len, src_len):\n\u001b[0;32m 403\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mValueError\u001b[39;00m(\n\u001b[0;32m 404\u001b[0m \u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mAttention weights should be of size \u001b[39m\u001b[38;5;132;01m{\u001b[39;00m(bsz \u001b[38;5;241m*\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mnum_heads, tgt_len, src_len)\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m, but is\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[0;32m 405\u001b[0m \u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mattn_weights\u001b[38;5;241m.\u001b[39msize()\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m\"\u001b[39m\n\u001b[0;32m 406\u001b[0m )\n", + "\u001b[1;31mKeyboardInterrupt\u001b[0m: " + ] + } + ], + "source": [ + "%%time\n", + "\n", + "model.eval()\n", + "\n", + "forecasts = []\n", + "\n", + "for batch in test_dataloader:\n", + " print(batch)\n", + " outputs = model.generate(\n", + " static_categorical_features=batch[\"static_categorical_features\"].to(device)\n", + " if config.num_static_categorical_features > 0\n", + " else None,\n", + " static_real_features=batch[\"static_real_features\"].to(device)\n", + " if config.num_static_real_features > 0\n", + " else None,\n", + " past_time_features=batch[\"past_time_features\"].to(device),\n", + " past_values=batch[\"past_values\"].to(device),\n", + " future_time_features=batch[\"future_time_features\"].to(device),\n", + " past_observed_mask=batch[\"past_observed_mask\"].to(device),\n", + " )\n", + " forecasts.append(outputs.sequences.cpu().numpy())" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "2a13e68a", + "metadata": {}, + "outputs": [], + "source": [ + "print(forecasts[0].shape)\n", + "forecasts = np.vstack(forecasts)\n", + "print(forecasts.shape)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "f945d7cf", + "metadata": {}, + "outputs": [], + "source": [ + "from evaluate import load\n", + "from gluonts.time_feature import get_seasonality\n", + "\n", + "mase_metric = load(\"mase\")\n", + "smape_metric = load(\"smape\")\n", + "\n", + "forecast_median = np.median(forecasts, 1)\n", + "\n", + "mase_metrics = []\n", + "smape_metrics = []\n", + "for item_id, ts in enumerate(test_dataset):\n", + " training_data = ts[\"target\"][:-prediction_length]\n", + " ground_truth = ts[\"target\"][-prediction_length:]\n", + " mase = mase_metric.compute(\n", + " predictions=forecast_median[item_id], \n", + " references=np.array(ground_truth), \n", + " training=np.array(training_data), \n", + " periodicity=get_seasonality(freq))\n", + " mase_metrics.append(mase[\"mase\"])\n", + " \n", + " smape = smape_metric.compute(\n", + " predictions=forecast_median[item_id], \n", + " references=np.array(ground_truth), \n", + " )\n", + " smape_metrics.append(smape[\"smape\"])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "a77386b1", + "metadata": {}, + "outputs": [], + "source": [ + "print(f\"MASE: {np.mean(mase_metrics)}\")\n", + "print(f\"sMAPE: {np.mean(smape_metrics)}\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "f73a6f14", + "metadata": {}, + "outputs": [], + "source": [ + "plt.scatter(mase_metrics, smape_metrics, alpha=0.3)\n", + "plt.xlabel(\"MASE\")\n", + "plt.ylabel(\"sMAPE\")\n", + "plt.show()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "34e34a88", + "metadata": {}, + "outputs": [], + "source": [ + "import matplotlib.dates as mdates\n", + "\n", + "def plot(ts_index):\n", + " fig, ax = plt.subplots()\n", + "\n", + " index = pd.period_range(\n", + " start=test_dataset[ts_index][FieldName.START],\n", + " periods=len(test_dataset[ts_index][FieldName.TARGET]),\n", + " freq=freq,\n", + " ).to_timestamp()\n", + "\n", + " # Major ticks every half year, minor ticks every month,\n", + " ax.xaxis.set_major_locator(mdates.MonthLocator(bymonth=(1, 7)))\n", + " ax.xaxis.set_minor_locator(mdates.MonthLocator())\n", + "\n", + " ax.plot(\n", + " index[-2*prediction_length:], \n", + " test_dataset[ts_index][\"target\"][-2*prediction_length:],\n", + " label=\"actual\",\n", + " )\n", + "\n", + " plt.plot(\n", + " index[-prediction_length:], \n", + " np.median(forecasts[ts_index], axis=0),\n", + " label=\"median\",\n", + " )\n", + " \n", + " plt.fill_between(\n", + " index[-prediction_length:],\n", + " forecasts[ts_index].mean(0) - forecasts[ts_index].std(axis=0), \n", + " forecasts[ts_index].mean(0) + forecasts[ts_index].std(axis=0), \n", + " alpha=0.3, \n", + " interpolate=True,\n", + " label=\"+/- 1-std\",\n", + " )\n", + " plt.legend()\n", + " plt.show()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "1fd88d87", + "metadata": {}, + "outputs": [], + "source": [ + "plt(0)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "4164385d", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "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.10.9" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +}