Skip to content

Commit

Permalink
Added code for anomaly detection
Browse files Browse the repository at this point in the history
  • Loading branch information
mariolpantunes committed Oct 11, 2023
1 parent 54bba35 commit 0c87147
Show file tree
Hide file tree
Showing 19 changed files with 3,442 additions and 500 deletions.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@
}
],
"source": [
"df = pl.read_csv('../datasets/spam.csv')\n",
"df = pl.read_csv('../../datasets/spam.csv')\n",
"df"
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@
}
],
"source": [
"df = pl.read_csv('../datasets/spam.csv')\n",
"df = pl.read_csv('../../datasets/spam.csv')\n",
"df"
]
},
Expand Down
38 changes: 14 additions & 24 deletions notebooks/notebook_03.ipynb → notebooks/00-spam/notebook_03.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -44,7 +44,7 @@
},
{
"cell_type": "code",
"execution_count": 24,
"execution_count": 3,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -120,9 +120,16 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 4,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"MovieWriter imagemagick unavailable; using Pillow instead.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
Expand Down Expand Up @@ -206,34 +213,17 @@
" return ax, pbest_plot, p_plot, p_arrow, gbest_plot\n",
" \n",
"anim = FuncAnimation(fig, animate, frames=list(range(1,50)), interval=500, blit=False, repeat=True)\n",
"anim.save(\"resources/PSO.gif\", dpi=120, writer=\"imagemagick\")\n",
"anim.save(\"../resources/PSO.gif\", dpi=120, writer=\"imagemagick\")\n",
" \n",
"print(\"PSO found best solution at f({})={}\".format(gbest, gbest_obj))\n",
"print(\"Global optimal at f({})={}\".format([x_min,y_min], f(x_min,y_min)))"
]
},
{
"cell_type": "code",
"execution_count": 11,
"cell_type": "markdown",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<img src=\"resources/PSO.gif\" />"
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Displaying animation\n",
"HTML('<img src=\"resources/PSO.gif\" />')"
"![title](../resources/PSO.gif)"
]
},
{
Expand Down Expand Up @@ -264,7 +254,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.18"
"version": "3.10.12"
},
"orig_nbformat": 4
},
Expand Down
1 change: 1 addition & 0 deletions notebooks/00-spam/notebook_04.ipynb

Large diffs are not rendered by default.

66 changes: 30 additions & 36 deletions notebooks/notebook_05.ipynb → notebooks/00-spam/notebook_05.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
},
{
"cell_type": "code",
"execution_count": 30,
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -60,7 +60,7 @@
},
{
"cell_type": "code",
"execution_count": 31,
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -70,7 +70,7 @@
},
{
"cell_type": "code",
"execution_count": 32,
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -79,7 +79,7 @@
},
{
"cell_type": "code",
"execution_count": 33,
"execution_count": 4,
"metadata": {},
"outputs": [
{
Expand All @@ -101,7 +101,7 @@
},
{
"cell_type": "code",
"execution_count": 34,
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -131,21 +131,14 @@
},
{
"cell_type": "code",
"execution_count": 35,
"execution_count": 6,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
" 0%| | 0/300 [00:00<?, ?it/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"100%|██████████| 300/300 [00:03<00:00, 90.32it/s]"
"100%|██████████| 300/300 [00:03<00:00, 90.18it/s]"
]
},
{
Expand All @@ -171,7 +164,7 @@
},
{
"cell_type": "code",
"execution_count": 36,
"execution_count": 7,
"metadata": {},
"outputs": [
{
Expand All @@ -195,7 +188,7 @@
},
{
"cell_type": "code",
"execution_count": 37,
"execution_count": 8,
"metadata": {},
"outputs": [
{
Expand All @@ -213,7 +206,7 @@
},
{
"cell_type": "code",
"execution_count": 38,
"execution_count": 9,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -249,14 +242,14 @@
},
{
"cell_type": "code",
"execution_count": 39,
"execution_count": 10,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"100%|██████████| 1000/1000 [00:00<00:00, 84548.94it/s]"
"100%|██████████| 1000/1000 [00:00<00:00, 90558.42it/s]"
]
},
{
Expand All @@ -282,7 +275,7 @@
},
{
"cell_type": "code",
"execution_count": 40,
"execution_count": 11,
"metadata": {},
"outputs": [
{
Expand All @@ -306,7 +299,7 @@
},
{
"cell_type": "code",
"execution_count": 41,
"execution_count": 12,
"metadata": {},
"outputs": [
{
Expand All @@ -324,7 +317,7 @@
},
{
"cell_type": "code",
"execution_count": 42,
"execution_count": 13,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -356,14 +349,15 @@
},
{
"cell_type": "code",
"execution_count": 43,
"execution_count": 14,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"100%|██████████| 300/300 [00:01<00:00, 240.99it/s]"
" 0%| | 0/300 [00:00<?, ?it/s]An NVIDIA GPU may be present on this machine, but a CUDA-enabled jaxlib is not installed. Falling back to cpu.\n",
"100%|██████████| 300/300 [00:03<00:00, 78.26it/s] "
]
},
{
Expand All @@ -389,7 +383,7 @@
},
{
"cell_type": "code",
"execution_count": 44,
"execution_count": 15,
"metadata": {},
"outputs": [
{
Expand All @@ -413,7 +407,7 @@
},
{
"cell_type": "code",
"execution_count": 45,
"execution_count": 16,
"metadata": {},
"outputs": [
{
Expand All @@ -431,7 +425,7 @@
},
{
"cell_type": "code",
"execution_count": 46,
"execution_count": 17,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -467,14 +461,14 @@
},
{
"cell_type": "code",
"execution_count": 47,
"execution_count": 18,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
" 1%| | 1/100 [00:00<00:19, 5.19it/s]"
" 1%| | 1/100 [00:00<00:52, 1.90it/s]"
]
},
{
Expand All @@ -500,7 +494,7 @@
},
{
"cell_type": "code",
"execution_count": 48,
"execution_count": 19,
"metadata": {},
"outputs": [
{
Expand All @@ -524,7 +518,7 @@
},
{
"cell_type": "code",
"execution_count": 49,
"execution_count": 20,
"metadata": {},
"outputs": [
{
Expand All @@ -549,7 +543,7 @@
},
{
"cell_type": "code",
"execution_count": 50,
"execution_count": 21,
"metadata": {},
"outputs": [
{
Expand All @@ -575,7 +569,7 @@
},
{
"cell_type": "code",
"execution_count": 51,
"execution_count": 22,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -585,14 +579,14 @@
},
{
"cell_type": "code",
"execution_count": 52,
"execution_count": 23,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
" 2%|▏ | 2/100 [00:00<00:02, 39.91it/s]"
" 2%|▏ | 2/100 [00:00<00:29, 3.31it/s]"
]
},
{
Expand All @@ -618,7 +612,7 @@
},
{
"cell_type": "code",
"execution_count": 53,
"execution_count": 24,
"metadata": {},
"outputs": [
{
Expand Down
Loading

0 comments on commit 0c87147

Please sign in to comment.