From 517d252a5e9d774067984bbb5e648a93ec174312 Mon Sep 17 00:00:00 2001 From: Faried Abu Zaid Date: Tue, 4 Jun 2024 15:15:45 +0200 Subject: [PATCH 1/3] adopt to pandas api change --- src/tfl_training_anomaly_detection/exercise_tools.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tfl_training_anomaly_detection/exercise_tools.py b/src/tfl_training_anomaly_detection/exercise_tools.py index 366d03e..28a235d 100755 --- a/src/tfl_training_anomaly_detection/exercise_tools.py +++ b/src/tfl_training_anomaly_detection/exercise_tools.py @@ -702,7 +702,7 @@ def perform_rkde_experiment( if epsilon != 0: model.compute_anomaly_roc(y) new_scores = model.get_score() - total_scores = total_scores.append(new_scores, ignore_index=True) + total_scores = total_scores._append(new_scores, ignore_index=True) return total_scores From 2bd2fa4412f2a6c44b5798a4831496d3404c1671 Mon Sep 17 00:00:00 2001 From: Faried Abu Zaid Date: Tue, 4 Jun 2024 15:17:09 +0200 Subject: [PATCH 2/3] Adopt to pandas api change, Fix error in KDE definition --- ...aly_detection_via_density_estimation.ipynb | 340 ++++++++++++++++-- 1 file changed, 304 insertions(+), 36 deletions(-) diff --git a/notebooks/nb_02_anomaly_detection_via_density_estimation.ipynb b/notebooks/nb_02_anomaly_detection_via_density_estimation.ipynb index c22aa54..36443d9 100644 --- a/notebooks/nb_02_anomaly_detection_via_density_estimation.ipynb +++ b/notebooks/nb_02_anomaly_detection_via_density_estimation.ipynb @@ -404,8 +404,8 @@ "**Definition:**\n", "\n", "---\n", - "Let $D = \\{x_1,\\ldots,x_N\\}\\subset \\mathbb{R}^p$. The KDE with kernel $K$ and bandwidth $h$ is\n", - "$KDE_h(x, D) = \\frac{1}{N}\\sum_{i=1}^N \\frac{1}{h^p}K\\left(\\frac{|x-x_i|}{h}\\right)$\n", + "Let $D = \\{x_1,\\ldots,x_N\\}\\subset \\mathbb{R}^p$. The KDE with symmetric kernel $K$ and bandwidth $h$ is\n", + "$KDE_h(x, D) = \\frac{1}{N}\\sum_{i=1}^N \\frac{1}{h^p}K\\left(\\frac{x-x_i}{h}\\right)$\n", "\n", "---\n", "\n", @@ -536,7 +536,7 @@ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "1b867c01b0fe43baafd4884bcf92b680", + "model_id": "83d957ba3af3428bbb3bcd6db94adfb7", "version_major": 2, "version_minor": 0 }, @@ -762,7 +762,7 @@ "name": "stderr", "output_type": "stream", "text": [ - "/opt/homebrew/Caskroom/miniconda/base/envs/tfl-training-ad/lib/python3.10/site-packages/sklearn/model_selection/_search.py:1051: UserWarning: One or more of the test scores are non-finite: [-583.82004189 -460.99529797 -481.91244569 -500.00511672 -545.60663629\n", + "/Users/fariedabuzaid/.pyenv/versions/3.10.11/lib/python3.10/site-packages/sklearn/model_selection/_search.py:1051: UserWarning: One or more of the test scores are non-finite: [-583.82004189 -460.99529797 -481.91244569 -500.00511672 -545.60663629\n", " -561.06553923 -393.29051279 -436.60580108 -508.03454897 -inf\n", " -452.96132239 -473.5478597 -460.29104963 -522.20259792 -598.90918215\n", " -467.81178514 -648.98516413 -484.85010317 -534.20785976 -353.24010639\n", @@ -783,7 +783,7 @@ " -531.0443066 -496.60353839 -603.09910009 -518.27158361 -485.81926434\n", " -446.02585033 -617.26185348 -inf -492.11710758 -509.52974428]\n", " warnings.warn(\n", - "/opt/homebrew/Caskroom/miniconda/base/envs/tfl-training-ad/lib/python3.10/site-packages/sklearn/model_selection/_search.py:1062: RuntimeWarning: invalid value encountered in subtract\n", + "/Users/fariedabuzaid/.pyenv/versions/3.10.11/lib/python3.10/site-packages/sklearn/model_selection/_search.py:1062: RuntimeWarning: invalid value encountered in subtract\n", " (array - array_means[:, np.newaxis]) ** 2, axis=1, weights=weights\n" ] }, @@ -2603,9 +2603,9 @@ } }, "text/html": [ - "