diff --git a/.test b/.test index 3b878f6..67f34bb 100644 --- a/.test +++ b/.test @@ -1,5 +1,5 @@ -01-ingest-datasources.ipynb -02-create-training-model.ipynb -03-deploy-serving-model.ipynb -04-pipeline.ipynb +01-exploratory-data-analysis.ipynb +02-interactive-data-preparation.ipynb +03-ingest-with-feature-store.ipynb +04-train-test-pipeline.ipynb 05-real-time-serving-pipeline.ipynb \ No newline at end of file diff --git a/1-exploratory-data-analysis.ipynb b/01-exploratory-data-analysis.ipynb similarity index 82% rename from 1-exploratory-data-analysis.ipynb rename to 01-exploratory-data-analysis.ipynb index 1ee7a31..48e9c98 100644 --- a/1-exploratory-data-analysis.ipynb +++ b/01-exploratory-data-analysis.ipynb @@ -35,7 +35,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Before you run any data processing or modeling, you must start by getting to know the data you work with. The `1-exploratory-data-analysis.ipynb` notebook provides basic explanatory data analysis (EDA) on the fraud example datasets." + "Before you run any data processing or modeling, you must start by getting to know the data you work with. This notebook provides basic explanatory data analysis (EDA) on the fraud example datasets." ] }, { @@ -47,7 +47,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 1, "metadata": {}, "outputs": [], "source": [ @@ -63,17 +63,9 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 2, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "> 2024-01-31 21:13:25,400 [info] Server and client versions are not the same but compatible: {'parsed_server_version': VersionInfo(major=1, minor=5, patch=2, prerelease='rc1', build='track'), 'parsed_client_version': VersionInfo(major=1, minor=3, patch=0, prerelease=None, build=None)}\n" - ] - } - ], + "outputs": [], "source": [ "import pandas as pd\n", "import mlrun\n", @@ -94,7 +86,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 3, "metadata": {}, "outputs": [ { @@ -199,7 +191,7 @@ "2 7a851d0758894078b5846851ae32d5e3 " ] }, - "execution_count": 5, + "execution_count": 3, "metadata": {}, "output_type": "execute_result" } @@ -211,7 +203,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 4, "metadata": {}, "outputs": [ { @@ -232,7 +224,7 @@ "dtype: object" ] }, - "execution_count": 6, + "execution_count": 4, "metadata": {}, "output_type": "execute_result" } @@ -244,12 +236,13 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/plain": [ + "age\n", "2 149840\n", "3 117110\n", "4 86871\n", @@ -258,10 +251,10 @@ "6 21377\n", "0 1886\n", "U 928\n", - "Name: age, dtype: int64" + "Name: count, dtype: int64" ] }, - "execution_count": 7, + "execution_count": 5, "metadata": {}, "output_type": "execute_result" } @@ -273,7 +266,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 6, "metadata": {}, "outputs": [ { @@ -303,6 +296,7 @@ " zipMerchant\n", " amount\n", " fraud\n", + " timestamp\n", " \n", " \n", " \n", @@ -314,6 +308,7 @@ " 473745.0\n", " 473745.000000\n", " 473745.000000\n", + " 473745\n", " \n", " \n", " mean\n", @@ -323,15 +318,7 @@ " 28007.0\n", " 38.105695\n", " 0.012446\n", - " \n", - " \n", - " std\n", - " 41.991176\n", - " 1.325787\n", - " 0.0\n", - " 0.0\n", - " 113.887429\n", - " 0.110863\n", + " 2020-06-10 21:37:42.210974208\n", " \n", " \n", " min\n", @@ -341,6 +328,7 @@ " 28007.0\n", " 0.000000\n", " 0.000000\n", + " 2019-12-11 11:44:09.900633\n", " \n", " \n", " 25%\n", @@ -350,6 +338,7 @@ " 28007.0\n", " 13.740000\n", " 0.000000\n", + " 2020-03-11 13:09:03.778129920\n", " \n", " \n", " 50%\n", @@ -359,6 +348,7 @@ " 28007.0\n", " 26.890000\n", " 0.000000\n", + " 2020-06-10 22:26:45.202980096\n", " \n", " \n", " 75%\n", @@ -368,6 +358,7 @@ " 28007.0\n", " 42.530000\n", " 0.000000\n", + " 2020-09-10 03:53:20.925788928\n", " \n", " \n", " max\n", @@ -377,6 +368,17 @@ " 28007.0\n", " 7665.560000\n", " 1.000000\n", + " 2020-12-10 11:41:01.642802\n", + " \n", + " \n", + " std\n", + " 41.991176\n", + " 1.325787\n", + " 0.0\n", + " 0.0\n", + " 113.887429\n", + " 0.110863\n", + " NaN\n", " \n", " \n", "\n", @@ -386,25 +388,25 @@ " step age zipcodeOri zipMerchant amount \\\n", "count 473745.000000 473745.000000 473745.0 473745.0 473745.000000 \n", "mean 77.698114 3.005889 28007.0 28007.0 38.105695 \n", - "std 41.991176 1.325787 0.0 0.0 113.887429 \n", "min 0.000000 0.000000 28007.0 28007.0 0.000000 \n", "25% 42.000000 2.000000 28007.0 28007.0 13.740000 \n", "50% 80.000000 3.000000 28007.0 28007.0 26.890000 \n", "75% 114.000000 4.000000 28007.0 28007.0 42.530000 \n", "max 147.000000 6.000000 28007.0 28007.0 7665.560000 \n", + "std 41.991176 1.325787 0.0 0.0 113.887429 \n", "\n", - " fraud \n", - "count 473745.000000 \n", - "mean 0.012446 \n", - "std 0.110863 \n", - "min 0.000000 \n", - "25% 0.000000 \n", - "50% 0.000000 \n", - "75% 0.000000 \n", - "max 1.000000 " + " fraud timestamp \n", + "count 473745.000000 473745 \n", + "mean 0.012446 2020-06-10 21:37:42.210974208 \n", + "min 0.000000 2019-12-11 11:44:09.900633 \n", + "25% 0.000000 2020-03-11 13:09:03.778129920 \n", + "50% 0.000000 2020-06-10 22:26:45.202980096 \n", + "75% 0.000000 2020-09-10 03:53:20.925788928 \n", + "max 1.000000 2020-12-10 11:41:01.642802 \n", + "std 0.110863 NaN " ] }, - "execution_count": 8, + "execution_count": 6, "metadata": {}, "output_type": "execute_result" } @@ -420,18 +422,19 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/plain": [ + "fraud\n", "0 467849\n", "1 5896\n", - "Name: fraud, dtype: int64" + "Name: count, dtype: int64" ] }, - "execution_count": 9, + "execution_count": 7, "metadata": {}, "output_type": "execute_result" } @@ -457,19 +460,20 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 8, "metadata": {}, "outputs": [ { "data": { "text/plain": [ + "gender\n", "F 258905\n", "M 214414\n", "U 426\n", - "Name: gender, dtype: int64" + "Name: count, dtype: int64" ] }, - "execution_count": 10, + "execution_count": 8, "metadata": {}, "output_type": "execute_result" } @@ -481,7 +485,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 9, "metadata": {}, "outputs": [ { @@ -529,7 +533,7 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 10, "metadata": {}, "outputs": [ { @@ -578,7 +582,7 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 11, "metadata": {}, "outputs": [], "source": [ @@ -595,7 +599,7 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 12, "metadata": {}, "outputs": [ { @@ -604,7 +608,7 @@ "Text(0.5, 1.0, 'Count of fraud/not fraud grouped by hour')" ] }, - "execution_count": 14, + "execution_count": 12, "metadata": {}, "output_type": "execute_result" }, @@ -634,7 +638,7 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 13, "metadata": {}, "outputs": [ { @@ -643,7 +647,7 @@ "Text(0.5, 1.0, 'Count of fraud/not fraud for each day of the week')" ] }, - "execution_count": 15, + "execution_count": 13, "metadata": {}, "output_type": "execute_result" }, @@ -681,7 +685,7 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": 14, "metadata": {}, "outputs": [ { @@ -754,7 +758,7 @@ "4 C394979408 password_change 2020-10-14 23:27:41.291391" ] }, - "execution_count": 16, + "execution_count": 14, "metadata": {}, "output_type": "execute_result" } @@ -766,7 +770,7 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 15, "metadata": {}, "outputs": [ { @@ -823,7 +827,7 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": 16, "metadata": {}, "outputs": [], "source": [ @@ -834,7 +838,7 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": 17, "metadata": {}, "outputs": [ { @@ -877,93 +881,93 @@ " \n", " \n", " \n", - " 109219\n", - " 85\n", + " 139682\n", " 4\n", - " F\n", + " 3\n", + " M\n", " 28007\n", " 28007\n", " es_transportation\n", - " 54.66\n", + " 28.37\n", " 0\n", - " 2020-03-04 07:54:50.018455\n", - " 7\n", - " 4\n", + " 2020-03-27 21:50:16.562414\n", + " 21\n", + " 27\n", " 3\n", - " 2\n", + " 4\n", " 2020\n", " password_change\n", " \n", " \n", - " 240740\n", - " 28\n", - " 2\n", - " M\n", + " 98732\n", + " 21\n", + " 4\n", + " F\n", " 28007\n", " 28007\n", " es_transportation\n", - " 31.95\n", + " 11.76\n", " 0\n", - " 2020-06-13 21:14:47.709132\n", - " 21\n", - " 13\n", - " 6\n", - " 5\n", + " 2020-02-25 08:41:14.066739\n", + " 8\n", + " 25\n", + " 2\n", + " 1\n", " 2020\n", - " details_change\n", + " login\n", " \n", " \n", - " 135044\n", - " 4\n", - " 5\n", + " 459608\n", + " 123\n", + " 1\n", " F\n", " 28007\n", " 28007\n", " es_transportation\n", - " 31.56\n", + " 3.29\n", " 0\n", - " 2020-03-24 07:52:24.099779\n", - " 7\n", - " 24\n", - " 3\n", - " 1\n", + " 2020-11-29 12:51:28.706077\n", + " 12\n", + " 29\n", + " 11\n", + " 6\n", " 2020\n", " password_change\n", " \n", " \n", - " 245066\n", - " 129\n", - " 3\n", + " 428918\n", + " 80\n", + " 5\n", " M\n", " 28007\n", " 28007\n", - " es_food\n", - " 18.83\n", + " es_transportation\n", + " 36.56\n", " 0\n", - " 2020-06-17 02:14:57.581432\n", + " 2020-11-06 02:37:35.009392\n", " 2\n", - " 17\n", " 6\n", - " 2\n", + " 11\n", + " 4\n", " 2020\n", " login\n", " \n", " \n", - " 30109\n", - " 37\n", + " 25093\n", + " 84\n", " 2\n", " M\n", " 28007\n", " 28007\n", " es_transportation\n", - " 17.95\n", + " 42.60\n", " 0\n", - " 2020-01-03 15:36:39.372582\n", - " 15\n", - " 3\n", - " 1\n", - " 4\n", - " 2020\n", + " 2019-12-30 19:18:41.061667\n", + " 19\n", + " 30\n", + " 12\n", + " 0\n", + " 2019\n", " NaN\n", " \n", " \n", @@ -972,28 +976,28 @@ ], "text/plain": [ " step age gender zipcodeOri zipMerchant category amount \\\n", - "109219 85 4 F 28007 28007 es_transportation 54.66 \n", - "240740 28 2 M 28007 28007 es_transportation 31.95 \n", - "135044 4 5 F 28007 28007 es_transportation 31.56 \n", - "245066 129 3 M 28007 28007 es_food 18.83 \n", - "30109 37 2 M 28007 28007 es_transportation 17.95 \n", + "139682 4 3 M 28007 28007 es_transportation 28.37 \n", + "98732 21 4 F 28007 28007 es_transportation 11.76 \n", + "459608 123 1 F 28007 28007 es_transportation 3.29 \n", + "428918 80 5 M 28007 28007 es_transportation 36.56 \n", + "25093 84 2 M 28007 28007 es_transportation 42.60 \n", "\n", " fraud timestamp hour day month weekday year \\\n", - "109219 0 2020-03-04 07:54:50.018455 7 4 3 2 2020 \n", - "240740 0 2020-06-13 21:14:47.709132 21 13 6 5 2020 \n", - "135044 0 2020-03-24 07:52:24.099779 7 24 3 1 2020 \n", - "245066 0 2020-06-17 02:14:57.581432 2 17 6 2 2020 \n", - "30109 0 2020-01-03 15:36:39.372582 15 3 1 4 2020 \n", + "139682 0 2020-03-27 21:50:16.562414 21 27 3 4 2020 \n", + "98732 0 2020-02-25 08:41:14.066739 8 25 2 1 2020 \n", + "459608 0 2020-11-29 12:51:28.706077 12 29 11 6 2020 \n", + "428918 0 2020-11-06 02:37:35.009392 2 6 11 4 2020 \n", + "25093 0 2019-12-30 19:18:41.061667 19 30 12 0 2019 \n", "\n", " event \n", - "109219 password_change \n", - "240740 details_change \n", - "135044 password_change \n", - "245066 login \n", - "30109 NaN " + "139682 password_change \n", + "98732 login \n", + "459608 password_change \n", + "428918 login \n", + "25093 NaN " ] }, - "execution_count": 19, + "execution_count": 17, "metadata": {}, "output_type": "execute_result" } @@ -1020,7 +1024,7 @@ }, { "cell_type": "code", - "execution_count": 20, + "execution_count": 18, "metadata": {}, "outputs": [], "source": [ @@ -1046,7 +1050,7 @@ }, { "cell_type": "code", - "execution_count": 21, + "execution_count": 19, "metadata": {}, "outputs": [ { @@ -1063,8 +1067,7 @@ } ], "source": [ - "# \n", - "corr = all_data.corr()\n", + "corr = all_data.corr(numeric_only=True)\n", "plt.figure(figsize=(12, 10))\n", "\n", "sns.heatmap(corr[(corr >= 0.1) | (corr <= -0.1)], \n", @@ -1076,7 +1079,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "## Data Analyis with MLRUN\n", + "## Data Analysis with MLRun\n", "\n", "The code in the notebook represents just a sample of the kind of analysis one can do with the data. There are a variety of tools with great visualization capabilities that can offload or automate the EDA process. You can also harness the power of MLOps solutions to create or use pre-baked functions and services that analyze your data.\n", "The example notebook demonstrates using pre-baked functions from the MLRun public functions hub to perform EDA and modeling. Some examples:\n", @@ -1090,13 +1093,22 @@ }, { "cell_type": "code", - "execution_count": 22, + "execution_count": 20, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "> 2024-06-13 12:38:25,203 [info] Loading project from path: {\"path\":\"./\",\"project_name\":\"fraud-demo\"}\n", + "> 2024-06-13 12:38:41,220 [info] Project loaded successfully: {\"path\":\"./\",\"project_name\":\"fraud-demo\",\"stored_in_db\":true}\n" + ] + } + ], "source": [ "import mlrun\n", "\n", - "project = mlrun.load_project(\n", + "project = mlrun.get_or_create_project(\n", " name=\"fraud-demo\",\n", " context=\"./\",\n", " user_project=True,\n", @@ -1105,15 +1117,25 @@ }, { "cell_type": "code", - "execution_count": 23, + "execution_count": 21, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "> 2024-01-31 21:13:43,774 [info] Storing function: {'name': 'describe-analyze', 'uid': '21a13806928d4eb38dff918c0ac5e603', 'db': 'http://mlrun-api:8080'}\n", - "> 2024-01-31 21:13:50,731 [info] The data set is logged to the project under dataset name\n" + "> 2024-06-13 12:39:01,361 [info] Storing function: {\"db\":\"http://mlrun-api:8080\",\"name\":\"describe-analyze\",\"uid\":\"ce482a518b4d4d4c88edda39a7853cc0\"}\n", + "> 2024-06-13 12:39:11,383 [info] The data set is logged to the project under dataset name\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/User/.pythonlibs/mlrun-base/lib/python3.9/site-packages/mlrun/artifacts/dataset.py:387: RuntimeWarning:\n", + "\n", + "Converting input from bool to for compatibility.\n", + "\n" ] }, { @@ -1276,6 +1298,7 @@ " iter\n", " start\n", " state\n", + " kind\n", " name\n", " labels\n", " inputs\n", @@ -1286,27 +1309,28 @@ " \n", " \n", " \n", - " fraud-demo-pengw\n", - "
...0ac5e603
\n", + " fraud-demo-yonis\n", + "
...a7853cc0
\n", " 0\n", - " Jan 31 21:13:43\n", + " Jun 13 12:39:01\n", " completed\n", + " run\n", " describe-analyze\n", - "
v3io_user=pengw
kind=
owner=pengw
host=jupyter-pengw-56bc6f675d-pp868
\n", - "
table
\n", + "
v3io_user=yonis
kind=local
owner=yonis
host=jupyter-yoni-5d574b9596-jx5rt
\n", + "
table
\n", "
label_column=fraud
\n", " \n", - "
describe-csv
hist
histograms
scatter-2d
violin
imbalance
imbalance-weights-vec
correlation-matrix-csv
correlation
dataset
\n", + "
describe-csv
hist
histograms
scatter-2d
violin
imbalance
imbalance-weights-vec
correlation-matrix-csv
correlation
dataset
\n", " \n", " \n", "\n", "\n", - "
\n", + "
\n", "
\n", - " Title\n", - " ×\n", + " Title\n", + " ×\n", "
\n", - " \n", + " \n", "
\n", "
\n" ], @@ -1327,7 +1351,7 @@ { "data": { "text/html": [ - " > to track results use the .show() or .logs() methods or click here to open in UI" + " > to track results use the .show() or .logs() methods or click here to open in UI" ], "text/plain": [ "" @@ -1340,16 +1364,13 @@ "name": "stdout", "output_type": "stream", "text": [ - "> 2024-01-31 21:13:51,171 [info] run executed, status=completed: {'name': 'describe-analyze'}\n" + "> 2024-06-13 12:39:11,652 [info] Run execution finished: {\"name\":\"describe-analyze\",\"status\":\"completed\"}\n" ] } ], "source": [ "all_data.to_csv('./data_set_describe.csv', index=False)\n", "\n", - "\n", - "import mlrun\n", - "\n", "# import the function\n", "describe = mlrun.import_function('hub://describe')\n", "# need to change run to descirbe_run in the book\n", @@ -1359,7 +1380,7 @@ }, { "cell_type": "code", - "execution_count": 24, + "execution_count": 22, "metadata": {}, "outputs": [ { @@ -1368,7 +1389,7 @@ "dict_keys(['describe-csv', 'hist', 'histograms', 'scatter-2d', 'violin', 'imbalance', 'imbalance-weights-vec', 'correlation-matrix-csv', 'correlation', 'dataset'])" ] }, - "execution_count": 24, + "execution_count": 22, "metadata": {}, "output_type": "execute_result" } @@ -1380,7 +1401,7 @@ }, { "cell_type": "code", - "execution_count": 25, + "execution_count": 23, "metadata": {}, "outputs": [ { @@ -1454,7 +1475,7 @@ " * Copyright (c) 2014-2015, Jon Schlinkert.\n", " * Licensed under the MIT License.\n", " */\n", - "\"use strict\";var n,i=\"\";e.exports=function(t,e){if(\"string\"!=typeof t)throw new TypeError(\"expected a string\");if(1===e)return t;if(2===e)return t+t;var r=t.length*e;if(n!==t||void 0===n)n=t,i=\"\";else if(i.length>=r)return i.substr(0,r);for(;r>i.length&&e>1;)1&e&&(i+=t),e>>=1,t+=t;return i=(i+=t).substr(0,r)}},{}],278:[function(t,e,r){(function(t){(function(){e.exports=t.performance&&t.performance.now?function(){return performance.now()}:Date.now||function(){return+new Date}}).call(this)}).call(this,void 0!==n?n:\"undefined\"!=typeof self?self:\"undefined\"!=typeof window?window:{})},{}],279:[function(t,e,r){\"use strict\";e.exports=function(t){for(var e=t.length,r=t[t.length-1],n=e,i=e-2;i>=0;--i){var a=r,o=t[i];(l=o-((r=a+o)-a))&&(t[--n]=r,r=l)}var s=0;for(i=n;i0){if(a<=0)return o;n=i+a}else{if(!(i<0))return o;if(a>=0)return o;n=-(i+a)}var s=33306690738754716e-32*n;return o>=s||o<=-s?o:f(t,e,r)},function(t,e,r,n){var i=t[0]-n[0],a=e[0]-n[0],o=r[0]-n[0],s=t[1]-n[1],l=e[1]-n[1],c=r[1]-n[1],u=t[2]-n[2],f=e[2]-n[2],p=r[2]-n[2],d=a*c,m=o*l,g=o*s,v=i*c,y=i*l,x=a*s,b=u*(d-m)+f*(g-v)+p*(y-x),_=7771561172376103e-31*((Math.abs(d)+Math.abs(m))*Math.abs(u)+(Math.abs(g)+Math.abs(v))*Math.abs(f)+(Math.abs(y)+Math.abs(x))*Math.abs(p));return b>_||-b>_?b:h(t,e,r,n)}];function d(t){var e=p[t.length];return e||(e=p[t.length]=u(t.length)),e.apply(void 0,t)}function m(t,e,r,n,i,a,o){return function(e,r,s,l,c){switch(arguments.length){case 0:case 1:return 0;case 2:return n(e,r);case 3:return i(e,r,s);case 4:return a(e,r,s,l);case 5:return o(e,r,s,l,c)}for(var u=new Array(arguments.length),f=0;f0&&o>0||a<0&&o<0)return!1;var s=n(r,t,e),l=n(i,t,e);if(s>0&&l>0||s<0&&l<0)return!1;if(0===a&&0===o&&0===s&&0===l)return function(t,e,r,n){for(var i=0;i<2;++i){var a=t[i],o=e[i],s=Math.min(a,o),l=Math.max(a,o),c=r[i],u=n[i],f=Math.min(c,u);if(Math.max(c,u)=n?(i=f,(l+=1)=n?(i=f,(l+=1)>1,c=e[2*l+1];if(c===a)return l;a>1,c=e[2*l+1];if(c===a)return l;a>1,c=e[2*l+1];if(c===a)return l;a>1,s=a(t[o],e);s<=0?(0===s&&(i=o),r=o+1):s>0&&(n=o-1)}return i}function u(t,e){for(var r=new Array(t.length),i=0,o=r.length;i=t.length||0!==a(t[g],s)););}return r}function f(t,e){if(e<0)return[];for(var r=[],i=(1<>>u&1&&c.push(i[u]);e.push(c)}return s(e)},r.skeleton=f,r.boundary=function(t){for(var e=[],r=0,n=t.length;r>1:(t>>1)-1}function x(t){for(var e=v(t);;){var r=e,n=2*t+1,i=2*(t+1),a=t;if(n0;){var r=y(t);if(r>=0)if(e0){var t=k[0];return g(0,M-1),M-=1,x(0),t}return-1}function w(t,e){var r=k[t];return c[r]===e?t:(c[r]=-1/0,b(t),_(),c[r]=e,b((M+=1)-1))}function T(t){if(!u[t]){u[t]=!0;var e=s[t],r=l[t];s[r]>=0&&(s[r]=e),l[e]>=0&&(l[e]=r),A[e]>=0&&w(A[e],m(e)),A[r]>=0&&w(A[r],m(r))}}var k=[],A=new Array(a);for(f=0;f>1;f>=0;--f)x(f);for(;;){var S=_();if(S<0||c[S]>r)break;T(S)}var E=[];for(f=0;f=0&&r>=0&&e!==r){var n=A[e],i=A[r];n!==i&&C.push([n,i])}})),i.unique(i.normalize(C)),{positions:E,edges:C}};var n=t(\"robust-orientation\"),i=t(\"simplicial-complex\")},{\"robust-orientation\":284,\"simplicial-complex\":295}],298:[function(t,e,r){\"use strict\";e.exports=function(t,e){var r,a,o,s;if(e[0][0]e[1][0]))return i(e,t);r=e[1],a=e[0]}if(t[0][0]t[1][0]))return-i(t,e);o=t[1],s=t[0]}var l=n(r,a,s),c=n(r,a,o);if(l<0){if(c<=0)return l}else if(l>0){if(c>=0)return l}else if(c)return c;if(l=n(s,o,a),c=n(s,o,r),l<0){if(c<=0)return l}else if(l>0){if(c>=0)return l}else if(c)return c;return a[0]-s[0]};var n=t(\"robust-orientation\");function i(t,e){var r,i,a,o;if(e[0][0]e[1][0])){var s=Math.min(t[0][1],t[1][1]),l=Math.max(t[0][1],t[1][1]),c=Math.min(e[0][1],e[1][1]),u=Math.max(e[0][1],e[1][1]);return lu?s-u:l-u}r=e[1],i=e[0]}t[0][1]0)if(e[0]!==o[1][0])r=t,t=t.right;else{if(l=c(t.right,e))return l;t=t.left}else{if(e[0]!==o[1][0])return t;var l;if(l=c(t.right,e))return l;t=t.left}}return r}function u(t,e,r,n){this.y=t,this.index=e,this.start=r,this.closed=n}function f(t,e,r,n){this.x=t,this.segment=e,this.create=r,this.index=n}s.prototype.castUp=function(t){var e=n.le(this.coordinates,t[0]);if(e<0)return-1;this.slabs[e];var r=c(this.slabs[e],t),i=-1;if(r&&(i=r.value),this.coordinates[e]===t[0]){var s=null;if(r&&(s=r.key),e>0){var u=c(this.slabs[e-1],t);u&&(s?o(u.key,s)>0&&(s=u.key,i=u.value):(i=u.value,s=u.key))}var f=this.horizontal[e];if(f.length>0){var h=n.ge(f,t[1],l);if(h=f.length)return i;p=f[h]}}if(p.start)if(s){var d=a(s[0],s[1],[t[0],p.y]);s[0][0]>s[1][0]&&(d=-d),d>0&&(i=p.index)}else i=p.index;else p.y!==t[1]&&(i=p.index)}}}return i}},{\"./lib/order-segments\":298,\"binary-search-bounds\":31,\"functional-red-black-tree\":69,\"robust-orientation\":284}],300:[function(t,e,r){\"use strict\";var n=t(\"robust-dot-product\"),i=t(\"robust-sum\");function a(t,e){var r=i(n(t,e),[e[e.length-1]]);return r[r.length-1]}function o(t,e,r,n){var i=-e/(n-e);i<0?i=0:i>1&&(i=1);for(var a=1-i,o=t.length,s=new Array(o),l=0;l0||i>0&&u<0){var f=o(s,u,l,i);r.push(f),n.push(f.slice())}u<0?n.push(l.slice()):u>0?r.push(l.slice()):(r.push(l.slice()),n.push(l.slice())),i=u}return{positive:r,negative:n}},e.exports.positive=function(t,e){for(var r=[],n=a(t[t.length-1],e),i=t[t.length-1],s=t[0],l=0;l0||n>0&&c<0)&&r.push(o(i,c,s,n)),c>=0&&r.push(s.slice()),n=c}return r},e.exports.negative=function(t,e){for(var r=[],n=a(t[t.length-1],e),i=t[t.length-1],s=t[0],l=0;l0||n>0&&c<0)&&r.push(o(i,c,s,n)),c<=0&&r.push(s.slice()),n=c}return r}},{\"robust-dot-product\":281,\"robust-sum\":289}],301:[function(t,e,r){!function(){\"use strict\";var t={not_string:/[^s]/,not_bool:/[^t]/,not_type:/[^T]/,not_primitive:/[^v]/,number:/[diefg]/,numeric_arg:/[bcdiefguxX]/,json:/[j]/,not_json:/[^j]/,text:/^[^\\x25]+/,modulo:/^\\x25{2}/,placeholder:/^\\x25(?:([1-9]\\d*)\\$|\\(([^)]+)\\))?(\\+)?(0|'[^$])?(-)?(\\d+)?(?:\\.(\\d+))?([b-gijostTuvxX])/,key:/^([a-z_][a-z_\\d]*)/i,key_access:/^\\.([a-z_][a-z_\\d]*)/i,index_access:/^\\[(\\d+)\\]/,sign:/^[+-]/};function e(t){return i(o(t),arguments)}function n(t,r){return e.apply(null,[t].concat(r||[]))}function i(r,n){var i,a,o,s,l,c,u,f,h,p=1,d=r.length,m=\"\";for(a=0;a=0),s.type){case\"b\":i=parseInt(i,10).toString(2);break;case\"c\":i=String.fromCharCode(parseInt(i,10));break;case\"d\":case\"i\":i=parseInt(i,10);break;case\"j\":i=JSON.stringify(i,null,s.width?parseInt(s.width):0);break;case\"e\":i=s.precision?parseFloat(i).toExponential(s.precision):parseFloat(i).toExponential();break;case\"f\":i=s.precision?parseFloat(i).toFixed(s.precision):parseFloat(i);break;case\"g\":i=s.precision?String(Number(i.toPrecision(s.precision))):parseFloat(i);break;case\"o\":i=(parseInt(i,10)>>>0).toString(8);break;case\"s\":i=String(i),i=s.precision?i.substring(0,s.precision):i;break;case\"t\":i=String(!!i),i=s.precision?i.substring(0,s.precision):i;break;case\"T\":i=Object.prototype.toString.call(i).slice(8,-1).toLowerCase(),i=s.precision?i.substring(0,s.precision):i;break;case\"u\":i=parseInt(i,10)>>>0;break;case\"v\":i=i.valueOf(),i=s.precision?i.substring(0,s.precision):i;break;case\"x\":i=(parseInt(i,10)>>>0).toString(16);break;case\"X\":i=(parseInt(i,10)>>>0).toString(16).toUpperCase()}t.json.test(s.type)?m+=i:(!t.number.test(s.type)||f&&!s.sign?h=\"\":(h=f?\"+\":\"-\",i=i.toString().replace(t.sign,\"\")),c=s.pad_char?\"0\"===s.pad_char?\"0\":s.pad_char.charAt(1):\" \",u=s.width-(h+i).length,l=s.width&&u>0?c.repeat(u):\"\",m+=s.align?h+i+l:\"0\"===c?h+l+i:l+h+i)}return m}var a=Object.create(null);function o(e){if(a[e])return a[e];for(var r,n=e,i=[],o=0;n;){if(null!==(r=t.text.exec(n)))i.push(r[0]);else if(null!==(r=t.modulo.exec(n)))i.push(\"%\");else{if(null===(r=t.placeholder.exec(n)))throw new SyntaxError(\"[sprintf] unexpected placeholder\");if(r[2]){o|=1;var s=[],l=r[2],c=[];if(null===(c=t.key.exec(l)))throw new SyntaxError(\"[sprintf] failed to parse named argument key\");for(s.push(c[1]);\"\"!==(l=l.substring(c[0].length));)if(null!==(c=t.key_access.exec(l)))s.push(c[1]);else{if(null===(c=t.index_access.exec(l)))throw new SyntaxError(\"[sprintf] failed to parse named argument key\");s.push(c[1])}r[2]=s}else o|=2;if(3===o)throw new Error(\"[sprintf] mixing positional and named placeholders is not (yet) supported\");i.push({placeholder:r[0],param_no:r[1],keys:r[2],sign:r[3],pad_char:r[4],align:r[5],width:r[6],precision:r[7],type:r[8]})}n=n.substring(r[0].length)}return a[e]=i}void 0!==r&&(r.sprintf=e,r.vsprintf=n),\"undefined\"!=typeof window&&(window.sprintf=e,window.vsprintf=n)}()},{}],302:[function(t,e,r){\"use strict\";e.exports=function(t,e){if(t.dimension<=0)return{positions:[],cells:[]};if(1===t.dimension)return function(t,e){for(var r=i(t,e),n=r.length,a=new Array(n),o=new Array(n),s=0;sn|0},vertex:function(t,e,r,n,i,a,o,s,l,c,u,f,h){var p=(o<<0)+(s<<1)+(l<<2)+(c<<3)|0;if(0!==p&&15!==p)switch(p){case 0:u.push([t-.5,e-.5]);break;case 1:u.push([t-.25-.25*(n+r-2*h)/(r-n),e-.25-.25*(i+r-2*h)/(r-i)]);break;case 2:u.push([t-.75-.25*(-n-r+2*h)/(n-r),e-.25-.25*(a+n-2*h)/(n-a)]);break;case 3:u.push([t-.5,e-.5-.5*(i+r+a+n-4*h)/(r-i+n-a)]);break;case 4:u.push([t-.25-.25*(a+i-2*h)/(i-a),e-.75-.25*(-i-r+2*h)/(i-r)]);break;case 5:u.push([t-.5-.5*(n+r+a+i-4*h)/(r-n+i-a),e-.5]);break;case 6:u.push([t-.5-.25*(-n-r+a+i)/(n-r+i-a),e-.5-.25*(-i-r+a+n)/(i-r+n-a)]);break;case 7:u.push([t-.75-.25*(a+i-2*h)/(i-a),e-.75-.25*(a+n-2*h)/(n-a)]);break;case 8:u.push([t-.75-.25*(-a-i+2*h)/(a-i),e-.75-.25*(-a-n+2*h)/(a-n)]);break;case 9:u.push([t-.5-.25*(n+r+-a-i)/(r-n+a-i),e-.5-.25*(i+r+-a-n)/(r-i+a-n)]);break;case 10:u.push([t-.5-.5*(-n-r-a-i+4*h)/(n-r+a-i),e-.5]);break;case 11:u.push([t-.25-.25*(-a-i+2*h)/(a-i),e-.75-.25*(i+r-2*h)/(r-i)]);break;case 12:u.push([t-.5,e-.5-.5*(-i-r-a-n+4*h)/(i-r+a-n)]);break;case 13:u.push([t-.75-.25*(n+r-2*h)/(r-n),e-.25-.25*(-a-n+2*h)/(a-n)]);break;case 14:u.push([t-.25-.25*(-n-r+2*h)/(n-r),e-.25-.25*(-i-r+2*h)/(i-r)]);break;case 15:u.push([t-.5,e-.5])}},cell:function(t,e,r,n,i,a,o,s,l){i?s.push([t,e]):s.push([e,t])}});return function(t,e){var r=[],i=[];return n(t,r,i,e),{positions:r,cells:i}}}};var o={}},{\"ndarray-extract-contour\":251,\"zero-crossings\":318}],303:[function(t,e,r){(function(r){(function(){\"use strict\";e.exports=function t(e,r,i){i=i||{};var o=a[e];o||(o=a[e]={\" \":{data:new Float32Array(0),shape:.2}});var s=o[r];if(!s)if(r.length<=1||!/\\d/.test(r))s=o[r]=function(t){for(var e=t.cells,r=t.positions,n=new Float32Array(6*e.length),i=0,a=0,o=0;o0&&(f+=.02);var p=new Float32Array(u),d=0,m=-.5*f;for(h=0;hMath.max(r,n)?i[2]=1:r>Math.max(e,n)?i[0]=1:i[1]=1;for(var a=0,o=0,l=0;l<3;++l)a+=t[l]*t[l],o+=i[l]*t[l];for(l=0;l<3;++l)i[l]-=o/a*t[l];return s(i,i),i}function h(t,e,r,i,a,o,s,l){this.center=n(r),this.up=n(i),this.right=n(a),this.radius=n([o]),this.angle=n([s,l]),this.angle.bounds=[[-1/0,-Math.PI/2],[1/0,Math.PI/2]],this.setDistanceLimits(t,e),this.computedCenter=this.center.curve(0),this.computedUp=this.up.curve(0),this.computedRight=this.right.curve(0),this.computedRadius=this.radius.curve(0),this.computedAngle=this.angle.curve(0),this.computedToward=[0,0,0],this.computedEye=[0,0,0],this.computedMatrix=new Array(16);for(var c=0;c<16;++c)this.computedMatrix[c]=.5;this.recalcMatrix(0)}var p=h.prototype;p.setDistanceLimits=function(t,e){t=t>0?Math.log(t):-1/0,e=e>0?Math.log(e):1/0,e=Math.max(e,t),this.radius.bounds[0][0]=t,this.radius.bounds[1][0]=e},p.getDistanceLimits=function(t){var e=this.radius.bounds[0];return t?(t[0]=Math.exp(e[0][0]),t[1]=Math.exp(e[1][0]),t):[Math.exp(e[0][0]),Math.exp(e[1][0])]},p.recalcMatrix=function(t){this.center.curve(t),this.up.curve(t),this.right.curve(t),this.radius.curve(t),this.angle.curve(t);for(var e=this.computedUp,r=this.computedRight,n=0,i=0,a=0;a<3;++a)i+=e[a]*r[a],n+=e[a]*e[a];var l=Math.sqrt(n),u=0;for(a=0;a<3;++a)r[a]-=e[a]*i/n,u+=r[a]*r[a],e[a]/=l;var f=Math.sqrt(u);for(a=0;a<3;++a)r[a]/=f;var h=this.computedToward;o(h,e,r),s(h,h);var p=Math.exp(this.computedRadius[0]),d=this.computedAngle[0],m=this.computedAngle[1],g=Math.cos(d),v=Math.sin(d),y=Math.cos(m),x=Math.sin(m),b=this.computedCenter,_=g*y,w=v*y,T=x,k=-g*x,A=-v*x,M=y,S=this.computedEye,E=this.computedMatrix;for(a=0;a<3;++a){var L=_*r[a]+w*h[a]+T*e[a];E[4*a+1]=k*r[a]+A*h[a]+M*e[a],E[4*a+2]=L,E[4*a+3]=0}var C=E[1],P=E[5],I=E[9],O=E[2],z=E[6],D=E[10],R=P*D-I*z,F=I*O-C*D,B=C*z-P*O,N=c(R,F,B);R/=N,F/=N,B/=N,E[0]=R,E[4]=F,E[8]=B;for(a=0;a<3;++a)S[a]=b[a]+E[2+4*a]*p;for(a=0;a<3;++a){u=0;for(var j=0;j<3;++j)u+=E[a+4*j]*S[j];E[12+a]=-u}E[15]=1},p.getMatrix=function(t,e){this.recalcMatrix(t);var r=this.computedMatrix;if(e){for(var n=0;n<16;++n)e[n]=r[n];return e}return r};var d=[0,0,0];p.rotate=function(t,e,r,n){if(this.angle.move(t,e,r),n){this.recalcMatrix(t);var i=this.computedMatrix;d[0]=i[2],d[1]=i[6],d[2]=i[10];for(var o=this.computedUp,s=this.computedRight,l=this.computedToward,c=0;c<3;++c)i[4*c]=o[c],i[4*c+1]=s[c],i[4*c+2]=l[c];a(i,i,n,d);for(c=0;c<3;++c)o[c]=i[4*c],s[c]=i[4*c+1];this.up.set(t,o[0],o[1],o[2]),this.right.set(t,s[0],s[1],s[2])}},p.pan=function(t,e,r,n){e=e||0,r=r||0,n=n||0,this.recalcMatrix(t);var i=this.computedMatrix,a=(Math.exp(this.computedRadius[0]),i[1]),o=i[5],s=i[9],l=c(a,o,s);a/=l,o/=l,s/=l;var u=i[0],f=i[4],h=i[8],p=u*a+f*o+h*s,d=c(u-=a*p,f-=o*p,h-=s*p),m=(u/=d)*e+a*r,g=(f/=d)*e+o*r,v=(h/=d)*e+s*r;this.center.move(t,m,g,v);var y=Math.exp(this.computedRadius[0]);y=Math.max(1e-4,y+n),this.radius.set(t,Math.log(y))},p.translate=function(t,e,r,n){this.center.move(t,e||0,r||0,n||0)},p.setMatrix=function(t,e,r,n){var a=1;\"number\"==typeof r&&(a=0|r),(a<0||a>3)&&(a=1);var o=(a+2)%3;e||(this.recalcMatrix(t),e=this.computedMatrix);var s=e[a],l=e[a+4],f=e[a+8];if(n){var h=Math.abs(s),p=Math.abs(l),d=Math.abs(f),m=Math.max(h,p,d);h===m?(s=s<0?-1:1,l=f=0):d===m?(f=f<0?-1:1,s=l=0):(l=l<0?-1:1,s=f=0)}else{var g=c(s,l,f);s/=g,l/=g,f/=g}var v,y,x=e[o],b=e[o+4],_=e[o+8],w=x*s+b*l+_*f,T=c(x-=s*w,b-=l*w,_-=f*w),k=l*(_/=T)-f*(b/=T),A=f*(x/=T)-s*_,M=s*b-l*x,S=c(k,A,M);if(k/=S,A/=S,M/=S,this.center.jump(t,q,G,Y),this.radius.idle(t),this.up.jump(t,s,l,f),this.right.jump(t,x,b,_),2===a){var E=e[1],L=e[5],C=e[9],P=E*x+L*b+C*_,I=E*k+L*A+C*M;v=R<0?-Math.PI/2:Math.PI/2,y=Math.atan2(I,P)}else{var O=e[2],z=e[6],D=e[10],R=O*s+z*l+D*f,F=O*x+z*b+D*_,B=O*k+z*A+D*M;v=Math.asin(u(R)),y=Math.atan2(B,F)}this.angle.jump(t,y,v),this.recalcMatrix(t);var N=e[2],j=e[6],U=e[10],V=this.computedMatrix;i(V,e);var H=V[15],q=V[12]/H,G=V[13]/H,Y=V[14]/H,W=Math.exp(this.computedRadius[0]);this.center.jump(t,q-N*W,G-j*W,Y-U*W)},p.lastT=function(){return Math.max(this.center.lastT(),this.up.lastT(),this.right.lastT(),this.radius.lastT(),this.angle.lastT())},p.idle=function(t){this.center.idle(t),this.up.idle(t),this.right.idle(t),this.radius.idle(t),this.angle.idle(t)},p.flush=function(t){this.center.flush(t),this.up.flush(t),this.right.flush(t),this.radius.flush(t),this.angle.flush(t)},p.setDistance=function(t,e){e>0&&this.radius.set(t,Math.log(e))},p.lookAt=function(t,e,r,n){this.recalcMatrix(t),e=e||this.computedEye,r=r||this.computedCenter;var i=(n=n||this.computedUp)[0],a=n[1],o=n[2],s=c(i,a,o);if(!(s<1e-6)){i/=s,a/=s,o/=s;var l=e[0]-r[0],f=e[1]-r[1],h=e[2]-r[2],p=c(l,f,h);if(!(p<1e-6)){l/=p,f/=p,h/=p;var d=this.computedRight,m=d[0],g=d[1],v=d[2],y=i*m+a*g+o*v,x=c(m-=y*i,g-=y*a,v-=y*o);if(!(x<.01&&(x=c(m=a*h-o*f,g=o*l-i*h,v=i*f-a*l))<1e-6)){m/=x,g/=x,v/=x,this.up.set(t,i,a,o),this.right.set(t,m,g,v),this.center.set(t,r[0],r[1],r[2]),this.radius.set(t,Math.log(p));var b=a*v-o*g,_=o*m-i*v,w=i*g-a*m,T=c(b,_,w),k=i*l+a*f+o*h,A=m*l+g*f+v*h,M=(b/=T)*l+(_/=T)*f+(w/=T)*h,S=Math.asin(u(k)),E=Math.atan2(M,A),L=this.angle._state,C=L[L.length-1],P=L[L.length-2];C%=2*Math.PI;var I=Math.abs(C+2*Math.PI-E),O=Math.abs(C-E),z=Math.abs(C-2*Math.PI-E);I0?r.pop():new ArrayBuffer(t)}function d(t){return new Uint8Array(p(t),0,t)}function m(t){return new Uint16Array(p(2*t),0,t)}function g(t){return new Uint32Array(p(4*t),0,t)}function v(t){return new Int8Array(p(t),0,t)}function y(t){return new Int16Array(p(2*t),0,t)}function x(t){return new Int32Array(p(4*t),0,t)}function b(t){return new Float32Array(p(4*t),0,t)}function _(t){return new Float64Array(p(8*t),0,t)}function w(t){return o?new Uint8ClampedArray(p(t),0,t):d(t)}function T(t){return s?new BigUint64Array(p(8*t),0,t):null}function k(t){return l?new BigInt64Array(p(8*t),0,t):null}function A(t){return new DataView(p(t),0,t)}function M(t){t=n.nextPow2(t);var e=n.log2(t),r=f[e];return r.length>0?r.pop():new a(t)}r.free=function(t){if(a.isBuffer(t))f[n.log2(t.length)].push(t);else{if(\"[object ArrayBuffer]\"!==Object.prototype.toString.call(t)&&(t=t.buffer),!t)return;var e=t.length||t.byteLength,r=0|n.log2(e);u[r].push(t)}},r.freeUint8=r.freeUint16=r.freeUint32=r.freeBigUint64=r.freeInt8=r.freeInt16=r.freeInt32=r.freeBigInt64=r.freeFloat32=r.freeFloat=r.freeFloat64=r.freeDouble=r.freeUint8Clamped=r.freeDataView=function(t){h(t.buffer)},r.freeArrayBuffer=h,r.freeBuffer=function(t){f[n.log2(t.length)].push(t)},r.malloc=function(t,e){if(void 0===e||\"arraybuffer\"===e)return p(t);switch(e){case\"uint8\":return d(t);case\"uint16\":return m(t);case\"uint32\":return g(t);case\"int8\":return v(t);case\"int16\":return y(t);case\"int32\":return x(t);case\"float\":case\"float32\":return b(t);case\"double\":case\"float64\":return _(t);case\"uint8_clamped\":return w(t);case\"bigint64\":return k(t);case\"biguint64\":return T(t);case\"buffer\":return M(t);case\"data\":case\"dataview\":return A(t);default:return null}return null},r.mallocArrayBuffer=p,r.mallocUint8=d,r.mallocUint16=m,r.mallocUint32=g,r.mallocInt8=v,r.mallocInt16=y,r.mallocInt32=x,r.mallocFloat32=r.mallocFloat=b,r.mallocFloat64=r.mallocDouble=_,r.mallocUint8Clamped=w,r.mallocBigUint64=T,r.mallocBigInt64=k,r.mallocDataView=A,r.mallocBuffer=M,r.clearCache=function(){for(var t=0;t<32;++t)c.UINT8[t].length=0,c.UINT16[t].length=0,c.UINT32[t].length=0,c.INT8[t].length=0,c.INT16[t].length=0,c.INT32[t].length=0,c.FLOAT[t].length=0,c.DOUBLE[t].length=0,c.BIGUINT64[t].length=0,c.BIGINT64[t].length=0,c.UINT8C[t].length=0,u[t].length=0,f[t].length=0}}).call(this)}).call(this,void 0!==n?n:\"undefined\"!=typeof self?self:\"undefined\"!=typeof window?window:{})},{\"bit-twiddle\":32,buffer:3,dup:65}],309:[function(t,e,r){\"use strict\";function n(t){this.roots=new Array(t),this.ranks=new Array(t);for(var e=0;e0&&(a=n.size),n.lineSpacing&&n.lineSpacing>0&&(o=n.lineSpacing),n.styletags&&n.styletags.breaklines&&(s.breaklines=!!n.styletags.breaklines),n.styletags&&n.styletags.bolds&&(s.bolds=!!n.styletags.bolds),n.styletags&&n.styletags.italics&&(s.italics=!!n.styletags.italics),n.styletags&&n.styletags.subscripts&&(s.subscripts=!!n.styletags.subscripts),n.styletags&&n.styletags.superscripts&&(s.superscripts=!!n.styletags.superscripts));return r.font=[n.fontStyle,n.fontVariant,n.fontWeight,a+\"px\",n.font].filter((function(t){return t})).join(\" \"),r.textAlign=\"start\",r.textBaseline=\"alphabetic\",r.direction=\"ltr\",h(function(t,e,r,n,a,o){r=r.replace(/\\n/g,\"\"),r=!0===o.breaklines?r.replace(/\\/g,\"\\n\"):r.replace(/\\/g,\" \");var s=\"\",l=[];for(p=0;p-1?parseInt(t[1+i]):0,l=a>-1?parseInt(r[1+a]):0;s!==l&&(n=n.replace(S(),\"?px \"),g*=Math.pow(.75,l-s),n=n.replace(\"?px \",S())),m+=.25*x*(l-s)}if(!0===o.superscripts){var c=t.indexOf(\"+\"),u=r.indexOf(\"+\"),f=c>-1?parseInt(t[1+c]):0,h=u>-1?parseInt(r[1+u]):0;f!==h&&(n=n.replace(S(),\"?px \"),g*=Math.pow(.75,h-f),n=n.replace(\"?px \",S())),m-=.25*x*(h-f)}if(!0===o.bolds){var p=t.indexOf(\"b|\")>-1,d=r.indexOf(\"b|\")>-1;!p&&d&&(n=v?n.replace(\"italic \",\"italic bold \"):\"bold \"+n),p&&!d&&(n=n.replace(\"bold \",\"\"))}if(!0===o.italics){var v=t.indexOf(\"i|\")>-1,y=r.indexOf(\"i|\")>-1;!v&&y&&(n=\"italic \"+n),v&&!y&&(n=n.replace(\"italic \",\"\"))}e.font=n}for(h=0;h\",a=\"\",o=i.length,s=a.length,l=\"+\"===e[0]||\"-\"===e[0],c=0,u=-s;c>-1&&-1!==(c=r.indexOf(i,c))&&-1!==(u=r.indexOf(a,c+o))&&!(u<=c);){for(var f=c;f=u)n[f]=null,r=r.substr(0,f)+\" \"+r.substr(f+1);else if(null!==n[f]){var h=n[f].indexOf(e[0]);-1===h?n[f]+=e:l&&(n[f]=n[f].substr(0,h+1)+(1+parseInt(n[f][h+1]))+n[f].substr(h+2))}var p=c+o,d=r.substr(p,u-p).indexOf(i);c=-1!==d?d:u+s}return n}function u(t,e){var r=n(t,128);return e?a(r.cells,r.positions,.25):{edges:r.cells,positions:r.positions}}function f(t,e,r,n){var i=u(t,n),a=function(t,e,r){for(var n=e.textAlign||\"start\",i=e.textBaseline||\"alphabetic\",a=[1<<30,1<<30],o=[0,0],s=t.length,l=0;l=0?e[a]:i}))},has___:{value:y((function(e){var n=v(e);return n?r in n:t.indexOf(e)>=0}))},set___:{value:y((function(n,i){var a,o=v(n);return o?o[r]=i:(a=t.indexOf(n))>=0?e[a]=i:(a=t.length,e[a]=i,t[a]=n),this}))},delete___:{value:y((function(n){var i,a,o=v(n);return o?r in o&&delete o[r]:!((i=t.indexOf(n))<0)&&(a=t.length-1,t[i]=void 0,e[i]=e[a],t[i]=t[a],t.length=a,e.length=a,!0)}))}})};d.prototype=Object.create(Object.prototype,{get:{value:function(t,e){return this.get___(t,e)},writable:!0,configurable:!0},has:{value:function(t){return this.has___(t)},writable:!0,configurable:!0},set:{value:function(t,e){return this.set___(t,e)},writable:!0,configurable:!0},delete:{value:function(t){return this.delete___(t)},writable:!0,configurable:!0}}),\"function\"==typeof r?function(){function n(){this instanceof d||x();var e,n=new r,i=void 0,a=!1;return e=t?function(t,e){return n.set(t,e),n.has(t)||(i||(i=new d),i.set(t,e)),this}:function(t,e){if(a)try{n.set(t,e)}catch(r){i||(i=new d),i.set___(t,e)}else n.set(t,e);return this},Object.create(d.prototype,{get___:{value:y((function(t,e){return i?n.has(t)?n.get(t):i.get___(t,e):n.get(t,e)}))},has___:{value:y((function(t){return n.has(t)||!!i&&i.has___(t)}))},set___:{value:y(e)},delete___:{value:y((function(t){var e=!!n.delete(t);return i&&i.delete___(t)||e}))},permitHostObjects___:{value:y((function(t){if(t!==m)throw new Error(\"bogus call to permitHostObjects___\");a=!0}))}})}t&&\"undefined\"!=typeof Proxy&&(Proxy=void 0),n.prototype=d.prototype,e.exports=n,Object.defineProperty(WeakMap.prototype,\"constructor\",{value:WeakMap,enumerable:!1,configurable:!0,writable:!0})}():(\"undefined\"!=typeof Proxy&&(Proxy=void 0),e.exports=d)}function m(t){t.permitHostObjects___&&t.permitHostObjects___(m)}function g(t){return!(\"weakmap:\"==t.substr(0,\"weakmap:\".length)&&\"___\"===t.substr(t.length-3))}function v(t){if(t!==Object(t))throw new TypeError(\"Not an object: \"+t);var e=t[l];if(e&&e.key===t)return e;if(s(t)){e={key:t};try{return o(t,l,{value:e,writable:!1,enumerable:!1,configurable:!1}),e}catch(t){return}}}function y(t){return t.prototype=null,Object.freeze(t)}function x(){h||\"undefined\"==typeof console||(h=!0,console.warn(\"WeakMap should be invoked as new WeakMap(), not WeakMap(). This will be an error in the future.\"))}}()},{}],314:[function(t,e,r){var n=t(\"./hidden-store.js\");e.exports=function(){var t={};return function(e){if((\"object\"!=typeof e||null===e)&&\"function\"!=typeof e)throw new Error(\"Weakmap-shim: Key must be object\");var r=e.valueOf(t);return r&&r.identity===t?r:n(e,t)}}},{\"./hidden-store.js\":315}],315:[function(t,e,r){e.exports=function(t,e){var r={identity:e},n=t.valueOf;return Object.defineProperty(t,\"valueOf\",{value:function(t){return t!==e?n.apply(this,arguments):r},writable:!0}),r}},{}],316:[function(t,e,r){var n=t(\"./create-store.js\");e.exports=function(){var t=n();return{get:function(e,r){var n=t(e);return n.hasOwnProperty(\"value\")?n.value:r},set:function(e,r){return t(e).value=r,this},has:function(e){return\"value\"in t(e)},delete:function(e){return delete t(e).value}}}},{\"./create-store.js\":314}],317:[function(t,e,r){\"use strict\";var n,i=function(){return function(t,e,r,n,i,a){var o=t[0],s=r[0],l=[0],c=s;n|=0;var u=0,f=s;for(u=0;u=0!=p>=0&&i.push(l[0]+.5+.5*(h+p)/(h-p)),n+=f,++l[0]}}};e.exports=(n={funcName:{funcName:\"zeroCrossings\"}.funcName},function(t){var e={};return function(r,n,i){var a=r.dtype,o=r.order,s=[a,o.join()].join(),l=e[s];return l||(e[s]=l=t([a,o])),l(r.shape.slice(0),r.data,r.stride,0|r.offset,n,i)}}(i.bind(void 0,n)))},{}],318:[function(t,e,r){\"use strict\";e.exports=function(t,e){var r=[];return e=+e||0,n(t.hi(t.shape[0]-1),r,e),r};var n=t(\"./lib/zc-core\")},{\"./lib/zc-core\":317}]},{},[6])(6)}))}).call(this)}).call(this,\"undefined\"!=typeof global?global:\"undefined\"!=typeof self?self:\"undefined\"!=typeof window?window:{})},{}]},{},[27])(27)}));
\n", + "\"use strict\";var n,i=\"\";e.exports=function(t,e){if(\"string\"!=typeof t)throw new TypeError(\"expected a string\");if(1===e)return t;if(2===e)return t+t;var r=t.length*e;if(n!==t||void 0===n)n=t,i=\"\";else if(i.length>=r)return i.substr(0,r);for(;r>i.length&&e>1;)1&e&&(i+=t),e>>=1,t+=t;return i=(i+=t).substr(0,r)}},{}],278:[function(t,e,r){(function(t){(function(){e.exports=t.performance&&t.performance.now?function(){return performance.now()}:Date.now||function(){return+new Date}}).call(this)}).call(this,void 0!==n?n:\"undefined\"!=typeof self?self:\"undefined\"!=typeof window?window:{})},{}],279:[function(t,e,r){\"use strict\";e.exports=function(t){for(var e=t.length,r=t[t.length-1],n=e,i=e-2;i>=0;--i){var a=r,o=t[i];(l=o-((r=a+o)-a))&&(t[--n]=r,r=l)}var s=0;for(i=n;i0){if(a<=0)return o;n=i+a}else{if(!(i<0))return o;if(a>=0)return o;n=-(i+a)}var s=33306690738754716e-32*n;return o>=s||o<=-s?o:f(t,e,r)},function(t,e,r,n){var i=t[0]-n[0],a=e[0]-n[0],o=r[0]-n[0],s=t[1]-n[1],l=e[1]-n[1],c=r[1]-n[1],u=t[2]-n[2],f=e[2]-n[2],p=r[2]-n[2],d=a*c,m=o*l,g=o*s,v=i*c,y=i*l,x=a*s,b=u*(d-m)+f*(g-v)+p*(y-x),_=7771561172376103e-31*((Math.abs(d)+Math.abs(m))*Math.abs(u)+(Math.abs(g)+Math.abs(v))*Math.abs(f)+(Math.abs(y)+Math.abs(x))*Math.abs(p));return b>_||-b>_?b:h(t,e,r,n)}];function d(t){var e=p[t.length];return e||(e=p[t.length]=u(t.length)),e.apply(void 0,t)}function m(t,e,r,n,i,a,o){return function(e,r,s,l,c){switch(arguments.length){case 0:case 1:return 0;case 2:return n(e,r);case 3:return i(e,r,s);case 4:return a(e,r,s,l);case 5:return o(e,r,s,l,c)}for(var u=new Array(arguments.length),f=0;f0&&o>0||a<0&&o<0)return!1;var s=n(r,t,e),l=n(i,t,e);if(s>0&&l>0||s<0&&l<0)return!1;if(0===a&&0===o&&0===s&&0===l)return function(t,e,r,n){for(var i=0;i<2;++i){var a=t[i],o=e[i],s=Math.min(a,o),l=Math.max(a,o),c=r[i],u=n[i],f=Math.min(c,u);if(Math.max(c,u)=n?(i=f,(l+=1)=n?(i=f,(l+=1)>1,c=e[2*l+1];if(c===a)return l;a>1,c=e[2*l+1];if(c===a)return l;a>1,c=e[2*l+1];if(c===a)return l;a>1,s=a(t[o],e);s<=0?(0===s&&(i=o),r=o+1):s>0&&(n=o-1)}return i}function u(t,e){for(var r=new Array(t.length),i=0,o=r.length;i=t.length||0!==a(t[g],s)););}return r}function f(t,e){if(e<0)return[];for(var r=[],i=(1<>>u&1&&c.push(i[u]);e.push(c)}return s(e)},r.skeleton=f,r.boundary=function(t){for(var e=[],r=0,n=t.length;r>1:(t>>1)-1}function x(t){for(var e=v(t);;){var r=e,n=2*t+1,i=2*(t+1),a=t;if(n0;){var r=y(t);if(r>=0)if(e0){var t=k[0];return g(0,M-1),M-=1,x(0),t}return-1}function w(t,e){var r=k[t];return c[r]===e?t:(c[r]=-1/0,b(t),_(),c[r]=e,b((M+=1)-1))}function T(t){if(!u[t]){u[t]=!0;var e=s[t],r=l[t];s[r]>=0&&(s[r]=e),l[e]>=0&&(l[e]=r),A[e]>=0&&w(A[e],m(e)),A[r]>=0&&w(A[r],m(r))}}var k=[],A=new Array(a);for(f=0;f>1;f>=0;--f)x(f);for(;;){var S=_();if(S<0||c[S]>r)break;T(S)}var E=[];for(f=0;f=0&&r>=0&&e!==r){var n=A[e],i=A[r];n!==i&&C.push([n,i])}})),i.unique(i.normalize(C)),{positions:E,edges:C}};var n=t(\"robust-orientation\"),i=t(\"simplicial-complex\")},{\"robust-orientation\":284,\"simplicial-complex\":295}],298:[function(t,e,r){\"use strict\";e.exports=function(t,e){var r,a,o,s;if(e[0][0]e[1][0]))return i(e,t);r=e[1],a=e[0]}if(t[0][0]t[1][0]))return-i(t,e);o=t[1],s=t[0]}var l=n(r,a,s),c=n(r,a,o);if(l<0){if(c<=0)return l}else if(l>0){if(c>=0)return l}else if(c)return c;if(l=n(s,o,a),c=n(s,o,r),l<0){if(c<=0)return l}else if(l>0){if(c>=0)return l}else if(c)return c;return a[0]-s[0]};var n=t(\"robust-orientation\");function i(t,e){var r,i,a,o;if(e[0][0]e[1][0])){var s=Math.min(t[0][1],t[1][1]),l=Math.max(t[0][1],t[1][1]),c=Math.min(e[0][1],e[1][1]),u=Math.max(e[0][1],e[1][1]);return lu?s-u:l-u}r=e[1],i=e[0]}t[0][1]0)if(e[0]!==o[1][0])r=t,t=t.right;else{if(l=c(t.right,e))return l;t=t.left}else{if(e[0]!==o[1][0])return t;var l;if(l=c(t.right,e))return l;t=t.left}}return r}function u(t,e,r,n){this.y=t,this.index=e,this.start=r,this.closed=n}function f(t,e,r,n){this.x=t,this.segment=e,this.create=r,this.index=n}s.prototype.castUp=function(t){var e=n.le(this.coordinates,t[0]);if(e<0)return-1;this.slabs[e];var r=c(this.slabs[e],t),i=-1;if(r&&(i=r.value),this.coordinates[e]===t[0]){var s=null;if(r&&(s=r.key),e>0){var u=c(this.slabs[e-1],t);u&&(s?o(u.key,s)>0&&(s=u.key,i=u.value):(i=u.value,s=u.key))}var f=this.horizontal[e];if(f.length>0){var h=n.ge(f,t[1],l);if(h=f.length)return i;p=f[h]}}if(p.start)if(s){var d=a(s[0],s[1],[t[0],p.y]);s[0][0]>s[1][0]&&(d=-d),d>0&&(i=p.index)}else i=p.index;else p.y!==t[1]&&(i=p.index)}}}return i}},{\"./lib/order-segments\":298,\"binary-search-bounds\":31,\"functional-red-black-tree\":69,\"robust-orientation\":284}],300:[function(t,e,r){\"use strict\";var n=t(\"robust-dot-product\"),i=t(\"robust-sum\");function a(t,e){var r=i(n(t,e),[e[e.length-1]]);return r[r.length-1]}function o(t,e,r,n){var i=-e/(n-e);i<0?i=0:i>1&&(i=1);for(var a=1-i,o=t.length,s=new Array(o),l=0;l0||i>0&&u<0){var f=o(s,u,l,i);r.push(f),n.push(f.slice())}u<0?n.push(l.slice()):u>0?r.push(l.slice()):(r.push(l.slice()),n.push(l.slice())),i=u}return{positive:r,negative:n}},e.exports.positive=function(t,e){for(var r=[],n=a(t[t.length-1],e),i=t[t.length-1],s=t[0],l=0;l0||n>0&&c<0)&&r.push(o(i,c,s,n)),c>=0&&r.push(s.slice()),n=c}return r},e.exports.negative=function(t,e){for(var r=[],n=a(t[t.length-1],e),i=t[t.length-1],s=t[0],l=0;l0||n>0&&c<0)&&r.push(o(i,c,s,n)),c<=0&&r.push(s.slice()),n=c}return r}},{\"robust-dot-product\":281,\"robust-sum\":289}],301:[function(t,e,r){!function(){\"use strict\";var t={not_string:/[^s]/,not_bool:/[^t]/,not_type:/[^T]/,not_primitive:/[^v]/,number:/[diefg]/,numeric_arg:/[bcdiefguxX]/,json:/[j]/,not_json:/[^j]/,text:/^[^\\x25]+/,modulo:/^\\x25{2}/,placeholder:/^\\x25(?:([1-9]\\d*)\\$|\\(([^)]+)\\))?(\\+)?(0|'[^$])?(-)?(\\d+)?(?:\\.(\\d+))?([b-gijostTuvxX])/,key:/^([a-z_][a-z_\\d]*)/i,key_access:/^\\.([a-z_][a-z_\\d]*)/i,index_access:/^\\[(\\d+)\\]/,sign:/^[+-]/};function e(t){return i(o(t),arguments)}function n(t,r){return e.apply(null,[t].concat(r||[]))}function i(r,n){var i,a,o,s,l,c,u,f,h,p=1,d=r.length,m=\"\";for(a=0;a=0),s.type){case\"b\":i=parseInt(i,10).toString(2);break;case\"c\":i=String.fromCharCode(parseInt(i,10));break;case\"d\":case\"i\":i=parseInt(i,10);break;case\"j\":i=JSON.stringify(i,null,s.width?parseInt(s.width):0);break;case\"e\":i=s.precision?parseFloat(i).toExponential(s.precision):parseFloat(i).toExponential();break;case\"f\":i=s.precision?parseFloat(i).toFixed(s.precision):parseFloat(i);break;case\"g\":i=s.precision?String(Number(i.toPrecision(s.precision))):parseFloat(i);break;case\"o\":i=(parseInt(i,10)>>>0).toString(8);break;case\"s\":i=String(i),i=s.precision?i.substring(0,s.precision):i;break;case\"t\":i=String(!!i),i=s.precision?i.substring(0,s.precision):i;break;case\"T\":i=Object.prototype.toString.call(i).slice(8,-1).toLowerCase(),i=s.precision?i.substring(0,s.precision):i;break;case\"u\":i=parseInt(i,10)>>>0;break;case\"v\":i=i.valueOf(),i=s.precision?i.substring(0,s.precision):i;break;case\"x\":i=(parseInt(i,10)>>>0).toString(16);break;case\"X\":i=(parseInt(i,10)>>>0).toString(16).toUpperCase()}t.json.test(s.type)?m+=i:(!t.number.test(s.type)||f&&!s.sign?h=\"\":(h=f?\"+\":\"-\",i=i.toString().replace(t.sign,\"\")),c=s.pad_char?\"0\"===s.pad_char?\"0\":s.pad_char.charAt(1):\" \",u=s.width-(h+i).length,l=s.width&&u>0?c.repeat(u):\"\",m+=s.align?h+i+l:\"0\"===c?h+l+i:l+h+i)}return m}var a=Object.create(null);function o(e){if(a[e])return a[e];for(var r,n=e,i=[],o=0;n;){if(null!==(r=t.text.exec(n)))i.push(r[0]);else if(null!==(r=t.modulo.exec(n)))i.push(\"%\");else{if(null===(r=t.placeholder.exec(n)))throw new SyntaxError(\"[sprintf] unexpected placeholder\");if(r[2]){o|=1;var s=[],l=r[2],c=[];if(null===(c=t.key.exec(l)))throw new SyntaxError(\"[sprintf] failed to parse named argument key\");for(s.push(c[1]);\"\"!==(l=l.substring(c[0].length));)if(null!==(c=t.key_access.exec(l)))s.push(c[1]);else{if(null===(c=t.index_access.exec(l)))throw new SyntaxError(\"[sprintf] failed to parse named argument key\");s.push(c[1])}r[2]=s}else o|=2;if(3===o)throw new Error(\"[sprintf] mixing positional and named placeholders is not (yet) supported\");i.push({placeholder:r[0],param_no:r[1],keys:r[2],sign:r[3],pad_char:r[4],align:r[5],width:r[6],precision:r[7],type:r[8]})}n=n.substring(r[0].length)}return a[e]=i}void 0!==r&&(r.sprintf=e,r.vsprintf=n),\"undefined\"!=typeof window&&(window.sprintf=e,window.vsprintf=n)}()},{}],302:[function(t,e,r){\"use strict\";e.exports=function(t,e){if(t.dimension<=0)return{positions:[],cells:[]};if(1===t.dimension)return function(t,e){for(var r=i(t,e),n=r.length,a=new Array(n),o=new Array(n),s=0;sn|0},vertex:function(t,e,r,n,i,a,o,s,l,c,u,f,h){var p=(o<<0)+(s<<1)+(l<<2)+(c<<3)|0;if(0!==p&&15!==p)switch(p){case 0:u.push([t-.5,e-.5]);break;case 1:u.push([t-.25-.25*(n+r-2*h)/(r-n),e-.25-.25*(i+r-2*h)/(r-i)]);break;case 2:u.push([t-.75-.25*(-n-r+2*h)/(n-r),e-.25-.25*(a+n-2*h)/(n-a)]);break;case 3:u.push([t-.5,e-.5-.5*(i+r+a+n-4*h)/(r-i+n-a)]);break;case 4:u.push([t-.25-.25*(a+i-2*h)/(i-a),e-.75-.25*(-i-r+2*h)/(i-r)]);break;case 5:u.push([t-.5-.5*(n+r+a+i-4*h)/(r-n+i-a),e-.5]);break;case 6:u.push([t-.5-.25*(-n-r+a+i)/(n-r+i-a),e-.5-.25*(-i-r+a+n)/(i-r+n-a)]);break;case 7:u.push([t-.75-.25*(a+i-2*h)/(i-a),e-.75-.25*(a+n-2*h)/(n-a)]);break;case 8:u.push([t-.75-.25*(-a-i+2*h)/(a-i),e-.75-.25*(-a-n+2*h)/(a-n)]);break;case 9:u.push([t-.5-.25*(n+r+-a-i)/(r-n+a-i),e-.5-.25*(i+r+-a-n)/(r-i+a-n)]);break;case 10:u.push([t-.5-.5*(-n-r-a-i+4*h)/(n-r+a-i),e-.5]);break;case 11:u.push([t-.25-.25*(-a-i+2*h)/(a-i),e-.75-.25*(i+r-2*h)/(r-i)]);break;case 12:u.push([t-.5,e-.5-.5*(-i-r-a-n+4*h)/(i-r+a-n)]);break;case 13:u.push([t-.75-.25*(n+r-2*h)/(r-n),e-.25-.25*(-a-n+2*h)/(a-n)]);break;case 14:u.push([t-.25-.25*(-n-r+2*h)/(n-r),e-.25-.25*(-i-r+2*h)/(i-r)]);break;case 15:u.push([t-.5,e-.5])}},cell:function(t,e,r,n,i,a,o,s,l){i?s.push([t,e]):s.push([e,t])}});return function(t,e){var r=[],i=[];return n(t,r,i,e),{positions:r,cells:i}}}};var o={}},{\"ndarray-extract-contour\":251,\"zero-crossings\":318}],303:[function(t,e,r){(function(r){(function(){\"use strict\";e.exports=function t(e,r,i){i=i||{};var o=a[e];o||(o=a[e]={\" \":{data:new Float32Array(0),shape:.2}});var s=o[r];if(!s)if(r.length<=1||!/\\d/.test(r))s=o[r]=function(t){for(var e=t.cells,r=t.positions,n=new Float32Array(6*e.length),i=0,a=0,o=0;o0&&(f+=.02);var p=new Float32Array(u),d=0,m=-.5*f;for(h=0;hMath.max(r,n)?i[2]=1:r>Math.max(e,n)?i[0]=1:i[1]=1;for(var a=0,o=0,l=0;l<3;++l)a+=t[l]*t[l],o+=i[l]*t[l];for(l=0;l<3;++l)i[l]-=o/a*t[l];return s(i,i),i}function h(t,e,r,i,a,o,s,l){this.center=n(r),this.up=n(i),this.right=n(a),this.radius=n([o]),this.angle=n([s,l]),this.angle.bounds=[[-1/0,-Math.PI/2],[1/0,Math.PI/2]],this.setDistanceLimits(t,e),this.computedCenter=this.center.curve(0),this.computedUp=this.up.curve(0),this.computedRight=this.right.curve(0),this.computedRadius=this.radius.curve(0),this.computedAngle=this.angle.curve(0),this.computedToward=[0,0,0],this.computedEye=[0,0,0],this.computedMatrix=new Array(16);for(var c=0;c<16;++c)this.computedMatrix[c]=.5;this.recalcMatrix(0)}var p=h.prototype;p.setDistanceLimits=function(t,e){t=t>0?Math.log(t):-1/0,e=e>0?Math.log(e):1/0,e=Math.max(e,t),this.radius.bounds[0][0]=t,this.radius.bounds[1][0]=e},p.getDistanceLimits=function(t){var e=this.radius.bounds[0];return t?(t[0]=Math.exp(e[0][0]),t[1]=Math.exp(e[1][0]),t):[Math.exp(e[0][0]),Math.exp(e[1][0])]},p.recalcMatrix=function(t){this.center.curve(t),this.up.curve(t),this.right.curve(t),this.radius.curve(t),this.angle.curve(t);for(var e=this.computedUp,r=this.computedRight,n=0,i=0,a=0;a<3;++a)i+=e[a]*r[a],n+=e[a]*e[a];var l=Math.sqrt(n),u=0;for(a=0;a<3;++a)r[a]-=e[a]*i/n,u+=r[a]*r[a],e[a]/=l;var f=Math.sqrt(u);for(a=0;a<3;++a)r[a]/=f;var h=this.computedToward;o(h,e,r),s(h,h);var p=Math.exp(this.computedRadius[0]),d=this.computedAngle[0],m=this.computedAngle[1],g=Math.cos(d),v=Math.sin(d),y=Math.cos(m),x=Math.sin(m),b=this.computedCenter,_=g*y,w=v*y,T=x,k=-g*x,A=-v*x,M=y,S=this.computedEye,E=this.computedMatrix;for(a=0;a<3;++a){var L=_*r[a]+w*h[a]+T*e[a];E[4*a+1]=k*r[a]+A*h[a]+M*e[a],E[4*a+2]=L,E[4*a+3]=0}var C=E[1],P=E[5],I=E[9],O=E[2],z=E[6],D=E[10],R=P*D-I*z,F=I*O-C*D,B=C*z-P*O,N=c(R,F,B);R/=N,F/=N,B/=N,E[0]=R,E[4]=F,E[8]=B;for(a=0;a<3;++a)S[a]=b[a]+E[2+4*a]*p;for(a=0;a<3;++a){u=0;for(var j=0;j<3;++j)u+=E[a+4*j]*S[j];E[12+a]=-u}E[15]=1},p.getMatrix=function(t,e){this.recalcMatrix(t);var r=this.computedMatrix;if(e){for(var n=0;n<16;++n)e[n]=r[n];return e}return r};var d=[0,0,0];p.rotate=function(t,e,r,n){if(this.angle.move(t,e,r),n){this.recalcMatrix(t);var i=this.computedMatrix;d[0]=i[2],d[1]=i[6],d[2]=i[10];for(var o=this.computedUp,s=this.computedRight,l=this.computedToward,c=0;c<3;++c)i[4*c]=o[c],i[4*c+1]=s[c],i[4*c+2]=l[c];a(i,i,n,d);for(c=0;c<3;++c)o[c]=i[4*c],s[c]=i[4*c+1];this.up.set(t,o[0],o[1],o[2]),this.right.set(t,s[0],s[1],s[2])}},p.pan=function(t,e,r,n){e=e||0,r=r||0,n=n||0,this.recalcMatrix(t);var i=this.computedMatrix,a=(Math.exp(this.computedRadius[0]),i[1]),o=i[5],s=i[9],l=c(a,o,s);a/=l,o/=l,s/=l;var u=i[0],f=i[4],h=i[8],p=u*a+f*o+h*s,d=c(u-=a*p,f-=o*p,h-=s*p),m=(u/=d)*e+a*r,g=(f/=d)*e+o*r,v=(h/=d)*e+s*r;this.center.move(t,m,g,v);var y=Math.exp(this.computedRadius[0]);y=Math.max(1e-4,y+n),this.radius.set(t,Math.log(y))},p.translate=function(t,e,r,n){this.center.move(t,e||0,r||0,n||0)},p.setMatrix=function(t,e,r,n){var a=1;\"number\"==typeof r&&(a=0|r),(a<0||a>3)&&(a=1);var o=(a+2)%3;e||(this.recalcMatrix(t),e=this.computedMatrix);var s=e[a],l=e[a+4],f=e[a+8];if(n){var h=Math.abs(s),p=Math.abs(l),d=Math.abs(f),m=Math.max(h,p,d);h===m?(s=s<0?-1:1,l=f=0):d===m?(f=f<0?-1:1,s=l=0):(l=l<0?-1:1,s=f=0)}else{var g=c(s,l,f);s/=g,l/=g,f/=g}var v,y,x=e[o],b=e[o+4],_=e[o+8],w=x*s+b*l+_*f,T=c(x-=s*w,b-=l*w,_-=f*w),k=l*(_/=T)-f*(b/=T),A=f*(x/=T)-s*_,M=s*b-l*x,S=c(k,A,M);if(k/=S,A/=S,M/=S,this.center.jump(t,q,G,Y),this.radius.idle(t),this.up.jump(t,s,l,f),this.right.jump(t,x,b,_),2===a){var E=e[1],L=e[5],C=e[9],P=E*x+L*b+C*_,I=E*k+L*A+C*M;v=R<0?-Math.PI/2:Math.PI/2,y=Math.atan2(I,P)}else{var O=e[2],z=e[6],D=e[10],R=O*s+z*l+D*f,F=O*x+z*b+D*_,B=O*k+z*A+D*M;v=Math.asin(u(R)),y=Math.atan2(B,F)}this.angle.jump(t,y,v),this.recalcMatrix(t);var N=e[2],j=e[6],U=e[10],V=this.computedMatrix;i(V,e);var H=V[15],q=V[12]/H,G=V[13]/H,Y=V[14]/H,W=Math.exp(this.computedRadius[0]);this.center.jump(t,q-N*W,G-j*W,Y-U*W)},p.lastT=function(){return Math.max(this.center.lastT(),this.up.lastT(),this.right.lastT(),this.radius.lastT(),this.angle.lastT())},p.idle=function(t){this.center.idle(t),this.up.idle(t),this.right.idle(t),this.radius.idle(t),this.angle.idle(t)},p.flush=function(t){this.center.flush(t),this.up.flush(t),this.right.flush(t),this.radius.flush(t),this.angle.flush(t)},p.setDistance=function(t,e){e>0&&this.radius.set(t,Math.log(e))},p.lookAt=function(t,e,r,n){this.recalcMatrix(t),e=e||this.computedEye,r=r||this.computedCenter;var i=(n=n||this.computedUp)[0],a=n[1],o=n[2],s=c(i,a,o);if(!(s<1e-6)){i/=s,a/=s,o/=s;var l=e[0]-r[0],f=e[1]-r[1],h=e[2]-r[2],p=c(l,f,h);if(!(p<1e-6)){l/=p,f/=p,h/=p;var d=this.computedRight,m=d[0],g=d[1],v=d[2],y=i*m+a*g+o*v,x=c(m-=y*i,g-=y*a,v-=y*o);if(!(x<.01&&(x=c(m=a*h-o*f,g=o*l-i*h,v=i*f-a*l))<1e-6)){m/=x,g/=x,v/=x,this.up.set(t,i,a,o),this.right.set(t,m,g,v),this.center.set(t,r[0],r[1],r[2]),this.radius.set(t,Math.log(p));var b=a*v-o*g,_=o*m-i*v,w=i*g-a*m,T=c(b,_,w),k=i*l+a*f+o*h,A=m*l+g*f+v*h,M=(b/=T)*l+(_/=T)*f+(w/=T)*h,S=Math.asin(u(k)),E=Math.atan2(M,A),L=this.angle._state,C=L[L.length-1],P=L[L.length-2];C%=2*Math.PI;var I=Math.abs(C+2*Math.PI-E),O=Math.abs(C-E),z=Math.abs(C-2*Math.PI-E);I0?r.pop():new ArrayBuffer(t)}function d(t){return new Uint8Array(p(t),0,t)}function m(t){return new Uint16Array(p(2*t),0,t)}function g(t){return new Uint32Array(p(4*t),0,t)}function v(t){return new Int8Array(p(t),0,t)}function y(t){return new Int16Array(p(2*t),0,t)}function x(t){return new Int32Array(p(4*t),0,t)}function b(t){return new Float32Array(p(4*t),0,t)}function _(t){return new Float64Array(p(8*t),0,t)}function w(t){return o?new Uint8ClampedArray(p(t),0,t):d(t)}function T(t){return s?new BigUint64Array(p(8*t),0,t):null}function k(t){return l?new BigInt64Array(p(8*t),0,t):null}function A(t){return new DataView(p(t),0,t)}function M(t){t=n.nextPow2(t);var e=n.log2(t),r=f[e];return r.length>0?r.pop():new a(t)}r.free=function(t){if(a.isBuffer(t))f[n.log2(t.length)].push(t);else{if(\"[object ArrayBuffer]\"!==Object.prototype.toString.call(t)&&(t=t.buffer),!t)return;var e=t.length||t.byteLength,r=0|n.log2(e);u[r].push(t)}},r.freeUint8=r.freeUint16=r.freeUint32=r.freeBigUint64=r.freeInt8=r.freeInt16=r.freeInt32=r.freeBigInt64=r.freeFloat32=r.freeFloat=r.freeFloat64=r.freeDouble=r.freeUint8Clamped=r.freeDataView=function(t){h(t.buffer)},r.freeArrayBuffer=h,r.freeBuffer=function(t){f[n.log2(t.length)].push(t)},r.malloc=function(t,e){if(void 0===e||\"arraybuffer\"===e)return p(t);switch(e){case\"uint8\":return d(t);case\"uint16\":return m(t);case\"uint32\":return g(t);case\"int8\":return v(t);case\"int16\":return y(t);case\"int32\":return x(t);case\"float\":case\"float32\":return b(t);case\"double\":case\"float64\":return _(t);case\"uint8_clamped\":return w(t);case\"bigint64\":return k(t);case\"biguint64\":return T(t);case\"buffer\":return M(t);case\"data\":case\"dataview\":return A(t);default:return null}return null},r.mallocArrayBuffer=p,r.mallocUint8=d,r.mallocUint16=m,r.mallocUint32=g,r.mallocInt8=v,r.mallocInt16=y,r.mallocInt32=x,r.mallocFloat32=r.mallocFloat=b,r.mallocFloat64=r.mallocDouble=_,r.mallocUint8Clamped=w,r.mallocBigUint64=T,r.mallocBigInt64=k,r.mallocDataView=A,r.mallocBuffer=M,r.clearCache=function(){for(var t=0;t<32;++t)c.UINT8[t].length=0,c.UINT16[t].length=0,c.UINT32[t].length=0,c.INT8[t].length=0,c.INT16[t].length=0,c.INT32[t].length=0,c.FLOAT[t].length=0,c.DOUBLE[t].length=0,c.BIGUINT64[t].length=0,c.BIGINT64[t].length=0,c.UINT8C[t].length=0,u[t].length=0,f[t].length=0}}).call(this)}).call(this,void 0!==n?n:\"undefined\"!=typeof self?self:\"undefined\"!=typeof window?window:{})},{\"bit-twiddle\":32,buffer:3,dup:65}],309:[function(t,e,r){\"use strict\";function n(t){this.roots=new Array(t),this.ranks=new Array(t);for(var e=0;e0&&(a=n.size),n.lineSpacing&&n.lineSpacing>0&&(o=n.lineSpacing),n.styletags&&n.styletags.breaklines&&(s.breaklines=!!n.styletags.breaklines),n.styletags&&n.styletags.bolds&&(s.bolds=!!n.styletags.bolds),n.styletags&&n.styletags.italics&&(s.italics=!!n.styletags.italics),n.styletags&&n.styletags.subscripts&&(s.subscripts=!!n.styletags.subscripts),n.styletags&&n.styletags.superscripts&&(s.superscripts=!!n.styletags.superscripts));return r.font=[n.fontStyle,n.fontVariant,n.fontWeight,a+\"px\",n.font].filter((function(t){return t})).join(\" \"),r.textAlign=\"start\",r.textBaseline=\"alphabetic\",r.direction=\"ltr\",h(function(t,e,r,n,a,o){r=r.replace(/\\n/g,\"\"),r=!0===o.breaklines?r.replace(/\\/g,\"\\n\"):r.replace(/\\/g,\" \");var s=\"\",l=[];for(p=0;p-1?parseInt(t[1+i]):0,l=a>-1?parseInt(r[1+a]):0;s!==l&&(n=n.replace(S(),\"?px \"),g*=Math.pow(.75,l-s),n=n.replace(\"?px \",S())),m+=.25*x*(l-s)}if(!0===o.superscripts){var c=t.indexOf(\"+\"),u=r.indexOf(\"+\"),f=c>-1?parseInt(t[1+c]):0,h=u>-1?parseInt(r[1+u]):0;f!==h&&(n=n.replace(S(),\"?px \"),g*=Math.pow(.75,h-f),n=n.replace(\"?px \",S())),m-=.25*x*(h-f)}if(!0===o.bolds){var p=t.indexOf(\"b|\")>-1,d=r.indexOf(\"b|\")>-1;!p&&d&&(n=v?n.replace(\"italic \",\"italic bold \"):\"bold \"+n),p&&!d&&(n=n.replace(\"bold \",\"\"))}if(!0===o.italics){var v=t.indexOf(\"i|\")>-1,y=r.indexOf(\"i|\")>-1;!v&&y&&(n=\"italic \"+n),v&&!y&&(n=n.replace(\"italic \",\"\"))}e.font=n}for(h=0;h\",a=\"\",o=i.length,s=a.length,l=\"+\"===e[0]||\"-\"===e[0],c=0,u=-s;c>-1&&-1!==(c=r.indexOf(i,c))&&-1!==(u=r.indexOf(a,c+o))&&!(u<=c);){for(var f=c;f=u)n[f]=null,r=r.substr(0,f)+\" \"+r.substr(f+1);else if(null!==n[f]){var h=n[f].indexOf(e[0]);-1===h?n[f]+=e:l&&(n[f]=n[f].substr(0,h+1)+(1+parseInt(n[f][h+1]))+n[f].substr(h+2))}var p=c+o,d=r.substr(p,u-p).indexOf(i);c=-1!==d?d:u+s}return n}function u(t,e){var r=n(t,128);return e?a(r.cells,r.positions,.25):{edges:r.cells,positions:r.positions}}function f(t,e,r,n){var i=u(t,n),a=function(t,e,r){for(var n=e.textAlign||\"start\",i=e.textBaseline||\"alphabetic\",a=[1<<30,1<<30],o=[0,0],s=t.length,l=0;l=0?e[a]:i}))},has___:{value:y((function(e){var n=v(e);return n?r in n:t.indexOf(e)>=0}))},set___:{value:y((function(n,i){var a,o=v(n);return o?o[r]=i:(a=t.indexOf(n))>=0?e[a]=i:(a=t.length,e[a]=i,t[a]=n),this}))},delete___:{value:y((function(n){var i,a,o=v(n);return o?r in o&&delete o[r]:!((i=t.indexOf(n))<0)&&(a=t.length-1,t[i]=void 0,e[i]=e[a],t[i]=t[a],t.length=a,e.length=a,!0)}))}})};d.prototype=Object.create(Object.prototype,{get:{value:function(t,e){return this.get___(t,e)},writable:!0,configurable:!0},has:{value:function(t){return this.has___(t)},writable:!0,configurable:!0},set:{value:function(t,e){return this.set___(t,e)},writable:!0,configurable:!0},delete:{value:function(t){return this.delete___(t)},writable:!0,configurable:!0}}),\"function\"==typeof r?function(){function n(){this instanceof d||x();var e,n=new r,i=void 0,a=!1;return e=t?function(t,e){return n.set(t,e),n.has(t)||(i||(i=new d),i.set(t,e)),this}:function(t,e){if(a)try{n.set(t,e)}catch(r){i||(i=new d),i.set___(t,e)}else n.set(t,e);return this},Object.create(d.prototype,{get___:{value:y((function(t,e){return i?n.has(t)?n.get(t):i.get___(t,e):n.get(t,e)}))},has___:{value:y((function(t){return n.has(t)||!!i&&i.has___(t)}))},set___:{value:y(e)},delete___:{value:y((function(t){var e=!!n.delete(t);return i&&i.delete___(t)||e}))},permitHostObjects___:{value:y((function(t){if(t!==m)throw new Error(\"bogus call to permitHostObjects___\");a=!0}))}})}t&&\"undefined\"!=typeof Proxy&&(Proxy=void 0),n.prototype=d.prototype,e.exports=n,Object.defineProperty(WeakMap.prototype,\"constructor\",{value:WeakMap,enumerable:!1,configurable:!0,writable:!0})}():(\"undefined\"!=typeof Proxy&&(Proxy=void 0),e.exports=d)}function m(t){t.permitHostObjects___&&t.permitHostObjects___(m)}function g(t){return!(\"weakmap:\"==t.substr(0,\"weakmap:\".length)&&\"___\"===t.substr(t.length-3))}function v(t){if(t!==Object(t))throw new TypeError(\"Not an object: \"+t);var e=t[l];if(e&&e.key===t)return e;if(s(t)){e={key:t};try{return o(t,l,{value:e,writable:!1,enumerable:!1,configurable:!1}),e}catch(t){return}}}function y(t){return t.prototype=null,Object.freeze(t)}function x(){h||\"undefined\"==typeof console||(h=!0,console.warn(\"WeakMap should be invoked as new WeakMap(), not WeakMap(). This will be an error in the future.\"))}}()},{}],314:[function(t,e,r){var n=t(\"./hidden-store.js\");e.exports=function(){var t={};return function(e){if((\"object\"!=typeof e||null===e)&&\"function\"!=typeof e)throw new Error(\"Weakmap-shim: Key must be object\");var r=e.valueOf(t);return r&&r.identity===t?r:n(e,t)}}},{\"./hidden-store.js\":315}],315:[function(t,e,r){e.exports=function(t,e){var r={identity:e},n=t.valueOf;return Object.defineProperty(t,\"valueOf\",{value:function(t){return t!==e?n.apply(this,arguments):r},writable:!0}),r}},{}],316:[function(t,e,r){var n=t(\"./create-store.js\");e.exports=function(){var t=n();return{get:function(e,r){var n=t(e);return n.hasOwnProperty(\"value\")?n.value:r},set:function(e,r){return t(e).value=r,this},has:function(e){return\"value\"in t(e)},delete:function(e){return delete t(e).value}}}},{\"./create-store.js\":314}],317:[function(t,e,r){\"use strict\";var n,i=function(){return function(t,e,r,n,i,a){var o=t[0],s=r[0],l=[0],c=s;n|=0;var u=0,f=s;for(u=0;u=0!=p>=0&&i.push(l[0]+.5+.5*(h+p)/(h-p)),n+=f,++l[0]}}};e.exports=(n={funcName:{funcName:\"zeroCrossings\"}.funcName},function(t){var e={};return function(r,n,i){var a=r.dtype,o=r.order,s=[a,o.join()].join(),l=e[s];return l||(e[s]=l=t([a,o])),l(r.shape.slice(0),r.data,r.stride,0|r.offset,n,i)}}(i.bind(void 0,n)))},{}],318:[function(t,e,r){\"use strict\";e.exports=function(t,e){var r=[];return e=+e||0,n(t.hi(t.shape[0]-1),r,e),r};var n=t(\"./lib/zc-core\")},{\"./lib/zc-core\":317}]},{},[6])(6)}))}).call(this)}).call(this,\"undefined\"!=typeof global?global:\"undefined\"!=typeof self?self:\"undefined\"!=typeof window?window:{})},{}]},{},[27])(27)}));
\n", "\n", "" ], @@ -1471,6 +1492,16 @@ "describe_run.artifact(\"violin\").show()" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Done!\n", + "\n", + "You've completed the first part - EDA.\n", + "Proceed to [Part 2](02-interactive-data-preparation.ipynb) to learn how to interactively build features for training models." + ] + }, { "cell_type": "code", "execution_count": null, @@ -1495,7 +1526,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.9.18" } }, "nbformat": 4, diff --git a/2-interactive-data-prep.ipynb b/02-interactive-data-preparation.ipynb similarity index 81% rename from 2-interactive-data-prep.ipynb rename to 02-interactive-data-preparation.ipynb index 1ce8004..6de886b 100644 --- a/2-interactive-data-prep.ipynb +++ b/02-interactive-data-preparation.ipynb @@ -49,7 +49,7 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 1, "metadata": {}, "outputs": [ { @@ -98,7 +98,7 @@ " es_transportation\n", " 26.92\n", " 0\n", - " 2024-01-29 21:14:16.495915000\n", + " 2024-06-11 12:40:11.640588000\n", " C1022153336\n", " M1823072687\n", " 33832bb8607545df97632a7ab02d69c4\n", @@ -113,7 +113,7 @@ " es_transportation\n", " 48.22\n", " 0\n", - " 2024-01-29 21:14:34.789540913\n", + " 2024-06-11 12:40:29.934213913\n", " C1006176917\n", " M348934600\n", " fadd829c49e74ffa86c8da3be75ada53\n", @@ -128,7 +128,7 @@ " es_transportation\n", " 17.56\n", " 0\n", - " 2024-01-29 21:14:39.896710939\n", + " 2024-06-11 12:40:35.041383939\n", " C1010936270\n", " M348934600\n", " 58d0422a50bc40c89d2b4977b2f1beea\n", @@ -144,9 +144,9 @@ "416998 131 3 M 28007 28007 es_transportation 17.56 \n", "\n", " fraud timestamp source target \\\n", - "274633 0 2024-01-29 21:14:16.495915000 C1022153336 M1823072687 \n", - "286902 0 2024-01-29 21:14:34.789540913 C1006176917 M348934600 \n", - "416998 0 2024-01-29 21:14:39.896710939 C1010936270 M348934600 \n", + "274633 0 2024-06-11 12:40:11.640588000 C1022153336 M1823072687 \n", + "286902 0 2024-06-11 12:40:29.934213913 C1006176917 M348934600 \n", + "416998 0 2024-06-11 12:40:35.041383939 C1010936270 M348934600 \n", "\n", " device \n", "274633 33832bb8607545df97632a7ab02d69c4 \n", @@ -154,7 +154,7 @@ "416998 58d0422a50bc40c89d2b4977b2f1beea " ] }, - "execution_count": 12, + "execution_count": 1, "metadata": {}, "output_type": "execute_result" } @@ -180,7 +180,7 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 2, "metadata": {}, "outputs": [ { @@ -191,7 +191,7 @@ " dtype='object')" ] }, - "execution_count": 13, + "execution_count": 2, "metadata": {}, "output_type": "execute_result" } @@ -209,7 +209,7 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 3, "metadata": {}, "outputs": [ { @@ -265,21 +265,21 @@ " 28007\n", " 26.92\n", " 0\n", - " 2024-01-29 21:14:16.495915000\n", + " 2024-06-11 12:40:11.640588000\n", " C1022153336\n", " M1823072687\n", " 33832bb8607545df97632a7ab02d69c4\n", " ...\n", - " 0\n", - " 0\n", - " 0\n", - " 0\n", - " 0\n", - " 1\n", - " 0\n", - " 0\n", - " 1\n", - " 0\n", + " False\n", + " False\n", + " False\n", + " False\n", + " False\n", + " True\n", + " False\n", + " False\n", + " True\n", + " False\n", " \n", " \n", " 286902\n", @@ -289,21 +289,21 @@ " 28007\n", " 48.22\n", " 0\n", - " 2024-01-29 21:14:34.789540913\n", + " 2024-06-11 12:40:29.934213913\n", " C1006176917\n", " M348934600\n", " fadd829c49e74ffa86c8da3be75ada53\n", " ...\n", - " 0\n", - " 0\n", - " 0\n", - " 0\n", - " 0\n", - " 1\n", - " 0\n", - " 0\n", - " 0\n", - " 1\n", + " False\n", + " False\n", + " False\n", + " False\n", + " False\n", + " True\n", + " False\n", + " False\n", + " False\n", + " True\n", " \n", " \n", " 416998\n", @@ -313,21 +313,21 @@ " 28007\n", " 17.56\n", " 0\n", - " 2024-01-29 21:14:39.896710939\n", + " 2024-06-11 12:40:35.041383939\n", " C1010936270\n", " M348934600\n", " 58d0422a50bc40c89d2b4977b2f1beea\n", " ...\n", - " 0\n", - " 0\n", - " 0\n", - " 0\n", - " 0\n", - " 1\n", - " 0\n", - " 0\n", - " 0\n", - " 1\n", + " False\n", + " False\n", + " False\n", + " False\n", + " False\n", + " True\n", + " False\n", + " False\n", + " False\n", + " True\n", " \n", " \n", " 334543\n", @@ -337,21 +337,21 @@ " 28007\n", " 4.50\n", " 0\n", - " 2024-01-29 21:14:52.189462118\n", + " 2024-06-11 12:40:47.334135118\n", " C1033736586\n", " M1823072687\n", " 30b269ae55984e5584f1dd5f642ac1a3\n", " ...\n", - " 0\n", - " 0\n", - " 0\n", - " 0\n", - " 0\n", - " 1\n", - " 0\n", - " 0\n", - " 1\n", - " 0\n", + " False\n", + " False\n", + " False\n", + " False\n", + " False\n", + " True\n", + " False\n", + " False\n", + " True\n", + " False\n", " \n", " \n", " 210647\n", @@ -361,21 +361,21 @@ " 28007\n", " 1.83\n", " 0\n", - " 2024-01-29 21:15:26.078544001\n", + " 2024-06-11 12:41:21.223217001\n", " C1019071188\n", " M348934600\n", " 97bee3503a984f59aa6139b59f933c0b\n", " ...\n", - " 0\n", - " 0\n", - " 0\n", - " 0\n", - " 0\n", - " 1\n", - " 0\n", - " 0\n", - " 0\n", - " 1\n", + " False\n", + " False\n", + " False\n", + " False\n", + " False\n", + " True\n", + " False\n", + " False\n", + " False\n", + " True\n", " \n", " \n", "\n", @@ -391,51 +391,51 @@ "210647 72 4 28007 28007 1.83 0 \n", "\n", " timestamp source target \\\n", - "274633 2024-01-29 21:14:16.495915000 C1022153336 M1823072687 \n", - "286902 2024-01-29 21:14:34.789540913 C1006176917 M348934600 \n", - "416998 2024-01-29 21:14:39.896710939 C1010936270 M348934600 \n", - "334543 2024-01-29 21:14:52.189462118 C1033736586 M1823072687 \n", - "210647 2024-01-29 21:15:26.078544001 C1019071188 M348934600 \n", + "274633 2024-06-11 12:40:11.640588000 C1022153336 M1823072687 \n", + "286902 2024-06-11 12:40:29.934213913 C1006176917 M348934600 \n", + "416998 2024-06-11 12:40:35.041383939 C1010936270 M348934600 \n", + "334543 2024-06-11 12:40:47.334135118 C1033736586 M1823072687 \n", + "210647 2024-06-11 12:41:21.223217001 C1019071188 M348934600 \n", "\n", " device ... category_es_hyper \\\n", - "274633 33832bb8607545df97632a7ab02d69c4 ... 0 \n", - "286902 fadd829c49e74ffa86c8da3be75ada53 ... 0 \n", - "416998 58d0422a50bc40c89d2b4977b2f1beea ... 0 \n", - "334543 30b269ae55984e5584f1dd5f642ac1a3 ... 0 \n", - "210647 97bee3503a984f59aa6139b59f933c0b ... 0 \n", + "274633 33832bb8607545df97632a7ab02d69c4 ... False \n", + "286902 fadd829c49e74ffa86c8da3be75ada53 ... False \n", + "416998 58d0422a50bc40c89d2b4977b2f1beea ... False \n", + "334543 30b269ae55984e5584f1dd5f642ac1a3 ... False \n", + "210647 97bee3503a984f59aa6139b59f933c0b ... False \n", "\n", " category_es_leisure category_es_otherservices \\\n", - "274633 0 0 \n", - "286902 0 0 \n", - "416998 0 0 \n", - "334543 0 0 \n", - "210647 0 0 \n", + "274633 False False \n", + "286902 False False \n", + "416998 False False \n", + "334543 False False \n", + "210647 False False \n", "\n", " category_es_sportsandtoys category_es_tech \\\n", - "274633 0 0 \n", - "286902 0 0 \n", - "416998 0 0 \n", - "334543 0 0 \n", - "210647 0 0 \n", + "274633 False False \n", + "286902 False False \n", + "416998 False False \n", + "334543 False False \n", + "210647 False False \n", "\n", " category_es_transportation category_es_travel \\\n", - "274633 1 0 \n", - "286902 1 0 \n", - "416998 1 0 \n", - "334543 1 0 \n", - "210647 1 0 \n", + "274633 True False \n", + "286902 True False \n", + "416998 True False \n", + "334543 True False \n", + "210647 True False \n", "\n", " category_es_wellnessandbeauty gender_F gender_M \n", - "274633 0 1 0 \n", - "286902 0 0 1 \n", - "416998 0 0 1 \n", - "334543 0 1 0 \n", - "210647 0 0 1 \n", + "274633 False True False \n", + "286902 False False True \n", + "416998 False False True \n", + "334543 False True False \n", + "210647 False False True \n", "\n", "[5 rows x 30 columns]" ] }, - "execution_count": 14, + "execution_count": 3, "metadata": {}, "output_type": "execute_result" } @@ -459,7 +459,7 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 4, "metadata": {}, "outputs": [], "source": [ @@ -475,7 +475,7 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": 5, "metadata": {}, "outputs": [ { @@ -555,10 +555,10 @@ " 28007\n", " 26.92\n", " 0\n", - " 2024-01-29 21:14:16.495915000\n", + " 2024-06-11 12:40:11.640588000\n", " M1823072687\n", " 33832bb8607545df97632a7ab02d69c4\n", - " 0\n", + " 1\n", " ...\n", " 1\n", " 1\n", @@ -579,10 +579,10 @@ " 28007\n", " 48.22\n", " 0\n", - " 2024-01-29 21:14:34.789540913\n", + " 2024-06-11 12:40:29.934213913\n", " M348934600\n", " fadd829c49e74ffa86c8da3be75ada53\n", - " 0\n", + " 1\n", " ...\n", " 4\n", " 0\n", @@ -603,10 +603,10 @@ " 28007\n", " 17.56\n", " 0\n", - " 2024-01-29 21:14:39.896710939\n", + " 2024-06-11 12:40:35.041383939\n", " M348934600\n", " 58d0422a50bc40c89d2b4977b2f1beea\n", - " 0\n", + " 1\n", " ...\n", " 4\n", " 0\n", @@ -627,10 +627,10 @@ " 28007\n", " 4.50\n", " 0\n", - " 2024-01-29 21:14:52.189462118\n", + " 2024-06-11 12:40:47.334135118\n", " M1823072687\n", " 30b269ae55984e5584f1dd5f642ac1a3\n", - " 0\n", + " 1\n", " ...\n", " 3\n", " 2\n", @@ -651,10 +651,10 @@ " 28007\n", " 1.83\n", " 0\n", - " 2024-01-29 21:15:26.078544001\n", + " 2024-06-11 12:41:21.223217001\n", " M348934600\n", " 97bee3503a984f59aa6139b59f933c0b\n", - " 0\n", + " 1\n", " ...\n", " 1\n", " 0\n", @@ -683,19 +683,19 @@ "\n", " timestamp target \\\n", "source \n", - "C1022153336 2024-01-29 21:14:16.495915000 M1823072687 \n", - "C1006176917 2024-01-29 21:14:34.789540913 M348934600 \n", - "C1010936270 2024-01-29 21:14:39.896710939 M348934600 \n", - "C1033736586 2024-01-29 21:14:52.189462118 M1823072687 \n", - "C1019071188 2024-01-29 21:15:26.078544001 M348934600 \n", + "C1022153336 2024-06-11 12:40:11.640588000 M1823072687 \n", + "C1006176917 2024-06-11 12:40:29.934213913 M348934600 \n", + "C1010936270 2024-06-11 12:40:35.041383939 M348934600 \n", + "C1033736586 2024-06-11 12:40:47.334135118 M1823072687 \n", + "C1019071188 2024-06-11 12:41:21.223217001 M348934600 \n", "\n", " device day_of_week ... \\\n", "source ... \n", - "C1022153336 33832bb8607545df97632a7ab02d69c4 0 ... \n", - "C1006176917 fadd829c49e74ffa86c8da3be75ada53 0 ... \n", - "C1010936270 58d0422a50bc40c89d2b4977b2f1beea 0 ... \n", - "C1033736586 30b269ae55984e5584f1dd5f642ac1a3 0 ... \n", - "C1019071188 97bee3503a984f59aa6139b59f933c0b 0 ... \n", + "C1022153336 33832bb8607545df97632a7ab02d69c4 1 ... \n", + "C1006176917 fadd829c49e74ffa86c8da3be75ada53 1 ... \n", + "C1010936270 58d0422a50bc40c89d2b4977b2f1beea 1 ... \n", + "C1033736586 30b269ae55984e5584f1dd5f642ac1a3 1 ... \n", + "C1019071188 97bee3503a984f59aa6139b59f933c0b 1 ... \n", "\n", " es_barsandrestaurants_sum_14D es_tech_sum_14D \\\n", "source \n", @@ -732,7 +732,7 @@ "[5 rows x 56 columns]" ] }, - "execution_count": 16, + "execution_count": 5, "metadata": {}, "output_type": "execute_result" } @@ -753,7 +753,7 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 6, "metadata": {}, "outputs": [ { @@ -768,26 +768,26 @@ "timestamp datetime64[ns]\n", "target object\n", "device object\n", - "day_of_week int64\n", - "hour int64\n", + "day_of_week int32\n", + "hour int32\n", "age_mapped object\n", - "category_es_barsandrestaurants uint8\n", - "category_es_contents uint8\n", - "category_es_fashion uint8\n", - "category_es_food uint8\n", - "category_es_health uint8\n", - "category_es_home uint8\n", - "category_es_hotelservices uint8\n", - "category_es_hyper uint8\n", - "category_es_leisure uint8\n", - "category_es_otherservices uint8\n", - "category_es_sportsandtoys uint8\n", - "category_es_tech uint8\n", - "category_es_transportation uint8\n", - "category_es_travel uint8\n", - "category_es_wellnessandbeauty uint8\n", - "gender_F uint8\n", - "gender_M uint8\n", + "category_es_barsandrestaurants bool\n", + "category_es_contents bool\n", + "category_es_fashion bool\n", + "category_es_food bool\n", + "category_es_health bool\n", + "category_es_home bool\n", + "category_es_hotelservices bool\n", + "category_es_hyper bool\n", + "category_es_leisure bool\n", + "category_es_otherservices bool\n", + "category_es_sportsandtoys bool\n", + "category_es_tech bool\n", + "category_es_transportation bool\n", + "category_es_travel bool\n", + "category_es_wellnessandbeauty bool\n", + "gender_F bool\n", + "gender_M bool\n", "amount_mean_2H float64\n", "amount_sum_2H float64\n", "amount_count_2H int64\n", @@ -800,25 +800,25 @@ "amount_sum_24H float64\n", "amount_count_24H int64\n", "amount_max_24H float64\n", - "es_transportation_sum_14D uint8\n", - "es_health_sum_14D uint8\n", - "es_otherservices_sum_14D uint8\n", - "es_food_sum_14D uint8\n", - "es_hotelservices_sum_14D uint8\n", - "es_barsandrestaurants_sum_14D uint8\n", - "es_tech_sum_14D uint8\n", - "es_sportsandtoys_sum_14D uint8\n", - "es_wellnessandbeauty_sum_14D uint8\n", - "es_hyper_sum_14D uint8\n", - "es_fashion_sum_14D uint8\n", - "es_home_sum_14D uint8\n", - "es_contents_sum_14D uint8\n", - "es_travel_sum_14D uint8\n", - "es_leisure_sum_14D uint8\n", + "es_transportation_sum_14D int64\n", + "es_health_sum_14D int64\n", + "es_otherservices_sum_14D int64\n", + "es_food_sum_14D int64\n", + "es_hotelservices_sum_14D int64\n", + "es_barsandrestaurants_sum_14D int64\n", + "es_tech_sum_14D int64\n", + "es_sportsandtoys_sum_14D int64\n", + "es_wellnessandbeauty_sum_14D int64\n", + "es_hyper_sum_14D int64\n", + "es_fashion_sum_14D int64\n", + "es_home_sum_14D int64\n", + "es_contents_sum_14D int64\n", + "es_travel_sum_14D int64\n", + "es_leisure_sum_14D int64\n", "dtype: object" ] }, - "execution_count": 17, + "execution_count": 6, "metadata": {}, "output_type": "execute_result" } @@ -850,7 +850,7 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": 7, "metadata": {}, "outputs": [ { @@ -884,19 +884,19 @@ " 45553\n", " C137986193\n", " password_change\n", - " 2024-01-29 21:14:17.160985000\n", + " 2024-06-11 12:40:13.215172000\n", " \n", " \n", " 24134\n", " C1940951230\n", " details_change\n", - " 2024-01-29 21:14:18.209167091\n", + " 2024-06-11 12:40:14.263354091\n", " \n", " \n", " 64444\n", " C247537602\n", " login\n", - " 2024-01-29 21:14:19.863950103\n", + " 2024-06-11 12:40:15.918137103\n", " \n", " \n", "\n", @@ -904,12 +904,12 @@ ], "text/plain": [ " source event timestamp\n", - "45553 C137986193 password_change 2024-01-29 21:14:17.160985000\n", - "24134 C1940951230 details_change 2024-01-29 21:14:18.209167091\n", - "64444 C247537602 login 2024-01-29 21:14:19.863950103" + "45553 C137986193 password_change 2024-06-11 12:40:13.215172000\n", + "24134 C1940951230 details_change 2024-06-11 12:40:14.263354091\n", + "64444 C247537602 login 2024-06-11 12:40:15.918137103" ] }, - "execution_count": 18, + "execution_count": 7, "metadata": {}, "output_type": "execute_result" } @@ -928,7 +928,7 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": 8, "metadata": {}, "outputs": [ { @@ -968,38 +968,38 @@ " \n", " \n", " C137986193\n", - " 2024-01-29 21:14:17.160985000\n", - " 0\n", - " 0\n", - " 1\n", + " 2024-06-11 12:40:13.215172000\n", + " False\n", + " False\n", + " True\n", " \n", " \n", " C1940951230\n", - " 2024-01-29 21:14:18.209167091\n", - " 1\n", - " 0\n", - " 0\n", + " 2024-06-11 12:40:14.263354091\n", + " True\n", + " False\n", + " False\n", " \n", " \n", " C247537602\n", - " 2024-01-29 21:14:19.863950103\n", - " 0\n", - " 1\n", - " 0\n", + " 2024-06-11 12:40:15.918137103\n", + " False\n", + " True\n", + " False\n", " \n", " \n", " C470079617\n", - " 2024-01-29 21:14:21.154399428\n", - " 0\n", - " 0\n", - " 1\n", + " 2024-06-11 12:40:17.208586428\n", + " False\n", + " False\n", + " True\n", " \n", " \n", " C1142118359\n", - " 2024-01-29 21:14:21.944691830\n", - " 0\n", - " 1\n", - " 0\n", + " 2024-06-11 12:40:17.998878830\n", + " False\n", + " True\n", + " False\n", " \n", " \n", "\n", @@ -1008,22 +1008,22 @@ "text/plain": [ " timestamp event_details_change event_login \\\n", "source \n", - "C137986193 2024-01-29 21:14:17.160985000 0 0 \n", - "C1940951230 2024-01-29 21:14:18.209167091 1 0 \n", - "C247537602 2024-01-29 21:14:19.863950103 0 1 \n", - "C470079617 2024-01-29 21:14:21.154399428 0 0 \n", - "C1142118359 2024-01-29 21:14:21.944691830 0 1 \n", + "C137986193 2024-06-11 12:40:13.215172000 False False \n", + "C1940951230 2024-06-11 12:40:14.263354091 True False \n", + "C247537602 2024-06-11 12:40:15.918137103 False True \n", + "C470079617 2024-06-11 12:40:17.208586428 False False \n", + "C1142118359 2024-06-11 12:40:17.998878830 False True \n", "\n", " event_password_change \n", "source \n", - "C137986193 1 \n", - "C1940951230 0 \n", - "C247537602 0 \n", - "C470079617 1 \n", - "C1142118359 0 " + "C137986193 True \n", + "C1940951230 False \n", + "C247537602 False \n", + "C470079617 True \n", + "C1142118359 False " ] }, - "execution_count": 19, + "execution_count": 8, "metadata": {}, "output_type": "execute_result" } @@ -1059,21 +1059,21 @@ }, { "cell_type": "code", - "execution_count": 20, + "execution_count": 9, "metadata": {}, "outputs": [], "source": [ "def create_labels(df):\n", " labels = df[['fraud','timestamp']].copy()\n", " labels = labels.rename(columns={\"fraud\": \"label\"})\n", - " labels['timestamp'] = labels['timestamp'].astype(\"datetime64[ms]\")\n", + " labels['timestamp'] = labels['timestamp'].astype(\"datetime64[ns]\")\n", " labels['label'] = labels['label'].astype(int)\n", " return labels" ] }, { "cell_type": "code", - "execution_count": 21, + "execution_count": 10, "metadata": {}, "outputs": [ { @@ -1110,43 +1110,43 @@ " \n", " C1022153336\n", " 0\n", - " 2024-01-29 21:14:16.495\n", + " 2024-06-11 12:40:11.640588000\n", " \n", " \n", " C1006176917\n", " 0\n", - " 2024-01-29 21:14:34.789\n", + " 2024-06-11 12:40:29.934213913\n", " \n", " \n", " C1010936270\n", " 0\n", - " 2024-01-29 21:14:39.896\n", + " 2024-06-11 12:40:35.041383939\n", " \n", " \n", " C1033736586\n", " 0\n", - " 2024-01-29 21:14:52.189\n", + " 2024-06-11 12:40:47.334135118\n", " \n", " \n", " C1019071188\n", " 0\n", - " 2024-01-29 21:15:26.078\n", + " 2024-06-11 12:41:21.223217001\n", " \n", " \n", "\n", "" ], "text/plain": [ - " label timestamp\n", - "source \n", - "C1022153336 0 2024-01-29 21:14:16.495\n", - "C1006176917 0 2024-01-29 21:14:34.789\n", - "C1010936270 0 2024-01-29 21:14:39.896\n", - "C1033736586 0 2024-01-29 21:14:52.189\n", - "C1019071188 0 2024-01-29 21:15:26.078" + " label timestamp\n", + "source \n", + "C1022153336 0 2024-06-11 12:40:11.640588000\n", + "C1006176917 0 2024-06-11 12:40:29.934213913\n", + "C1010936270 0 2024-06-11 12:40:35.041383939\n", + "C1033736586 0 2024-06-11 12:40:47.334135118\n", + "C1019071188 0 2024-06-11 12:41:21.223217001" ] }, - "execution_count": 21, + "execution_count": 10, "metadata": {}, "output_type": "execute_result" } @@ -1166,7 +1166,7 @@ }, { "cell_type": "code", - "execution_count": 25, + "execution_count": 11, "metadata": {}, "outputs": [ { @@ -1587,13 +1587,16 @@ " /* fitted */\n", " background-color: var(--sklearn-color-fitted-level-3);\n", "}\n", - "
RandomForestClassifier(max_depth=100, min_samples_split=10, n_estimators=50)
In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook.
On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.
" + "
RandomForestClassifier(max_depth=10, min_samples_leaf=2, min_samples_split=5,\n",
+       "                       n_estimators=50)
In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook.
On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.
" ], "text/plain": [ - "RandomForestClassifier(max_depth=100, min_samples_split=10, n_estimators=50)" + "RandomForestClassifier(max_depth=10, min_samples_leaf=2, min_samples_split=5,\n", + " n_estimators=50)" ] }, - "execution_count": 25, + "execution_count": 11, "metadata": {}, "output_type": "execute_result" } @@ -1609,6 +1612,16 @@ "rf_best" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Done!\n", + "\n", + "You've completed the second part - interactive data preparation.\n", + "Proceed to [Part 3](03-ingest-with-feature-store.ipynb) to learn how to build data ingestion services with the Feature Store." + ] + }, { "cell_type": "code", "execution_count": null, @@ -1633,7 +1646,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.9.18" }, "toc-showtags": false }, diff --git a/3-ingest-with-feature-store.ipynb b/03-ingest-with-feature-store.ipynb similarity index 84% rename from 3-ingest-with-feature-store.ipynb rename to 03-ingest-with-feature-store.ipynb index 26abb4e..fbcfdab 100644 --- a/3-ingest-with-feature-store.ipynb +++ b/03-ingest-with-feature-store.ipynb @@ -35,7 +35,7 @@ }, { "cell_type": "code", - "execution_count": 26, + "execution_count": 1, "metadata": {}, "outputs": [], "source": [ @@ -64,7 +64,7 @@ }, { "cell_type": "code", - "execution_count": 27, + "execution_count": 2, "metadata": {}, "outputs": [ { @@ -113,7 +113,7 @@ " es_transportation\n", " 26.92\n", " 0\n", - " 2024-01-29 21:18:28.042312000\n", + " 2024-06-11 12:45:39.562226000\n", " C1022153336\n", " M1823072687\n", " 33832bb8607545df97632a7ab02d69c4\n", @@ -128,7 +128,7 @@ " es_transportation\n", " 48.22\n", " 0\n", - " 2024-01-29 21:18:46.335937913\n", + " 2024-06-11 12:45:57.855851913\n", " C1006176917\n", " M348934600\n", " fadd829c49e74ffa86c8da3be75ada53\n", @@ -143,7 +143,7 @@ " es_transportation\n", " 17.56\n", " 0\n", - " 2024-01-29 21:18:51.443107939\n", + " 2024-06-11 12:46:02.963021939\n", " C1010936270\n", " M348934600\n", " 58d0422a50bc40c89d2b4977b2f1beea\n", @@ -159,9 +159,9 @@ "416998 131 3 M 28007 28007 es_transportation 17.56 \n", "\n", " fraud timestamp source target \\\n", - "274633 0 2024-01-29 21:18:28.042312000 C1022153336 M1823072687 \n", - "286902 0 2024-01-29 21:18:46.335937913 C1006176917 M348934600 \n", - "416998 0 2024-01-29 21:18:51.443107939 C1010936270 M348934600 \n", + "274633 0 2024-06-11 12:45:39.562226000 C1022153336 M1823072687 \n", + "286902 0 2024-06-11 12:45:57.855851913 C1006176917 M348934600 \n", + "416998 0 2024-06-11 12:46:02.963021939 C1010936270 M348934600 \n", "\n", " device \n", "274633 33832bb8607545df97632a7ab02d69c4 \n", @@ -169,7 +169,7 @@ "416998 58d0422a50bc40c89d2b4977b2f1beea " ] }, - "execution_count": 27, + "execution_count": 2, "metadata": {}, "output_type": "execute_result" } @@ -179,7 +179,7 @@ "from src.date_adjust import adjust_data_timespan\n", "\n", "# Fetch the transactions dataset from the server\n", - "transactions_data = pd.read_csv('https://s3.wasabisys.com/iguazio/data/fraud-demo-mlrun-fs-docs/data.csv', parse_dates=['timestamp'])\n", + "transactions_data = pd.read_csv(mlrun.get_sample_path(\"data/fraud-demo-mlrun-fs-docs/data.csv\"), parse_dates=['timestamp'])\n", "\n", "# use only first 10k\n", "transactions_data = transactions_data.sort_values(by='source', axis=0)[:10000]\n", @@ -205,7 +205,7 @@ }, { "cell_type": "code", - "execution_count": 28, + "execution_count": 3, "metadata": {}, "outputs": [], "source": [ @@ -216,7 +216,7 @@ }, { "cell_type": "code", - "execution_count": 29, + "execution_count": 4, "metadata": {}, "outputs": [], "source": [ @@ -238,7 +238,7 @@ }, { "cell_type": "code", - "execution_count": 30, + "execution_count": 5, "metadata": {}, "outputs": [], "source": [ @@ -286,7 +286,7 @@ }, { "cell_type": "code", - "execution_count": 31, + "execution_count": 6, "metadata": {}, "outputs": [ { @@ -387,10 +387,10 @@ "\n" ], "text/plain": [ - "" + "" ] }, - "execution_count": 31, + "execution_count": 6, "metadata": {}, "output_type": "execute_result" } @@ -402,9 +402,16 @@ }, { "cell_type": "code", - "execution_count": 32, + "execution_count": 7, "metadata": {}, "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "Call to deprecated function (or staticmethod) preview. ('preview' will be removed in 1.8.0, use 'FeatureSet.preview()' instead) -- Deprecated since version 1.6.0.\n" + ] + }, { "data": { "text/html": [ @@ -492,11 +499,11 @@ " 0\n", " 26.92\n", " 0\n", - " 2024-01-29 21:18:28.042312000\n", + " 2024-06-11 12:45:39.562226000\n", " M1823072687\n", " 33832bb8607545df97632a7ab02d69c4\n", - " 21\n", - " 0\n", + " 12\n", + " 1\n", " \n", " \n", " C1006176917\n", @@ -516,11 +523,11 @@ " 0\n", " 48.22\n", " 0\n", - " 2024-01-29 21:18:46.335937913\n", + " 2024-06-11 12:45:57.855851913\n", " M348934600\n", " fadd829c49e74ffa86c8da3be75ada53\n", - " 21\n", - " 0\n", + " 12\n", + " 1\n", " \n", " \n", " C1010936270\n", @@ -540,11 +547,11 @@ " 0\n", " 17.56\n", " 0\n", - " 2024-01-29 21:18:51.443107939\n", + " 2024-06-11 12:46:02.963021939\n", " M348934600\n", " 58d0422a50bc40c89d2b4977b2f1beea\n", - " 21\n", - " 0\n", + " 12\n", + " 1\n", " \n", " \n", " C1033736586\n", @@ -564,11 +571,11 @@ " 0\n", " 4.50\n", " 0\n", - " 2024-01-29 21:19:03.735859118\n", + " 2024-06-11 12:46:15.255773118\n", " M1823072687\n", " 30b269ae55984e5584f1dd5f642ac1a3\n", - " 21\n", - " 0\n", + " 12\n", + " 1\n", " \n", " \n", " C1019071188\n", @@ -588,11 +595,11 @@ " 0\n", " 1.83\n", " 0\n", - " 2024-01-29 21:19:37.624941001\n", + " 2024-06-11 12:46:49.144855001\n", " M348934600\n", " 97bee3503a984f59aa6139b59f933c0b\n", - " 21\n", - " 0\n", + " 12\n", + " 1\n", " \n", " \n", " ...\n", @@ -620,38 +627,38 @@ " \n", " \n", " C1032715879\n", - " 82.91\n", - " 719.55\n", - " 1681.25\n", - " 3.0\n", - " 25.0\n", - " 56.0\n", + " 118.62\n", + " 805.10\n", + " 1730.23\n", + " 4.0\n", + " 27.0\n", + " 58.0\n", " 54.55\n", " 70.47\n", " 85.97\n", - " 27.636667\n", + " 29.655000\n", " ...\n", " 0\n", " 0\n", " 0\n", " 26.00\n", " 0\n", - " 2024-01-31 21:17:25.956165884\n", + " 2024-06-13 12:44:37.476079884\n", " M348934600\n", " dcd0943b34254126a2d79d3ac652f268\n", - " 21\n", - " 2\n", + " 12\n", + " 3\n", " \n", " \n", " C1005806982\n", " 31.14\n", - " 31.14\n", + " 150.64\n", " 330.61\n", " 1.0\n", - " 1.0\n", + " 2.0\n", " 5.0\n", " 31.14\n", - " 31.14\n", + " 119.50\n", " 119.50\n", " 31.140000\n", " ...\n", @@ -660,44 +667,44 @@ " 0\n", " 31.14\n", " 0\n", - " 2024-01-31 21:17:30.320099022\n", + " 2024-06-13 12:44:41.840013022\n", " M1741626453\n", " c186fb979a77422fa06296c3ff2813f6\n", - " 21\n", - " 2\n", + " 12\n", + " 3\n", " \n", " \n", " C1018783569\n", - " 283.71\n", - " 1005.10\n", - " 1927.70\n", - " 3.0\n", - " 23.0\n", - " 58.0\n", + " 397.43\n", + " 1076.37\n", + " 1968.00\n", + " 6.0\n", + " 25.0\n", + " 59.0\n", " 218.48\n", " 218.48\n", " 218.48\n", - " 94.570000\n", + " 66.238333\n", " ...\n", " 0\n", " 0\n", " 0\n", " 218.48\n", " 0\n", - " 2024-01-31 21:17:57.702622602\n", + " 2024-06-13 12:45:09.222536602\n", " M1053599405\n", " 73bdcf0627aa4cc5b882f397cf0d1177\n", - " 21\n", - " 2\n", + " 12\n", + " 3\n", " \n", " \n", " C1014847580\n", " 118.22\n", " 935.26\n", - " 2062.69\n", + " 2082.60\n", " 5.0\n", " 31.0\n", - " 68.0\n", + " 69.0\n", " 34.93\n", " 79.16\n", " 89.85\n", @@ -708,35 +715,35 @@ " 0\n", " 34.93\n", " 0\n", - " 2024-01-31 21:18:04.684877958\n", + " 2024-06-13 12:45:16.204791958\n", " M1823072687\n", " 1b216268a9bd4937912c49d16adb5b67\n", - " 21\n", - " 2\n", + " 12\n", + " 3\n", " \n", " \n", " C1023803355\n", - " 189.08\n", - " 1099.98\n", + " 237.95\n", + " 1259.07\n", " 2451.98\n", - " 3.0\n", - " 35.0\n", + " 5.0\n", + " 37.0\n", " 72.0\n", " 77.76\n", - " 77.76\n", " 95.71\n", - " 63.026667\n", + " 95.71\n", + " 47.590000\n", " ...\n", " 0\n", " 0\n", " 0\n", " 35.65\n", " 0\n", - " 2024-01-31 21:18:28.042312000\n", + " 2024-06-13 12:45:39.562226000\n", " M348934600\n", " e2f1b14f73014143a94f7d9505638134\n", - " 21\n", - " 2\n", + " 12\n", + " 3\n", " \n", " \n", "\n", @@ -752,11 +759,11 @@ "C1033736586 4.50 4.50 4.50 1.0 \n", "C1019071188 1.83 1.83 1.83 1.0 \n", "... ... ... ... ... \n", - "C1032715879 82.91 719.55 1681.25 3.0 \n", - "C1005806982 31.14 31.14 330.61 1.0 \n", - "C1018783569 283.71 1005.10 1927.70 3.0 \n", - "C1014847580 118.22 935.26 2062.69 5.0 \n", - "C1023803355 189.08 1099.98 2451.98 3.0 \n", + "C1032715879 118.62 805.10 1730.23 4.0 \n", + "C1005806982 31.14 150.64 330.61 1.0 \n", + "C1018783569 397.43 1076.37 1968.00 6.0 \n", + "C1014847580 118.22 935.26 2082.60 5.0 \n", + "C1023803355 237.95 1259.07 2451.98 5.0 \n", "\n", " amount_count_12h amount_count_24h amount_max_2h \\\n", "source \n", @@ -766,11 +773,11 @@ "C1033736586 1.0 1.0 4.50 \n", "C1019071188 1.0 1.0 1.83 \n", "... ... ... ... \n", - "C1032715879 25.0 56.0 54.55 \n", - "C1005806982 1.0 5.0 31.14 \n", - "C1018783569 23.0 58.0 218.48 \n", - "C1014847580 31.0 68.0 34.93 \n", - "C1023803355 35.0 72.0 77.76 \n", + "C1032715879 27.0 58.0 54.55 \n", + "C1005806982 2.0 5.0 31.14 \n", + "C1018783569 25.0 59.0 218.48 \n", + "C1014847580 31.0 69.0 34.93 \n", + "C1023803355 37.0 72.0 77.76 \n", "\n", " amount_max_12h amount_max_24h amount_avg_2h ... \\\n", "source ... \n", @@ -780,11 +787,11 @@ "C1033736586 4.50 4.50 4.500000 ... \n", "C1019071188 1.83 1.83 1.830000 ... \n", "... ... ... ... ... \n", - "C1032715879 70.47 85.97 27.636667 ... \n", - "C1005806982 31.14 119.50 31.140000 ... \n", - "C1018783569 218.48 218.48 94.570000 ... \n", + "C1032715879 70.47 85.97 29.655000 ... \n", + "C1005806982 119.50 119.50 31.140000 ... \n", + "C1018783569 218.48 218.48 66.238333 ... \n", "C1014847580 79.16 89.85 23.644000 ... \n", - "C1023803355 77.76 95.71 63.026667 ... \n", + "C1023803355 95.71 95.71 47.590000 ... \n", "\n", " category_es_contents category_es_travel category_es_leisure \\\n", "source \n", @@ -802,50 +809,50 @@ "\n", " amount fraud timestamp target \\\n", "source \n", - "C1022153336 26.92 0 2024-01-29 21:18:28.042312000 M1823072687 \n", - "C1006176917 48.22 0 2024-01-29 21:18:46.335937913 M348934600 \n", - "C1010936270 17.56 0 2024-01-29 21:18:51.443107939 M348934600 \n", - "C1033736586 4.50 0 2024-01-29 21:19:03.735859118 M1823072687 \n", - "C1019071188 1.83 0 2024-01-29 21:19:37.624941001 M348934600 \n", + "C1022153336 26.92 0 2024-06-11 12:45:39.562226000 M1823072687 \n", + "C1006176917 48.22 0 2024-06-11 12:45:57.855851913 M348934600 \n", + "C1010936270 17.56 0 2024-06-11 12:46:02.963021939 M348934600 \n", + "C1033736586 4.50 0 2024-06-11 12:46:15.255773118 M1823072687 \n", + "C1019071188 1.83 0 2024-06-11 12:46:49.144855001 M348934600 \n", "... ... ... ... ... \n", - "C1032715879 26.00 0 2024-01-31 21:17:25.956165884 M348934600 \n", - "C1005806982 31.14 0 2024-01-31 21:17:30.320099022 M1741626453 \n", - "C1018783569 218.48 0 2024-01-31 21:17:57.702622602 M1053599405 \n", - "C1014847580 34.93 0 2024-01-31 21:18:04.684877958 M1823072687 \n", - "C1023803355 35.65 0 2024-01-31 21:18:28.042312000 M348934600 \n", + "C1032715879 26.00 0 2024-06-13 12:44:37.476079884 M348934600 \n", + "C1005806982 31.14 0 2024-06-13 12:44:41.840013022 M1741626453 \n", + "C1018783569 218.48 0 2024-06-13 12:45:09.222536602 M1053599405 \n", + "C1014847580 34.93 0 2024-06-13 12:45:16.204791958 M1823072687 \n", + "C1023803355 35.65 0 2024-06-13 12:45:39.562226000 M348934600 \n", "\n", " device timestamp_hour \\\n", "source \n", - "C1022153336 33832bb8607545df97632a7ab02d69c4 21 \n", - "C1006176917 fadd829c49e74ffa86c8da3be75ada53 21 \n", - "C1010936270 58d0422a50bc40c89d2b4977b2f1beea 21 \n", - "C1033736586 30b269ae55984e5584f1dd5f642ac1a3 21 \n", - "C1019071188 97bee3503a984f59aa6139b59f933c0b 21 \n", + "C1022153336 33832bb8607545df97632a7ab02d69c4 12 \n", + "C1006176917 fadd829c49e74ffa86c8da3be75ada53 12 \n", + "C1010936270 58d0422a50bc40c89d2b4977b2f1beea 12 \n", + "C1033736586 30b269ae55984e5584f1dd5f642ac1a3 12 \n", + "C1019071188 97bee3503a984f59aa6139b59f933c0b 12 \n", "... ... ... \n", - "C1032715879 dcd0943b34254126a2d79d3ac652f268 21 \n", - "C1005806982 c186fb979a77422fa06296c3ff2813f6 21 \n", - "C1018783569 73bdcf0627aa4cc5b882f397cf0d1177 21 \n", - "C1014847580 1b216268a9bd4937912c49d16adb5b67 21 \n", - "C1023803355 e2f1b14f73014143a94f7d9505638134 21 \n", + "C1032715879 dcd0943b34254126a2d79d3ac652f268 12 \n", + "C1005806982 c186fb979a77422fa06296c3ff2813f6 12 \n", + "C1018783569 73bdcf0627aa4cc5b882f397cf0d1177 12 \n", + "C1014847580 1b216268a9bd4937912c49d16adb5b67 12 \n", + "C1023803355 e2f1b14f73014143a94f7d9505638134 12 \n", "\n", " timestamp_day_of_week \n", "source \n", - "C1022153336 0 \n", - "C1006176917 0 \n", - "C1010936270 0 \n", - "C1033736586 0 \n", - "C1019071188 0 \n", + "C1022153336 1 \n", + "C1006176917 1 \n", + "C1010936270 1 \n", + "C1033736586 1 \n", + "C1019071188 1 \n", "... ... \n", - "C1032715879 2 \n", - "C1005806982 2 \n", - "C1018783569 2 \n", - "C1014847580 2 \n", - "C1023803355 2 \n", + "C1032715879 3 \n", + "C1005806982 3 \n", + "C1018783569 3 \n", + "C1014847580 3 \n", + "C1023803355 3 \n", "\n", "[10000 rows x 56 columns]" ] }, - "execution_count": 32, + "execution_count": 7, "metadata": {}, "output_type": "execute_result" } @@ -893,7 +900,7 @@ }, { "cell_type": "code", - "execution_count": 33, + "execution_count": 8, "metadata": {}, "outputs": [ { @@ -927,19 +934,19 @@ " 45553\n", " C137986193\n", " password_change\n", - " 2024-01-29 21:18:33.294708000\n", + " 2024-06-11 12:45:48.776557000\n", " \n", " \n", " 24134\n", " C1940951230\n", " details_change\n", - " 2024-01-29 21:18:34.342890091\n", + " 2024-06-11 12:45:49.824739091\n", " \n", " \n", " 64444\n", " C247537602\n", " login\n", - " 2024-01-29 21:18:35.997673103\n", + " 2024-06-11 12:45:51.479522103\n", " \n", " \n", "\n", @@ -947,12 +954,12 @@ ], "text/plain": [ " source event timestamp\n", - "45553 C137986193 password_change 2024-01-29 21:18:33.294708000\n", - "24134 C1940951230 details_change 2024-01-29 21:18:34.342890091\n", - "64444 C247537602 login 2024-01-29 21:18:35.997673103" + "45553 C137986193 password_change 2024-06-11 12:45:48.776557000\n", + "24134 C1940951230 details_change 2024-06-11 12:45:49.824739091\n", + "64444 C247537602 login 2024-06-11 12:45:51.479522103" ] }, - "execution_count": 33, + "execution_count": 8, "metadata": {}, "output_type": "execute_result" } @@ -971,7 +978,7 @@ }, { "cell_type": "code", - "execution_count": 34, + "execution_count": 9, "metadata": {}, "outputs": [], "source": [ @@ -983,7 +990,7 @@ }, { "cell_type": "code", - "execution_count": 35, + "execution_count": 10, "metadata": {}, "outputs": [ { @@ -1048,10 +1055,10 @@ "\n" ], "text/plain": [ - "" + "" ] }, - "execution_count": 35, + "execution_count": 10, "metadata": {}, "output_type": "execute_result" } @@ -1072,9 +1079,16 @@ }, { "cell_type": "code", - "execution_count": 36, + "execution_count": 11, "metadata": {}, "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "Call to deprecated function (or staticmethod) preview. ('preview' will be removed in 1.8.0, use 'FeatureSet.preview()' instead) -- Deprecated since version 1.6.0.\n" + ] + }, { "data": { "text/html": [ @@ -1115,35 +1129,35 @@ " 1\n", " 0\n", " 0\n", - " 2024-01-29 21:18:33.294708000\n", + " 2024-06-11 12:45:48.776557000\n", " \n", " \n", " C1940951230\n", " 0\n", " 1\n", " 0\n", - " 2024-01-29 21:18:34.342890091\n", + " 2024-06-11 12:45:49.824739091\n", " \n", " \n", " C247537602\n", " 0\n", " 0\n", " 1\n", - " 2024-01-29 21:18:35.997673103\n", + " 2024-06-11 12:45:51.479522103\n", " \n", " \n", " C470079617\n", " 1\n", " 0\n", " 0\n", - " 2024-01-29 21:18:37.288122428\n", + " 2024-06-11 12:45:52.769971428\n", " \n", " \n", " C1142118359\n", " 0\n", " 0\n", " 1\n", - " 2024-01-29 21:18:38.078414830\n", + " 2024-06-11 12:45:53.560263830\n", " \n", " \n", " ...\n", @@ -1157,35 +1171,35 @@ " 0\n", " 0\n", " 1\n", - " 2024-01-31 21:18:23.844257776\n", + " 2024-06-13 12:45:39.326106776\n", " \n", " \n", " C1790426542\n", " 1\n", " 0\n", " 0\n", - " 2024-01-31 21:18:28.915461974\n", + " 2024-06-13 12:45:44.397310974\n", " \n", " \n", " C662187574\n", " 0\n", " 0\n", " 1\n", - " 2024-01-31 21:18:30.336116178\n", + " 2024-06-13 12:45:45.817965178\n", " \n", " \n", " C1461183154\n", " 0\n", " 0\n", " 1\n", - " 2024-01-31 21:18:31.034256428\n", + " 2024-06-13 12:45:46.516105428\n", " \n", " \n", " C129566217\n", " 0\n", " 0\n", " 1\n", - " 2024-01-31 21:18:33.294708000\n", + " 2024-06-13 12:45:48.776557000\n", " \n", " \n", "\n", @@ -1209,22 +1223,22 @@ "\n", " timestamp \n", "source \n", - "C137986193 2024-01-29 21:18:33.294708000 \n", - "C1940951230 2024-01-29 21:18:34.342890091 \n", - "C247537602 2024-01-29 21:18:35.997673103 \n", - "C470079617 2024-01-29 21:18:37.288122428 \n", - "C1142118359 2024-01-29 21:18:38.078414830 \n", + "C137986193 2024-06-11 12:45:48.776557000 \n", + "C1940951230 2024-06-11 12:45:49.824739091 \n", + "C247537602 2024-06-11 12:45:51.479522103 \n", + "C470079617 2024-06-11 12:45:52.769971428 \n", + "C1142118359 2024-06-11 12:45:53.560263830 \n", "... ... \n", - "C71938921 2024-01-31 21:18:23.844257776 \n", - "C1790426542 2024-01-31 21:18:28.915461974 \n", - "C662187574 2024-01-31 21:18:30.336116178 \n", - "C1461183154 2024-01-31 21:18:31.034256428 \n", - "C129566217 2024-01-31 21:18:33.294708000 \n", + "C71938921 2024-06-13 12:45:39.326106776 \n", + "C1790426542 2024-06-13 12:45:44.397310974 \n", + "C662187574 2024-06-13 12:45:45.817965178 \n", + "C1461183154 2024-06-13 12:45:46.516105428 \n", + "C129566217 2024-06-13 12:45:48.776557000 \n", "\n", "[82092 rows x 4 columns]" ] }, - "execution_count": 36, + "execution_count": 11, "metadata": {}, "output_type": "execute_result" } @@ -1256,7 +1270,7 @@ }, { "cell_type": "code", - "execution_count": 37, + "execution_count": 12, "metadata": {}, "outputs": [], "source": [ @@ -1270,7 +1284,7 @@ }, { "cell_type": "code", - "execution_count": 38, + "execution_count": 13, "metadata": {}, "outputs": [ { @@ -1323,10 +1337,10 @@ "\n" ], "text/plain": [ - "" + "" ] }, - "execution_count": 38, + "execution_count": 13, "metadata": {}, "output_type": "execute_result" } @@ -1355,9 +1369,16 @@ }, { "cell_type": "code", - "execution_count": 39, + "execution_count": 14, "metadata": {}, "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "Call to deprecated function (or staticmethod) preview. ('preview' will be removed in 1.8.0, use 'FeatureSet.preview()' instead) -- Deprecated since version 1.6.0.\n" + ] + }, { "data": { "text/html": [ @@ -1392,27 +1413,27 @@ " \n", " C1022153336\n", " 0\n", - " 2024-01-29 21:18:28.042\n", + " 2024-06-11 12:45:39.562\n", " \n", " \n", " C1006176917\n", " 0\n", - " 2024-01-29 21:18:46.335\n", + " 2024-06-11 12:45:57.855\n", " \n", " \n", " C1010936270\n", " 0\n", - " 2024-01-29 21:18:51.443\n", + " 2024-06-11 12:46:02.963\n", " \n", " \n", " C1033736586\n", " 0\n", - " 2024-01-29 21:19:03.735\n", + " 2024-06-11 12:46:15.255\n", " \n", " \n", " C1019071188\n", " 0\n", - " 2024-01-29 21:19:37.624\n", + " 2024-06-11 12:46:49.144\n", " \n", " \n", " ...\n", @@ -1422,27 +1443,27 @@ " \n", " C1032715879\n", " 0\n", - " 2024-01-31 21:17:25.956\n", + " 2024-06-13 12:44:37.476\n", " \n", " \n", " C1005806982\n", " 0\n", - " 2024-01-31 21:17:30.320\n", + " 2024-06-13 12:44:41.840\n", " \n", " \n", " C1018783569\n", " 0\n", - " 2024-01-31 21:17:57.702\n", + " 2024-06-13 12:45:09.222\n", " \n", " \n", " C1014847580\n", " 0\n", - " 2024-01-31 21:18:04.684\n", + " 2024-06-13 12:45:16.204\n", " \n", " \n", " C1023803355\n", " 0\n", - " 2024-01-31 21:18:28.042\n", + " 2024-06-13 12:45:39.562\n", " \n", " \n", "\n", @@ -1452,22 +1473,22 @@ "text/plain": [ " label timestamp\n", "source \n", - "C1022153336 0 2024-01-29 21:18:28.042\n", - "C1006176917 0 2024-01-29 21:18:46.335\n", - "C1010936270 0 2024-01-29 21:18:51.443\n", - "C1033736586 0 2024-01-29 21:19:03.735\n", - "C1019071188 0 2024-01-29 21:19:37.624\n", + "C1022153336 0 2024-06-11 12:45:39.562\n", + "C1006176917 0 2024-06-11 12:45:57.855\n", + "C1010936270 0 2024-06-11 12:46:02.963\n", + "C1033736586 0 2024-06-11 12:46:15.255\n", + "C1019071188 0 2024-06-11 12:46:49.144\n", "... ... ...\n", - "C1032715879 0 2024-01-31 21:17:25.956\n", - "C1005806982 0 2024-01-31 21:17:30.320\n", - "C1018783569 0 2024-01-31 21:17:57.702\n", - "C1014847580 0 2024-01-31 21:18:04.684\n", - "C1023803355 0 2024-01-31 21:18:28.042\n", + "C1032715879 0 2024-06-13 12:44:37.476\n", + "C1005806982 0 2024-06-13 12:44:41.840\n", + "C1018783569 0 2024-06-13 12:45:09.222\n", + "C1014847580 0 2024-06-13 12:45:16.204\n", + "C1023803355 0 2024-06-13 12:45:39.562\n", "\n", "[10000 rows x 2 columns]" ] }, - "execution_count": 39, + "execution_count": 14, "metadata": {}, "output_type": "execute_result" } @@ -1506,7 +1527,7 @@ }, { "cell_type": "code", - "execution_count": 40, + "execution_count": 15, "metadata": {}, "outputs": [], "source": [ @@ -1546,7 +1567,7 @@ }, { "cell_type": "code", - "execution_count": 41, + "execution_count": 16, "metadata": {}, "outputs": [], "source": [ @@ -1557,21 +1578,23 @@ }, { "cell_type": "code", - "execution_count": 42, + "execution_count": 17, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "> 2024-01-31 21:19:14,318 [info] Starting remote function deploy\n", - "2024-01-31 21:19:14 (info) Deploying function\n", - "2024-01-31 21:19:14 (info) Building\n", - "2024-01-31 21:19:15 (info) Staging files and preparing base images\n", - "2024-01-31 21:19:15 (info) Building processor image\n", - "2024-01-31 21:20:00 (info) Build complete\n", - "2024-01-31 21:20:08 (info) Function deploy complete\n", - "> 2024-01-31 21:20:15,991 [info] successfully deployed function: {'internal_invocation_urls': ['nuclio-fraud-demo-pengw-transactions-ingest.default-tenant.svc.cluster.local:8080'], 'external_invocation_urls': ['fraud-demo-pengw-transactions-ingest-fraud-demo-pengw.default-tenant.app.llm2.iguazio-cd0.com/']}\n" + "[nuclio] 2024-06-13 12:48:24,923 workerAllocationMode was automatically set to 'static' because explicitAckMode is enabled\n", + "> 2024-06-13 12:48:24,925 [info] Starting remote function deploy\n", + "2024-06-13 12:48:25 (info) Deploying function\n", + "2024-06-13 12:48:25 (info) Building\n", + "2024-06-13 12:48:25 (info) Staging files and preparing base images\n", + "2024-06-13 12:48:25 (warn) Using user provided base image, runtime interpreter version is provided by the base image\n", + "2024-06-13 12:48:25 (info) Building processor image\n", + "2024-06-13 12:49:30 (info) Build complete\n", + "2024-06-13 12:50:06 (info) Function deploy complete\n", + "> 2024-06-13 12:50:16,002 [info] Successfully deployed function: {\"external_invocation_urls\":[\"fraud-demo-yonis-transactions-ingest.default-tenant.app.llm-dev.iguazio-cd1.com/\"],\"internal_invocation_urls\":[\"nuclio-fraud-demo-yonis-transactions-ingest.default-tenant.svc.cluster.local:8080\"]}\n" ] } ], @@ -1582,7 +1605,7 @@ "\n", "# Deploy the transactions feature set's ingestion service over a real-time (Nuclio) serverless function\n", "# you can use the run_config parameter to pass function/service specific configuration\n", - "transaction_set_endpoint = fstore.deploy_ingestion_service(featureset=transaction_set, source=source)" + "transaction_set_endpoint = transaction_set.deploy_ingestion_service(source=source)" ] }, { @@ -1604,27 +1627,27 @@ }, { "cell_type": "code", - "execution_count": 43, + "execution_count": 18, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "{'step': 17,\n", + "{'step': 0,\n", " 'age': '1',\n", " 'gender': 'F',\n", " 'zipcodeOri': 28007,\n", " 'zipMerchant': 28007,\n", - " 'category': 'es_wellnessandbeauty',\n", - " 'amount': 47.79,\n", + " 'category': 'es_transportation',\n", + " 'amount': 15.33,\n", " 'fraud': 0,\n", - " 'timestamp': '2024-01-31 21:20:16.039501',\n", - " 'source': 'C1035222482',\n", - " 'target': 'M209847108',\n", - " 'device': 'd45b0900ae9d4afb86a522e03fd994a7'}" + " 'timestamp': '2024-06-13 12:50:16.173815',\n", + " 'source': 'C1002759277',\n", + " 'target': 'M348934600',\n", + " 'device': '5f8f4536c0234bc9a53b970acb8649df'}" ] }, - "execution_count": 43, + "execution_count": 18, "metadata": {}, "output_type": "execute_result" } @@ -1641,23 +1664,23 @@ }, { "cell_type": "code", - "execution_count": 44, + "execution_count": 19, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "'{\"id\": \"8bf4500a-ba7f-449e-9fdd-54db7bbdc97f\"}'" + "'{\"id\": \"efe223ff-e4ad-4bfb-abc9-3a46241f0233\"}'" ] }, - "execution_count": 44, + "execution_count": 19, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Post the sample to the ingestion endpoint\n", - "requests.post(transaction_set_endpoint, json=transaction_sample).text" + "requests.post(transaction_set_endpoint[0], json=transaction_sample).text" ] }, { @@ -1670,7 +1693,7 @@ }, { "cell_type": "code", - "execution_count": 45, + "execution_count": 20, "metadata": {}, "outputs": [], "source": [ @@ -1681,21 +1704,23 @@ }, { "cell_type": "code", - "execution_count": 46, + "execution_count": 21, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "> 2024-01-31 21:20:16,227 [info] Starting remote function deploy\n", - "2024-01-31 21:20:16 (info) Deploying function\n", - "2024-01-31 21:20:16 (info) Building\n", - "2024-01-31 21:20:16 (info) Staging files and preparing base images\n", - "2024-01-31 21:20:16 (info) Building processor image\n", - "2024-01-31 21:21:01 (info) Build complete\n", - "2024-01-31 21:21:09 (info) Function deploy complete\n", - "> 2024-01-31 21:21:17,072 [info] successfully deployed function: {'internal_invocation_urls': ['nuclio-fraud-demo-pengw-events-ingest.default-tenant.svc.cluster.local:8080'], 'external_invocation_urls': ['fraud-demo-pengw-events-ingest-fraud-demo-pengw.default-tenant.app.llm2.iguazio-cd0.com/']}\n" + "[nuclio] 2024-06-13 12:50:16,359 workerAllocationMode was automatically set to 'static' because explicitAckMode is enabled\n", + "> 2024-06-13 12:50:16,361 [info] Starting remote function deploy\n", + "2024-06-13 12:50:16 (info) Deploying function\n", + "2024-06-13 12:50:16 (info) Building\n", + "2024-06-13 12:50:16 (info) Staging files and preparing base images\n", + "2024-06-13 12:50:16 (warn) Using user provided base image, runtime interpreter version is provided by the base image\n", + "2024-06-13 12:50:16 (info) Building processor image\n", + "2024-06-13 12:51:47 (info) Build complete\n", + "2024-06-13 12:52:35 (info) Function deploy complete\n", + "> 2024-06-13 12:52:37,614 [info] Successfully deployed function: {\"external_invocation_urls\":[\"fraud-demo-yonis-events-ingest.default-tenant.app.llm-dev.iguazio-cd1.com/\"],\"internal_invocation_urls\":[\"nuclio-fraud-demo-yonis-events-ingest.default-tenant.svc.cluster.local:8080\"]}\n" ] } ], @@ -1706,7 +1731,7 @@ "\n", "# Deploy the transactions feature set's ingestion service over a real-time (Nuclio) serverless function\n", "# you can use the run_config parameter to pass function/service specific configuration\n", - "events_set_endpoint = fstore.deploy_ingestion_service(featureset=user_events_set, source=source)" + "events_set_endpoint = user_events_set.deploy_ingestion_service(source=source)" ] }, { @@ -1718,18 +1743,18 @@ }, { "cell_type": "code", - "execution_count": 47, + "execution_count": 22, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "{'source': 'C2013871968',\n", + "{'source': 'C1434797923',\n", " 'event': 'password_change',\n", - " 'timestamp': '2024-01-31 21:21:17.122919'}" + " 'timestamp': '2024-06-13 12:52:37.658561'}" ] }, - "execution_count": 47, + "execution_count": 22, "metadata": {}, "output_type": "execute_result" } @@ -1743,23 +1768,23 @@ }, { "cell_type": "code", - "execution_count": 48, + "execution_count": 23, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "'{\"id\": \"fb8e3621-c99a-47ea-9410-d55830b9c621\"}'" + "'{\"id\": \"712464d2-1014-49e6-9dec-55f1bf10d24a\"}'" ] }, - "execution_count": 48, + "execution_count": 23, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Post the sample to the ingestion endpoint\n", - "requests.post(events_set_endpoint, json=user_events_sample).text" + "requests.post(events_set_endpoint[0], json=user_events_sample).text" ] }, { @@ -1768,9 +1793,16 @@ "source": [ "## Done!\n", "\n", - "You've completed Part 3 of the data-ingestion with the feature store.\n", - "Proceed to [Part 4](04-create-training-model.html) to learn how to train an ML model using the feature store data." + "You've completed the third part - the data-ingestion with the feature store.\n", + "Proceed to [Part 4](04-train-test-pipeline.ipynb) to learn how to train an ML model using the feature store data." ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": { @@ -1789,7 +1821,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.9.18" }, "toc-showtags": false }, diff --git a/4-train-test-pipeline.ipynb b/04-train-test-pipeline.ipynb similarity index 75% rename from 4-train-test-pipeline.ipynb rename to 04-train-test-pipeline.ipynb index 8ae7a73..a714d90 100644 --- a/4-train-test-pipeline.ipynb +++ b/04-train-test-pipeline.ipynb @@ -35,14 +35,14 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "> 2024-01-31 21:21:37,228 [info] loaded project fraud-demo from MLRun DB\n" + "> 2024-06-16 11:54:36,006 [info] Project loaded successfully: {\"project_name\":\"fraud-demo\"}\n" ] } ], @@ -74,7 +74,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 2, "metadata": {}, "outputs": [], "source": [ @@ -126,7 +126,7 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 3, "metadata": {}, "outputs": [], "source": [ @@ -191,13 +191,15 @@ }, { "cell_type": "code", - "execution_count": 13, - "metadata": {}, + "execution_count": 5, + "metadata": { + "tags": [] + }, "outputs": [ { "data": { "text/html": [ - "
Pipeline running (id=0dc89c25-235f-4a12-8c8d-6630675071d9), click here to view the details in MLRun UI
" + "
Pipeline running (id=95413672-9f21-404e-9a27-24da53915500), click here to view the details in MLRun UI
" ], "text/plain": [ "" @@ -220,68 +222,68 @@ "\n", "kfp\n", "\n", - "\n", + "\n", "\n", - "fraud-detection-pipeline-xvtp5-1318838833\n", + "fraud-detection-pipeline-dcvlv-199159427\n", "\n", "evaluate\n", "\n", - "\n", + "\n", "\n", - "fraud-detection-pipeline-xvtp5-1900309304\n", + "fraud-detection-pipeline-dcvlv-2822986386\n", + "\n", + "train\n", + "\n", + "\n", + "\n", + "fraud-detection-pipeline-dcvlv-2822986386->fraud-detection-pipeline-dcvlv-199159427\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "fraud-detection-pipeline-dcvlv-744271830\n", "\n", "\n", "\n", "\n", "deploy-serving\n", "\n", - "\n", - "\n", - "fraud-detection-pipeline-xvtp5-2180286806\n", + "\n", + "\n", + "fraud-detection-pipeline-dcvlv-2822986386->fraud-detection-pipeline-dcvlv-744271830\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "fraud-detection-pipeline-dcvlv-4248152384\n", "\n", "get-vector\n", "\n", - "\n", - "\n", - "fraud-detection-pipeline-xvtp5-3453900639\n", + "\n", + "\n", + "fraud-detection-pipeline-dcvlv-979477985\n", "\n", "feature-selection\n", "\n", - "\n", - "\n", - "fraud-detection-pipeline-xvtp5-2180286806->fraud-detection-pipeline-xvtp5-3453900639\n", + "\n", + "\n", + "fraud-detection-pipeline-dcvlv-4248152384->fraud-detection-pipeline-dcvlv-979477985\n", "\n", "\n", "\n", - "\n", - "\n", - "fraud-detection-pipeline-xvtp5-2293084544\n", - "\n", - "train\n", - "\n", - "\n", + "\n", "\n", - "fraud-detection-pipeline-xvtp5-3453900639->fraud-detection-pipeline-xvtp5-2293084544\n", + "fraud-detection-pipeline-dcvlv-979477985->fraud-detection-pipeline-dcvlv-2822986386\n", "\n", "\n", "\n", - "\n", - "\n", - "fraud-detection-pipeline-xvtp5-2293084544->fraud-detection-pipeline-xvtp5-1318838833\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "fraud-detection-pipeline-xvtp5-2293084544->fraud-detection-pipeline-xvtp5-1900309304\n", - "\n", - "\n", - "\n", "\n", "\n" ], "text/plain": [ - "" + "" ] }, "metadata": {}, @@ -290,12 +292,13 @@ { "data": { "text/html": [ - "

Run Results

[info] Workflow 0dc89c25-235f-4a12-8c8d-6630675071d9 finished, state=Succeeded


click the hyper links below to see detailed results
\n", + "

Run Results

[info] Workflow 95413672-9f21-404e-9a27-24da53915500 finished, state=Succeeded


click the hyper links below to see detailed results
\n", " \n", " \n", " \n", " \n", " \n", + " \n", " \n", " \n", " \n", @@ -303,36 +306,40 @@ " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", + " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", + " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", + " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", + " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", "
uidstartstatekindnameparametersresults
Jan 31 21:23:35Jun 16 11:58:21completedrunevaluate
label_columns=label
model=store://artifacts/fraud-demo-pengw/transaction_fraud_adaboost:0dc89c25-235f-4a12-8c8d-6630675071d9
drop_columns=label
evaluation_accuracy=0.992503748125937
evaluation_f1_score=0.3478260869565218
evaluation_precision_score=0.5
evaluation_recall_score=0.26666666666666666
label_columns=label
model=store://artifacts/fraud-demo-yonis/transaction_fraud_rf@95413672-9f21-404e-9a27-24da53915500
drop_columns=label
evaluation_accuracy=0.9915
evaluation_f1_score=0.32
evaluation_precision_score=0.8
evaluation_recall_score=0.2
Jan 31 21:22:57Jun 16 11:57:48completedruntrain
sample=-1
label_column=label
test_size=0.1
best_iteration=3
accuracy=0.992503748125937
f1_score=0.3478260869565218
precision_score=0.5
recall_score=0.26666666666666666
best_iteration=1
accuracy=0.9915
f1_score=0.32
precision_score=0.8
recall_score=0.2
Jan 31 21:22:18Jun 16 11:57:17completedrunfeature-selection
output_vector_name=short
label_column=label
k=18
min_votes=2
ignore_type_errors=True
top_features_vector=store://feature-vectors/fraud-demo-pengw/short
top_features_vector=store://feature-vectors/fraud-demo-yonis/short
Jan 31 21:21:49Jun 16 11:56:47completedrunget-vector
feature_vector=transactions-fraud
features=[]
label_feature=labels.label
target={'name': 'parquet', 'kind': 'parquet'}
update_stats=True
feature_vector=transactions-fraud
feature_vector_uri=store://feature-vectors/fraud-demo-pengw/transactions-fraud:latest
feature_vector=transactions-fraud
feature_vector_uri=store://feature-vectors/fraud-demo-yonis/transactions-fraud:latest
" @@ -377,25 +384,25 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 6, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "> 2024-01-31 21:24:51,195 [info] invoking function: {'method': 'POST', 'path': 'http://nuclio-fraud-demo-pengw-serving.default-tenant.svc.cluster.local:8080/v2/models/fraud/infer'}\n" + "> 2024-06-16 12:03:33,071 [info] Invoking function: {\"method\":\"POST\",\"path\":\"http://nuclio-fraud-demo-yonis-serving.default-tenant.svc.cluster.local:8080/v2/models/fraud/infer\"}\n" ] }, { "data": { "text/plain": [ - "{'id': 'a95bd1fd-7149-4cd4-a449-4def08ef3103',\n", + "{'id': '70a08b41-fc68-463d-8a4a-03900801d8bf',\n", " 'model_name': 'fraud',\n", " 'outputs': [0]}" ] }, - "execution_count": 14, + "execution_count": 6, "metadata": {}, "output_type": "execute_result" } @@ -419,8 +426,8 @@ "source": [ "## Done!\n", "\n", - "You've completed Part 4 of the model training with the feature store.\n", - "Proceed to part 5 to learn how to deploy real-time application pipeline" + "You've completed part 4 - the model training with the feature store.\n", + "Proceed to [Part 5](06-real-time-serving-pipeline.ipynb) to learn how to deploy real-time application pipelines." ] }, { @@ -447,7 +454,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.9.18" } }, "nbformat": 4, diff --git a/5-real-time-serving-pipeline.ipynb b/05-real-time-serving-pipeline.ipynb similarity index 68% rename from 5-real-time-serving-pipeline.ipynb rename to 05-real-time-serving-pipeline.ipynb index 2c5f8aa..0b793c9 100644 --- a/5-real-time-serving-pipeline.ipynb +++ b/05-real-time-serving-pipeline.ipynb @@ -11,59 +11,9 @@ "You would typically need to implement and deploy multiple microservices and com‐ plex logic to build such an application pipeline. But, with MLRun, you can define it in a few lines of code and deploy it automatically into elastic serverless functions. In addition, the MLRun serving framework will automatically support real-time feature imputing, model monitoring, and so on without requiring extra coding." ] }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Environment setup\n", - "\n", - "First, make sure SciKit-Learn is installed in the correct version:" - ] - }, { "cell_type": "code", - "execution_count": 12, - "metadata": { - "collapsed": false, - "jupyter": { - "outputs_hidden": false - }, - "pycharm": { - "name": "#%%\n" - } - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Requirement already satisfied: scikit-learn==1.2.2 in /User/.pythonlibs/mlrun-extended/lib/python3.9/site-packages (1.2.2)\n", - "Requirement already satisfied: scipy>=1.3.2 in /conda/envs/mlrun-extended/lib/python3.9/site-packages (from scikit-learn==1.2.2) (1.10.1)\n", - "Requirement already satisfied: threadpoolctl>=2.0.0 in /conda/envs/mlrun-extended/lib/python3.9/site-packages (from scikit-learn==1.2.2) (3.1.0)\n", - "Requirement already satisfied: joblib>=1.1.1 in /conda/envs/mlrun-extended/lib/python3.9/site-packages (from scikit-learn==1.2.2) (1.2.0)\n", - "Requirement already satisfied: numpy>=1.17.3 in /conda/envs/mlrun-extended/lib/python3.9/site-packages (from scikit-learn==1.2.2) (1.22.4)\n" - ] - } - ], - "source": [ - "!pip install -U scikit-learn==1.2.2" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "pycharm": { - "name": "#%% md\n" - } - }, - "source": [ - "Restart your kernel post installing.\n", - "Since your work is done in this project scope, you should define the project itself for all your MLRun work in this notebook." - ] - }, - { - "cell_type": "code", - "execution_count": 13, + "execution_count": 1, "metadata": {}, "outputs": [], "source": [ @@ -86,7 +36,7 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 2, "metadata": {}, "outputs": [], "source": [ @@ -95,7 +45,7 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 3, "metadata": {}, "outputs": [], "source": [ @@ -120,7 +70,7 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": 4, "metadata": {}, "outputs": [], "source": [ @@ -142,45 +92,45 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[('transaction_fraud_rf',\n", - " {'key': 'model',\n", - " 'project': 'fraud-demo-pengw',\n", + " {'tree': '95413672-9f21-404e-9a27-24da53915500',\n", + " 'updated': '2024-06-16 11:58:23.453818+00:00',\n", + " 'project': 'fraud-demo-yonis',\n", + " 'hash': '7757dbbbfe1a75a7cb58e8b87d5601b0e133a1b7',\n", + " 'labels': {'workflow-id': '95413672-9f21-404e-9a27-24da53915500',\n", + " 'framework': 'sklearn'},\n", " 'iter': 1,\n", - " 'tree': '0dc89c25-235f-4a12-8c8d-6630675071d9',\n", - " 'hash': '402a0ccbdbb40091aab79c273ce0969ffa30bd04',\n", " 'tag': 'latest',\n", - " 'updated': '2024-01-31T21:23:01.476554+00:00',\n", - " 'labels': {'workflow-id': '0dc89c25-235f-4a12-8c8d-6630675071d9',\n", - " 'framework': 'sklearn'}}),\n", + " 'key': 'model'}),\n", " ('transaction_fraud_xgboost',\n", - " {'key': 'model',\n", - " 'project': 'fraud-demo-pengw',\n", + " {'tree': '95413672-9f21-404e-9a27-24da53915500',\n", + " 'updated': '2024-06-16 11:57:55.092567+00:00',\n", + " 'project': 'fraud-demo-yonis',\n", + " 'hash': 'fc6b2b49050c97f1dde741db59130cb2c7217dda',\n", + " 'labels': {'workflow-id': '95413672-9f21-404e-9a27-24da53915500',\n", + " 'framework': 'sklearn'},\n", " 'iter': 2,\n", - " 'tree': '0dc89c25-235f-4a12-8c8d-6630675071d9',\n", - " 'hash': '00da01444243561ad0164019377553327228d602',\n", " 'tag': 'latest',\n", - " 'updated': '2024-01-31T21:23:05.370176+00:00',\n", - " 'labels': {'workflow-id': '0dc89c25-235f-4a12-8c8d-6630675071d9',\n", - " 'framework': 'sklearn'}}),\n", + " 'key': 'model'}),\n", " ('transaction_fraud_adaboost',\n", - " {'key': 'model',\n", - " 'project': 'fraud-demo-pengw',\n", + " {'tree': '95413672-9f21-404e-9a27-24da53915500',\n", + " 'updated': '2024-06-16 11:57:57.651277+00:00',\n", + " 'project': 'fraud-demo-yonis',\n", + " 'hash': '644f6341d55efe957af1a1819fbd4ad4766c8f05',\n", + " 'labels': {'workflow-id': '95413672-9f21-404e-9a27-24da53915500',\n", + " 'framework': 'sklearn'},\n", " 'iter': 3,\n", - " 'tree': '0dc89c25-235f-4a12-8c8d-6630675071d9',\n", - " 'hash': 'ee71454950f7056eb4b20e81166f987a9b67067b',\n", " 'tag': 'latest',\n", - " 'updated': '2024-01-31T21:23:08.040961+00:00',\n", - " 'labels': {'workflow-id': '0dc89c25-235f-4a12-8c8d-6630675071d9',\n", - " 'framework': 'sklearn'}})]" + " 'key': 'model'})]" ] }, - "execution_count": 17, + "execution_count": 5, "metadata": {}, "output_type": "execute_result" } @@ -191,7 +141,7 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": 6, "metadata": {}, "outputs": [ { @@ -265,10 +215,10 @@ "\n" ], "text/plain": [ - "" + "" ] }, - "execution_count": 18, + "execution_count": 6, "metadata": {}, "output_type": "execute_result" } @@ -302,16 +252,16 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": 7, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "> 2024-01-31 21:58:43,485 [info] model transaction_fraud_rf was loaded\n", - "> 2024-01-31 21:58:43,580 [info] model transaction_fraud_xgboost was loaded\n", - "> 2024-01-31 21:58:43,657 [info] model transaction_fraud_adaboost was loaded\n" + "> 2024-06-16 12:22:18,280 [info] model transaction_fraud_rf was loaded\n", + "> 2024-06-16 12:22:18,310 [info] model transaction_fraud_xgboost was loaded\n", + "> 2024-06-16 12:22:18,335 [info] model transaction_fraud_adaboost was loaded\n" ] } ], @@ -322,16 +272,16 @@ }, { "cell_type": "code", - "execution_count": 20, + "execution_count": 8, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "Input -> [[60.98, 73.78999999999999, 2.0, 36.894999999999996, 134.16, 999.8500000000001, 31.0, 32.25322580645162, 143.87, 1835.7000000000003, 58.0, 31.650000000000006, 90.0, 1.0, 2.0]]\n", - "Input -> [[60.98, 73.78999999999999, 2.0, 36.894999999999996, 134.16, 999.8500000000001, 31.0, 32.25322580645162, 143.87, 1835.7000000000003, 58.0, 31.650000000000006, 90.0, 1.0, 2.0]]\n", - "Input -> [[60.98, 73.78999999999999, 2.0, 36.894999999999996, 134.16, 999.8500000000001, 31.0, 32.25322580645162, 143.87, 1835.7000000000003, 58.0, 31.650000000000006, 90.0, 1.0, 2.0]]\n" + "Input -> [[82.069159, 175.59015899999997, 0.0, 38.538630532373176, 216.317882, 986.6475539999999, 0.0, 39.624237449781845, 290.097621, 1690.815196, 0.0, 39.91850357589505, 90.0, 1.0, 2.0]]\n", + "Input -> [[82.069159, 175.59015899999997, 0.0, 38.538630532373176, 216.317882, 986.6475539999999, 0.0, 39.624237449781845, 290.097621, 1690.815196, 0.0, 39.91850357589505, 90.0, 1.0, 2.0]]\n", + "Input -> [[82.069159, 175.59015899999997, 0.0, 38.538630532373176, 216.317882, 986.6475539999999, 0.0, 39.624237449781845, 290.097621, 1690.815196, 0.0, 39.91850357589505, 90.0, 1.0, 2.0]]\n" ] }, { @@ -346,13 +296,13 @@ { "data": { "text/plain": [ - "{'id': 'ae4261e0749b4a65a86f8191ac50a24e',\n", + "{'id': 'db33d30f0ff9462b8f4531f8b402aad0',\n", " 'model_name': 'VotingEnsemble',\n", " 'outputs': [0],\n", " 'model_version': 'v1'}" ] }, - "execution_count": 20, + "execution_count": 8, "metadata": {}, "output_type": "execute_result" } @@ -381,39 +331,39 @@ }, { "cell_type": "code", - "execution_count": 21, + "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "[{'amount_max_2h': 60.98,\n", - " 'amount_max_12h': 134.16,\n", - " 'amount_max_24h': 143.87,\n", - " 'amount_sum_2h': 73.78999999999999,\n", - " 'amount_sum_12h': 999.8500000000001,\n", - " 'amount_sum_24h': 1835.7000000000003,\n", - " 'amount_count_2h': 2.0,\n", - " 'amount_count_12h': 31.0,\n", - " 'amount_count_24h': 58.0,\n", + "[{'amount_max_2h': 82.069159,\n", + " 'amount_max_12h': 216.317882,\n", + " 'amount_max_24h': 290.097621,\n", + " 'amount_count_2h': 0.0,\n", + " 'amount_count_12h': 0.0,\n", + " 'amount_count_24h': 0.0,\n", + " 'amount_sum_2h': 175.59015899999997,\n", + " 'amount_sum_12h': 986.6475539999999,\n", + " 'amount_sum_24h': 1690.815196,\n", " 'es_transportation_sum_14d': 90.0,\n", " 'es_health_sum_14d': 1.0,\n", " 'es_otherservices_sum_14d': 2.0,\n", - " 'amount_avg_2h': 36.894999999999996,\n", - " 'amount_avg_12h': 32.25322580645162,\n", - " 'amount_avg_24h': 31.650000000000006}]" + " 'amount_avg_2h': 38.538630532373176,\n", + " 'amount_avg_12h': 39.624237449781845,\n", + " 'amount_avg_24h': 39.91850357589505}]" ] }, - "execution_count": 21, + "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "import mlrun.feature_store as fstore\n", + "import mlrun.feature_store as fs\n", "\n", "# Create the online feature service\n", - "svc = fstore.get_online_feature_service('short:latest', impute_policy={\"*\": \"$mean\"})\n", + "svc = fs.get_feature_vector('short:latest').get_online_feature_service(impute_policy={\"*\": \"$mean\"})\n", "\n", "# Get sample feature vector\n", "sample_fv = svc.get([{'source': sample_id}])\n", @@ -431,30 +381,31 @@ }, { "cell_type": "code", - "execution_count": 22, + "execution_count": 10, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "> 2024-01-31 21:58:44,020 [info] Starting remote function deploy\n", - "2024-01-31 21:58:44 (info) Deploying function\n", - "2024-01-31 21:58:44 (info) Building\n", - "2024-01-31 21:58:45 (info) Staging files and preparing base images\n", - "2024-01-31 21:58:45 (info) Building processor image\n", - "2024-01-31 21:59:20 (info) Build complete\n", - "2024-01-31 21:59:28 (info) Function deploy complete\n", - "> 2024-01-31 21:59:35,698 [info] successfully deployed function: {'internal_invocation_urls': ['nuclio-fraud-demo-pengw-test-function.default-tenant.svc.cluster.local:8080'], 'external_invocation_urls': ['fraud-demo-pengw-test-function-fraud-demo-pengw.default-tenant.app.llm2.iguazio-cd0.com/']}\n" + "> 2024-06-16 12:22:18,733 [info] Starting remote function deploy\n", + "2024-06-16 12:22:19 (info) Deploying function\n", + "2024-06-16 12:22:19 (info) Building\n", + "2024-06-16 12:22:19 (info) Staging files and preparing base images\n", + "2024-06-16 12:22:19 (warn) Using user provided base image, runtime interpreter version is provided by the base image\n", + "2024-06-16 12:22:19 (info) Building processor image\n", + "2024-06-16 12:24:04 (info) Build complete\n", + "2024-06-16 12:24:40 (info) Function deploy complete\n", + "> 2024-06-16 12:24:50,110 [info] Successfully deployed function: {\"external_invocation_urls\":[\"fraud-demo-yonis-test-function.default-tenant.app.llm-dev.iguazio-cd1.com/\"],\"internal_invocation_urls\":[\"nuclio-fraud-demo-yonis-test-function.default-tenant.svc.cluster.local:8080\"]}\n" ] }, { "data": { "text/plain": [ - "'http://fraud-demo-pengw-test-function-fraud-demo-pengw.default-tenant.app.llm2.iguazio-cd0.com/'" + "'http://fraud-demo-yonis-test-function.default-tenant.app.llm-dev.iguazio-cd1.com/'" ] }, - "execution_count": 22, + "execution_count": 10, "metadata": {}, "output_type": "execute_result" } @@ -480,26 +431,26 @@ }, { "cell_type": "code", - "execution_count": 23, + "execution_count": 11, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "> 2024-01-31 21:59:35,745 [info] invoking function: {'method': 'POST', 'path': 'http://nuclio-fraud-demo-pengw-test-function.default-tenant.svc.cluster.local:8080/v2/models/infer'}\n" + "> 2024-06-16 12:24:50,156 [info] Invoking function: {\"method\":\"POST\",\"path\":\"http://nuclio-fraud-demo-yonis-test-function.default-tenant.svc.cluster.local:8080/v2/models/infer\"}\n" ] }, { "data": { "text/plain": [ - "{'id': '96eb93fa-1b56-4cae-8062-ee188f3e4e68',\n", + "{'id': '1040b6de-5352-465a-80fe-6d2c07c1a7c7',\n", " 'model_name': 'VotingEnsemble',\n", " 'outputs': [0],\n", " 'model_version': 'v1'}" ] }, - "execution_count": 23, + "execution_count": 11, "metadata": {}, "output_type": "execute_result" } @@ -531,12 +482,12 @@ }, { "cell_type": "code", - "execution_count": 24, + "execution_count": 13, "metadata": {}, "outputs": [], "source": [ "# Load the dataset\n", - "data = mlrun.get_dataitem('https://s3.wasabisys.com/iguazio/data/fraud-demo-mlrun-fs-docs/data.csv').as_df()\n", + "data = mlrun.get_dataitem(mlrun.get_sample_path(\"data/fraud-demo-mlrun-fs-docs/data.csv\")).as_df()\n", "\n", "# use only first 10k\n", "data = data.sort_values(by='source', axis=0)[:10000]\n", @@ -547,33 +498,33 @@ }, { "cell_type": "code", - "execution_count": 25, + "execution_count": 14, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "> 2024-01-31 21:59:39,143 [info] invoking function: {'method': 'POST', 'path': 'http://nuclio-fraud-demo-pengw-test-function.default-tenant.svc.cluster.local:8080/v2/models/infer'}\n", - "{'id': 'fd731a0e-60d1-408f-916f-7217386e5e19', 'model_name': 'VotingEnsemble', 'outputs': [0], 'model_version': 'v1'}\n", - "> 2024-01-31 21:59:40,786 [info] invoking function: {'method': 'POST', 'path': 'http://nuclio-fraud-demo-pengw-test-function.default-tenant.svc.cluster.local:8080/v2/models/infer'}\n", - "{'id': '05dac89f-a5b0-4436-8223-0337d41fdf3a', 'model_name': 'VotingEnsemble', 'outputs': [0], 'model_version': 'v1'}\n", - "> 2024-01-31 21:59:41,533 [info] invoking function: {'method': 'POST', 'path': 'http://nuclio-fraud-demo-pengw-test-function.default-tenant.svc.cluster.local:8080/v2/models/infer'}\n", - "{'id': '2f0711af-2ef9-4057-a270-d01051f4e09b', 'model_name': 'VotingEnsemble', 'outputs': [0], 'model_version': 'v1'}\n", - "> 2024-01-31 21:59:42,053 [info] invoking function: {'method': 'POST', 'path': 'http://nuclio-fraud-demo-pengw-test-function.default-tenant.svc.cluster.local:8080/v2/models/infer'}\n", - "{'id': 'ccea419a-4aa0-4a9e-923d-a8cc2d0d1555', 'model_name': 'VotingEnsemble', 'outputs': [0], 'model_version': 'v1'}\n", - "> 2024-01-31 21:59:43,229 [info] invoking function: {'method': 'POST', 'path': 'http://nuclio-fraud-demo-pengw-test-function.default-tenant.svc.cluster.local:8080/v2/models/infer'}\n", - "{'id': '3a01adad-dc4d-4659-9891-40444a2f7f59', 'model_name': 'VotingEnsemble', 'outputs': [0], 'model_version': 'v1'}\n", - "> 2024-01-31 21:59:44,918 [info] invoking function: {'method': 'POST', 'path': 'http://nuclio-fraud-demo-pengw-test-function.default-tenant.svc.cluster.local:8080/v2/models/infer'}\n", - "{'id': '94dc34d1-0c02-4551-93b8-ef107c92ab1a', 'model_name': 'VotingEnsemble', 'outputs': [0], 'model_version': 'v1'}\n", - "> 2024-01-31 21:59:45,850 [info] invoking function: {'method': 'POST', 'path': 'http://nuclio-fraud-demo-pengw-test-function.default-tenant.svc.cluster.local:8080/v2/models/infer'}\n", - "{'id': 'cafab576-d393-48d4-a486-99746ae6e8f0', 'model_name': 'VotingEnsemble', 'outputs': [0], 'model_version': 'v1'}\n", - "> 2024-01-31 21:59:46,450 [info] invoking function: {'method': 'POST', 'path': 'http://nuclio-fraud-demo-pengw-test-function.default-tenant.svc.cluster.local:8080/v2/models/infer'}\n", - "{'id': '8be232af-00e3-4366-b588-2affddd27e19', 'model_name': 'VotingEnsemble', 'outputs': [0], 'model_version': 'v1'}\n", - "> 2024-01-31 21:59:47,297 [info] invoking function: {'method': 'POST', 'path': 'http://nuclio-fraud-demo-pengw-test-function.default-tenant.svc.cluster.local:8080/v2/models/infer'}\n", - "{'id': '4b59f1a3-dcc6-42fd-bdb3-863f346cc5fb', 'model_name': 'VotingEnsemble', 'outputs': [0], 'model_version': 'v1'}\n", - "> 2024-01-31 21:59:48,190 [info] invoking function: {'method': 'POST', 'path': 'http://nuclio-fraud-demo-pengw-test-function.default-tenant.svc.cluster.local:8080/v2/models/infer'}\n", - "{'id': '67ea3ebf-56bf-420f-b947-51ba5895fd32', 'model_name': 'VotingEnsemble', 'outputs': [0], 'model_version': 'v1'}\n" + "> 2024-06-16 12:29:26,624 [info] Invoking function: {\"method\":\"POST\",\"path\":\"http://nuclio-fraud-demo-yonis-test-function.default-tenant.svc.cluster.local:8080/v2/models/infer\"}\n", + "{'id': '88ac4743-e6b9-4f5d-be46-9aa2127c2c1e', 'model_name': 'VotingEnsemble', 'outputs': [0], 'model_version': 'v1'}\n", + "> 2024-06-16 12:29:27,901 [info] Invoking function: {\"method\":\"POST\",\"path\":\"http://nuclio-fraud-demo-yonis-test-function.default-tenant.svc.cluster.local:8080/v2/models/infer\"}\n", + "{'id': 'ebf209e1-b439-4562-964e-b6e44b5e00c1', 'model_name': 'VotingEnsemble', 'outputs': [0], 'model_version': 'v1'}\n", + "> 2024-06-16 12:29:28,951 [info] Invoking function: {\"method\":\"POST\",\"path\":\"http://nuclio-fraud-demo-yonis-test-function.default-tenant.svc.cluster.local:8080/v2/models/infer\"}\n", + "{'id': 'a3712ea3-3444-4545-b315-13c7d76db9a6', 'model_name': 'VotingEnsemble', 'outputs': [0], 'model_version': 'v1'}\n", + "> 2024-06-16 12:29:29,500 [info] Invoking function: {\"method\":\"POST\",\"path\":\"http://nuclio-fraud-demo-yonis-test-function.default-tenant.svc.cluster.local:8080/v2/models/infer\"}\n", + "{'id': 'd70800fe-47e2-4a22-85fd-e05f91c85c99', 'model_name': 'VotingEnsemble', 'outputs': [0], 'model_version': 'v1'}\n", + "> 2024-06-16 12:29:30,209 [info] Invoking function: {\"method\":\"POST\",\"path\":\"http://nuclio-fraud-demo-yonis-test-function.default-tenant.svc.cluster.local:8080/v2/models/infer\"}\n", + "{'id': '034eae67-fa06-4907-9f6f-99447fff6928', 'model_name': 'VotingEnsemble', 'outputs': [0], 'model_version': 'v1'}\n", + "> 2024-06-16 12:29:30,498 [info] Invoking function: {\"method\":\"POST\",\"path\":\"http://nuclio-fraud-demo-yonis-test-function.default-tenant.svc.cluster.local:8080/v2/models/infer\"}\n", + "{'id': 'cd8b6a27-8c49-4dab-94f0-2f33926ec5c8', 'model_name': 'VotingEnsemble', 'outputs': [0], 'model_version': 'v1'}\n", + "> 2024-06-16 12:29:31,286 [info] Invoking function: {\"method\":\"POST\",\"path\":\"http://nuclio-fraud-demo-yonis-test-function.default-tenant.svc.cluster.local:8080/v2/models/infer\"}\n", + "{'id': '059b6ad1-c951-499d-b7ff-e85b5786869b', 'model_name': 'VotingEnsemble', 'outputs': [0], 'model_version': 'v1'}\n", + "> 2024-06-16 12:29:32,601 [info] Invoking function: {\"method\":\"POST\",\"path\":\"http://nuclio-fraud-demo-yonis-test-function.default-tenant.svc.cluster.local:8080/v2/models/infer\"}\n", + "{'id': '1f3bb3cd-4426-4efe-8813-e1b2d104090b', 'model_name': 'VotingEnsemble', 'outputs': [0], 'model_version': 'v1'}\n", + "> 2024-06-16 12:29:34,084 [info] Invoking function: {\"method\":\"POST\",\"path\":\"http://nuclio-fraud-demo-yonis-test-function.default-tenant.svc.cluster.local:8080/v2/models/infer\"}\n", + "{'id': 'eeca3bd4-a57b-41d8-81ca-21e2c3e6eeda', 'model_name': 'VotingEnsemble', 'outputs': [0], 'model_version': 'v1'}\n", + "> 2024-06-16 12:29:35,179 [info] Invoking function: {\"method\":\"POST\",\"path\":\"http://nuclio-fraud-demo-yonis-test-function.default-tenant.svc.cluster.local:8080/v2/models/infer\"}\n", + "{'id': '659d82a7-4d0a-489b-a502-202a1ca1d4f5', 'model_name': 'VotingEnsemble', 'outputs': [0], 'model_version': 'v1'}\n" ] } ], @@ -602,7 +553,7 @@ "source": [ "## Done!\n", "\n", - "You've completed Part 5 of the fraud-detection demo. \n" + "You've completed the fraud-detection demo. \n" ] }, { @@ -615,9 +566,9 @@ ], "metadata": { "kernelspec": { - "display_name": "mlrun-extended", + "display_name": "mlrun-base", "language": "python", - "name": "conda-env-mlrun-extended-py" + "name": "conda-env-mlrun-base-py" }, "language_info": { "codemirror_mode": { @@ -629,7 +580,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.9.18" } }, "nbformat": 4, diff --git a/README.md b/README.md index c8411bf..184a625 100644 --- a/README.md +++ b/README.md @@ -7,11 +7,11 @@ This demo shows the usage of MLRun and the feature store. The demo showcases: -- [**Data Exploration**](1-exploratory-data-analysis.ipynb) -- [**Offline Data prepare and train**](2-interactive-data-prep.ipynb) -- [**Data ingestion & preparation**](3-ingest-with-feature-store.ipynb) -- [**Building An Automated ML Pipeline**](4-train-test-pipeline.ipynb) -- [**Model serving**](5-real-time-serving-pipeline.ipynb) +- [**Data Exploration**](01-exploratory-data-analysis.ipynb) +- [**Offline Data prepare and train**](02-interactive-data-preparation.ipynb) +- [**Data ingestion & preparation**](03-ingest-with-feature-store.ipynb) +- [**Building An Automated ML Pipeline**](04-train-test-pipeline.ipynb) +- [**Model serving**](05-real-time-serving-pipeline.ipynb) Fraud prevention specifically is a challenge as it requires processing raw transaction and events in real-time and being able to quickly respond and block transactions before they occur. Consider, for example, a case where you would like to evaluate the @@ -28,11 +28,3 @@ In this demo we will learn how to **Ingest** different data sources to our **Fea We will walk through creation of ingestion pipeline for each data source with all the needed preprocessing and validation. We will run the pipeline locally within the notebook and then launch a real-time function to **ingest live data** or schedule a cron to run the task when needed. Following the ingestion, we will create a feature vector, select the most relevant features and create a final model. We will then deploy the model and showcase the feature vector and model serving. - -``` -01-exploratory-data-analysis -02-interactive-data-prep -03-ingest-with-feature-store -04-train-test-pipeline -05-real-time-serving-pipeline -```