diff --git a/examples/quick_start/quick_start.ipynb b/examples/quick_start/quick_start.ipynb index 8c8862c..a679a21 100644 --- a/examples/quick_start/quick_start.ipynb +++ b/examples/quick_start/quick_start.ipynb @@ -467,14 +467,14 @@ "output_type": "stream", "text": [ "Model 01 fitted finished, Error: 0.51274, Status: Maximum iteration reached\n", - "Model 02 fitted finished, Error: 0.33991, Status: Success\n", + "Model 02 fitted finished, Error: 0.33703, Status: Success\n", "Model 03 fitted finished, Error: 1.16522, Status: Maximum iteration reached\n", "Model 04 fitted finished, Error: 0.95356, Status: Maximum iteration reached\n", "Model 05 fitted finished, Error: 0.73477, Status: Maximum iteration reached\n", "Model 06 fitted finished, Error: 0.50834, Status: Maximum iteration reached\n", - "Model 07 fitted finished, Error: 0.10069, Status: Success\n", - "Model 08 fitted finished, Error: 0.39123, Status: Success\n", - "Model 09 fitted finished, Error: 0.12484, Status: Success\n", + "Model 07 fitted finished, Error: 0.23935, Status: Success\n", + "Model 08 fitted finished, Error: 0.46087, Status: Success\n", + "Model 09 fitted finished, Error: 0.18395, Status: Success\n", "Model 10 fitted finished, Error: 0.48132, Status: Success\n", "Model 11 fitted finished, Error: 1.53225, Status: Maximum iteration reached\n", "Model 12 fitted finished, Error: 2.83350, Status: Maximum iteration reached\n" @@ -483,6 +483,7 @@ ], "source": [ "from pybl.models import BLRPRx\n", + "from concurrent.futures import ThreadPoolExecutor\n", "\n", "BLRPRx_models: list[BLRPRx] = []\n", "results: list[dict] = []\n", @@ -598,51 +599,51 @@ " Jan.\n", " 0.012927\n", " 0.026185\n", - " 0.792360\n", - " 0.794979\n", - " 0.182908\n", - " 0.999193\n", - " 0.220716\n", + " 0.792368\n", + " 0.794990\n", + " 0.182909\n", + " 3.104458\n", + " 0.220714\n", " \n", " \n", " Feb.\n", - " 0.012272\n", - " 0.033338\n", - " 1.007502\n", - " 0.982218\n", - " 0.236826\n", - " 0.999000\n", - " 0.203081\n", + " 0.012355\n", + " 0.033729\n", + " 1.052670\n", + " 0.964153\n", + " 0.229199\n", + " 5.444216\n", + " 0.195587\n", " \n", " \n", " Mar.\n", - " 0.015295\n", - " 0.027197\n", - " 0.572306\n", - " 0.951545\n", - " 0.154677\n", - " 0.999000\n", - " 0.219535\n", + " 0.015296\n", + " 0.027199\n", + " 0.572340\n", + " 0.951552\n", + " 0.154688\n", + " 0.001529\n", + " 0.219529\n", " \n", " \n", " Apr.\n", " 0.011561\n", - " 0.020201\n", - " 0.395653\n", - " 0.691439\n", - " 0.118162\n", - " 0.999090\n", - " 0.316850\n", + " 0.020202\n", + " 0.395660\n", + " 0.691446\n", + " 0.118166\n", + " 13.473519\n", + " 0.316854\n", " \n", " \n", " May\n", " 0.014674\n", - " 0.036972\n", - " 0.350534\n", - " 0.634806\n", - " 0.092831\n", - " 0.999000\n", - " 0.542195\n", + " 0.036979\n", + " 0.350569\n", + " 0.634863\n", + " 0.092844\n", + " 0.000104\n", + " 0.542205\n", " \n", " \n", " June\n", @@ -651,68 +652,68 @@ " 0.194127\n", " 0.444547\n", " 0.054380\n", - " 0.999082\n", - " 1.095893\n", + " 19.675369\n", + " 1.095892\n", " \n", " \n", " July\n", - " 0.016705\n", - " 0.029560\n", - " 0.117107\n", - " 0.655403\n", - " 0.089659\n", - " 0.999918\n", - " 1.297929\n", + " 0.017366\n", + " 0.029250\n", + " 0.092736\n", + " 0.685429\n", + " 0.106273\n", + " 0.568828\n", + " 1.559148\n", " \n", " \n", " Aug.\n", - " 0.011813\n", - " 0.024258\n", - " 0.092325\n", - " 0.430576\n", - " 0.089087\n", - " 0.999000\n", - " 1.771041\n", + " 0.012890\n", + " 0.047545\n", + " 0.196139\n", + " 0.394176\n", + " 0.074678\n", + " 0.000100\n", + " 1.508108\n", " \n", " \n", " Sep.\n", - " 0.013263\n", - " 0.028330\n", - " 0.153094\n", - " 0.515577\n", - " 0.098311\n", - " 0.999688\n", - " 1.134882\n", + " 0.012632\n", + " 0.019867\n", + " 0.102405\n", + " 0.537093\n", + " 0.107315\n", + " 0.551649\n", + " 1.239538\n", " \n", " \n", " Oct.\n", " 0.011180\n", " 0.022361\n", - " 0.504114\n", - " 1.068053\n", - " 0.182091\n", - " 0.999168\n", - " 0.307444\n", + " 0.504107\n", + " 1.068055\n", + " 0.182075\n", + " 0.000100\n", + " 0.307439\n", " \n", " \n", " Nov.\n", " 0.008956\n", " 0.024885\n", - " 1.048077\n", - " 0.832441\n", - " 0.201981\n", - " 0.999000\n", - " 0.238859\n", + " 1.048099\n", + " 0.832411\n", + " 0.201979\n", + " 3.761680\n", + " 0.238857\n", " \n", " \n", " Dec.\n", " 0.011656\n", - " 0.023142\n", - " 0.635806\n", - " 0.647140\n", - " 0.151236\n", - " 0.999023\n", - " 0.272883\n", + " 0.023141\n", + " 0.635773\n", + " 0.647146\n", + " 0.151242\n", + " 2.050925\n", + " 0.272889\n", " \n", " \n", "\n", @@ -721,18 +722,18 @@ "text/plain": [ " lambda phi kappa alpha nu sigmax_mux iota\n", "Month \n", - "Jan. 0.012927 0.026185 0.792360 0.794979 0.182908 0.999193 0.220716\n", - "Feb. 0.012272 0.033338 1.007502 0.982218 0.236826 0.999000 0.203081\n", - "Mar. 0.015295 0.027197 0.572306 0.951545 0.154677 0.999000 0.219535\n", - "Apr. 0.011561 0.020201 0.395653 0.691439 0.118162 0.999090 0.316850\n", - "May 0.014674 0.036972 0.350534 0.634806 0.092831 0.999000 0.542195\n", - "June 0.018159 0.042274 0.194127 0.444547 0.054380 0.999082 1.095893\n", - "July 0.016705 0.029560 0.117107 0.655403 0.089659 0.999918 1.297929\n", - "Aug. 0.011813 0.024258 0.092325 0.430576 0.089087 0.999000 1.771041\n", - "Sep. 0.013263 0.028330 0.153094 0.515577 0.098311 0.999688 1.134882\n", - "Oct. 0.011180 0.022361 0.504114 1.068053 0.182091 0.999168 0.307444\n", - "Nov. 0.008956 0.024885 1.048077 0.832441 0.201981 0.999000 0.238859\n", - "Dec. 0.011656 0.023142 0.635806 0.647140 0.151236 0.999023 0.272883" + "Jan. 0.012927 0.026185 0.792368 0.794990 0.182909 3.104458 0.220714\n", + "Feb. 0.012355 0.033729 1.052670 0.964153 0.229199 5.444216 0.195587\n", + "Mar. 0.015296 0.027199 0.572340 0.951552 0.154688 0.001529 0.219529\n", + "Apr. 0.011561 0.020202 0.395660 0.691446 0.118166 13.473519 0.316854\n", + "May 0.014674 0.036979 0.350569 0.634863 0.092844 0.000104 0.542205\n", + "June 0.018159 0.042274 0.194127 0.444547 0.054380 19.675369 1.095892\n", + "July 0.017366 0.029250 0.092736 0.685429 0.106273 0.568828 1.559148\n", + "Aug. 0.012890 0.047545 0.196139 0.394176 0.074678 0.000100 1.508108\n", + "Sep. 0.012632 0.019867 0.102405 0.537093 0.107315 0.551649 1.239538\n", + "Oct. 0.011180 0.022361 0.504107 1.068055 0.182075 0.000100 0.307439\n", + "Nov. 0.008956 0.024885 1.048099 0.832411 0.201979 3.761680 0.238857\n", + "Dec. 0.011656 0.023141 0.635773 0.647146 0.151242 2.050925 0.272889" ] }, "execution_count": 7, @@ -893,7 +894,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "Best fitted model: July, Error: 0.10069\n", + "Best fitted model: Sep., Error: 0.18395\n", "Worst fitted model: Dec., Error: 2.83350\n" ] } @@ -907,10 +908,7 @@ "worst_month_idx = np.argmax(error)\n", "\n", "print(f\"Best fitted model: {month_abbr[best_month_idx]}, Error: {error[best_month_idx]:2.5f}\")\n", - "print(f\"Worst fitted model: {month_abbr[worst_month_idx]}, Error: {error[worst_month_idx]:2.5f}\")\n", - "\n", - "best_month_stats = results[best_month_idx]['theo_stats']\n", - "worst_month_stats = results[worst_month_idx]['theo_stats']" + "print(f\"Worst fitted model: {month_abbr[worst_month_idx]}, Error: {error[worst_month_idx]:2.5f}\")" ] }, { @@ -1063,31 +1061,31 @@ " \n", " \n", " 0.083333\n", - " 0.008965\n", - " 11.379874\n", - " 0.579428\n", - " 37.326717\n", + " 0.008030\n", + " 10.020834\n", + " 0.630432\n", + " 37.517408\n", " \n", " \n", " 1.000000\n", - " 0.107581\n", - " 6.313281\n", - " 0.286653\n", - " 15.252169\n", + " 0.096362\n", + " 5.852267\n", + " 0.310199\n", + " 15.832104\n", " \n", " \n", " 6.000000\n", - " 0.645488\n", - " 3.486269\n", - " 0.201028\n", - " 6.927106\n", + " 0.578170\n", + " 3.330652\n", + " 0.254475\n", + " 7.240695\n", " \n", " \n", " 24.000000\n", - " 2.581953\n", - " 2.054543\n", - " 0.115126\n", - " 3.685982\n", + " 2.312680\n", + " 2.058065\n", + " 0.172872\n", + " 3.970615\n", " \n", " \n", "\n", @@ -1096,17 +1094,17 @@ "text/plain": [ " StatMetrics.MEAN StatMetrics.CVAR StatMetrics.AR1 \\\n", "timescale_hr \n", - "0.083333 0.008965 11.379874 0.579428 \n", - "1.000000 0.107581 6.313281 0.286653 \n", - "6.000000 0.645488 3.486269 0.201028 \n", - "24.000000 2.581953 2.054543 0.115126 \n", + "0.083333 0.008030 10.020834 0.630432 \n", + "1.000000 0.096362 5.852267 0.310199 \n", + "6.000000 0.578170 3.330652 0.254475 \n", + "24.000000 2.312680 2.058065 0.172872 \n", "\n", " StatMetrics.SKEWNESS \n", "timescale_hr \n", - "0.083333 37.326717 \n", - "1.000000 15.252169 \n", - "6.000000 6.927106 \n", - "24.000000 3.685982 " + "0.083333 37.517408 \n", + "1.000000 15.832104 \n", + "6.000000 7.240695 \n", + "24.000000 3.970615 " ] }, "metadata": {}, @@ -1156,31 +1154,31 @@ " \n", " \n", " 0.083333\n", - " 0.008922\n", - " 11.180480\n", - " 0.592266\n", - " 33.816884\n", + " 0.008105\n", + " 8.094277\n", + " 0.656134\n", + " 25.625165\n", " \n", " \n", " 1.000000\n", - " 0.107065\n", - " 6.273239\n", - " 0.284599\n", - " 14.514512\n", + " 0.097256\n", + " 4.946199\n", + " 0.360873\n", + " 12.371813\n", " \n", " \n", " 6.000000\n", - " 0.642383\n", - " 3.470400\n", - " 0.208534\n", - " 6.676110\n", + " 0.583535\n", + " 2.959160\n", + " 0.299261\n", + " 6.058172\n", " \n", " \n", " 24.000000\n", - " 2.569486\n", - " 2.059352\n", - " 0.122148\n", - " 3.535409\n", + " 2.334125\n", + " 1.887514\n", + " 0.198371\n", + " 3.523645\n", " \n", " \n", "\n", @@ -1189,17 +1187,17 @@ "text/plain": [ " StatMetrics.MEAN StatMetrics.CVAR StatMetrics.AR1 \\\n", "timescale_hr \n", - "0.083333 0.008922 11.180480 0.592266 \n", - "1.000000 0.107065 6.273239 0.284599 \n", - "6.000000 0.642383 3.470400 0.208534 \n", - "24.000000 2.569486 2.059352 0.122148 \n", + "0.083333 0.008105 8.094277 0.656134 \n", + "1.000000 0.097256 4.946199 0.360873 \n", + "6.000000 0.583535 2.959160 0.299261 \n", + "24.000000 2.334125 1.887514 0.198371 \n", "\n", " StatMetrics.SKEWNESS \n", "timescale_hr \n", - "0.083333 33.816884 \n", - "1.000000 14.514512 \n", - "6.000000 6.676110 \n", - "24.000000 3.535409 " + "0.083333 25.625165 \n", + "1.000000 12.371813 \n", + "6.000000 6.058172 \n", + "24.000000 3.523645 " ] }, "metadata": {}, @@ -1303,7 +1301,7 @@ "print(\"Input Time Series Statistics\")\n", "display(stats[best_month_idx])\n", "print(\"Theoretical Time Series Statistics\")\n", - "display(best_month_stats)\n", + "display(results[best_month_idx]['theo_stats'])\n", "print(\"Sampled Time Series Statistics\")\n", "display(sampled_stats[best_month_idx])\n", "print(\"weights\")\n", @@ -1464,30 +1462,30 @@ " \n", " \n", " 0.083333\n", - " 0.007548\n", - " 5.293510\n", - " 0.751871\n", - " 17.680768\n", + " 0.007547\n", + " 5.293496\n", + " 0.751872\n", + " 17.680733\n", " \n", " \n", " 1.000000\n", - " 0.090571\n", - " 3.764516\n", - " 0.558657\n", - " 9.119594\n", + " 0.090569\n", + " 3.764498\n", + " 0.558651\n", + " 9.119569\n", " \n", " \n", " 6.000000\n", - " 0.543424\n", - " 2.682901\n", - " 0.443893\n", - " 5.597094\n", + " 0.543415\n", + " 2.682883\n", + " 0.443899\n", + " 5.597051\n", " \n", " \n", " 24.000000\n", - " 2.173695\n", - " 1.872379\n", - " 0.256153\n", + " 2.173661\n", + " 1.872376\n", + " 0.256160\n", " 3.514807\n", " \n", " \n", @@ -1497,16 +1495,16 @@ "text/plain": [ " StatMetrics.MEAN StatMetrics.CVAR StatMetrics.AR1 \\\n", "timescale_hr \n", - "0.083333 0.007548 5.293510 0.751871 \n", - "1.000000 0.090571 3.764516 0.558657 \n", - "6.000000 0.543424 2.682901 0.443893 \n", - "24.000000 2.173695 1.872379 0.256153 \n", + "0.083333 0.007547 5.293496 0.751872 \n", + "1.000000 0.090569 3.764498 0.558651 \n", + "6.000000 0.543415 2.682883 0.443899 \n", + "24.000000 2.173661 1.872376 0.256160 \n", "\n", " StatMetrics.SKEWNESS \n", "timescale_hr \n", - "0.083333 17.680768 \n", - "1.000000 9.119594 \n", - "6.000000 5.597094 \n", + "0.083333 17.680733 \n", + "1.000000 9.119569 \n", + "6.000000 5.597051 \n", "24.000000 3.514807 " ] }, @@ -1557,31 +1555,31 @@ " \n", " \n", " 0.083333\n", - " 0.007408\n", - " 5.428896\n", - " 0.745989\n", - " 18.278024\n", + " 0.007621\n", + " 7.581642\n", + " 0.698570\n", + " 28.780840\n", " \n", " \n", " 1.000000\n", - " 0.088898\n", - " 3.844772\n", - " 0.552141\n", - " 9.335921\n", + " 0.091458\n", + " 4.889165\n", + " 0.415629\n", + " 13.030705\n", " \n", " \n", " 6.000000\n", - " 0.533386\n", - " 2.724376\n", - " 0.443659\n", - " 5.650940\n", + " 0.548744\n", + " 3.088918\n", + " 0.350101\n", + " 6.575003\n", " \n", " \n", " 24.000000\n", - " 2.133507\n", - " 1.891517\n", - " 0.250076\n", - " 3.587621\n", + " 2.194963\n", + " 2.036548\n", + " 0.218213\n", + " 3.764381\n", " \n", " \n", "\n", @@ -1590,17 +1588,17 @@ "text/plain": [ " StatMetrics.MEAN StatMetrics.CVAR StatMetrics.AR1 \\\n", "timescale_hr \n", - "0.083333 0.007408 5.428896 0.745989 \n", - "1.000000 0.088898 3.844772 0.552141 \n", - "6.000000 0.533386 2.724376 0.443659 \n", - "24.000000 2.133507 1.891517 0.250076 \n", + "0.083333 0.007621 7.581642 0.698570 \n", + "1.000000 0.091458 4.889165 0.415629 \n", + "6.000000 0.548744 3.088918 0.350101 \n", + "24.000000 2.194963 2.036548 0.218213 \n", "\n", " StatMetrics.SKEWNESS \n", "timescale_hr \n", - "0.083333 18.278024 \n", - "1.000000 9.335921 \n", - "6.000000 5.650940 \n", - "24.000000 3.587621 " + "0.083333 28.780840 \n", + "1.000000 13.030705 \n", + "6.000000 6.575003 \n", + "24.000000 3.764381 " ] }, "metadata": {}, @@ -1704,7 +1702,7 @@ "print(\"Input Time Series Statistics\")\n", "display(stats[11])\n", "print(\"Theoretical Time Series Statistics\")\n", - "display(worst_month_stats)\n", + "display(results[worst_month_idx]['theo_stats'])\n", "print(\"Sampled Time Series Statistics\")\n", "display(sampled_stats[11])\n", "print(\"weights\")\n",