Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- \documentclass{ieeeaccess}
- % \usepackage{longtable}
- % \usepackage[utf8]{inputenc}
- % \usepackage[a4paper,left=2.9cm,right=2cm,top=2cm,bottom=2.25cm]{geometry}
- \usepackage{caption}
- % \usepackage{lipsum} % for dummy text
- % \usepackage{graphicx}
- % \usepackage{mathtools} % amsmath with extensions
- % \usepackage{amsfonts} % (otherwise \mathbb does nothing)
- % \usepackage{amsmath}
- % \usepackage{amssymb}
- % % \usepackage{natbib}
- % \usepackage{longtable}
- % \usepackage{lipsum}
- % \usepackage{float}
- % \usepackage[utf8]{inputenc}
- \usepackage{longtable}
- % \usepackage{xcolor}
- % \usepackage{xcolor,colortbl}
- \usepackage[usenames,dvipsnames]{xcolor,colortbl}
- % \definecolor{LightBlue}{rgb}{0.88,0.92,0.96} % Define a light blue color
- \usepackage{fancyhdr}
- \pagestyle{fancy}
- \fancyhf{}
- % \renewcommand{\headrulewidth}{0pt} % Removes the header rule
- \usepackage{booktabs} % For prettier tables
- \usepackage{makecell} % Allows for line breaks within table cells
- \usepackage{tabularx} % For tables that span the width of the page
- \usepackage{subcaption}
- \captionsetup{compatibility=false}
- % \usepackage[sort&compress,square,comma,authoryear]{natbib}
- \usepackage{authblk}
- % \usepackage{svg}
- % \usepackage{lineno}
- % \linenumbers
- % \usepackage{gensymb}%https://www.overleaf.com/project/6544eab4f0a2f7eb166b931b
- % \usepackage{amsmath}
- % \usepackage{algpseudocode}
- \usepackage{algorithm}
- \usepackage{algorithmic}
- % \usepackage{subfig}
- \usepackage{url}
- \usepackage{comment}
- % \usepackage{lineno}
- % % \linenumbers
- \usepackage[hidelinks]{hyperref}
- \usepackage{multirow}
- \usepackage{cite}
- \usepackage{amsmath,amssymb,amsfonts}
- \usepackage{algorithmic}
- \usepackage{graphicx}
- \usepackage{textcomp}
- These are packages causing conflict. Please fix them and also fix this algo
- \begin{algorithm}[!htb]
- \caption{Balance Dataset with ADASYN}
- \label{algo:ADASYN}
- \DontPrintSemicolon
- \KwIn{Imbalanced DataFrame \texttt{df}}
- \KwOut{Balanced DataFrame \texttt{balanced\_df}}
- \BlankLine
- \textbf{Print:} ``Applying ADASYN for class balancing...'' \;
- \BlankLine
- \textbf{Prepare features and label:} \;
- \If{\texttt{"label"} in df.columns}{
- $X \leftarrow \texttt{df.drop(["label", "attack\_cat"], axis=1)}$ \;
- }
- \Else{
- $X \leftarrow \texttt{df.drop(["attack\_cat"], axis=1)}$ \;
- }
- $y \leftarrow \texttt{df["attack\_cat"]}$ \;
- \BlankLine
- \textbf{Apply ADASYN:} \;
- adasyn $\leftarrow$ ADASYN(random\_state=42, n\_neighbors=5) \;
- $X_{\text{resampled}}, y_{\text{resampled}} \leftarrow$ adasyn.fit\_resample($X$, $y$) \;
- \BlankLine
- \textbf{Create balanced dataframe:} \;
- balanced\_df $\leftarrow$ DataFrame($X_{\text{resampled}}$, columns=$X$.columns) \;
- balanced\_df[``attack\_cat"] $\leftarrow y_{\text{resampled}}$ \;
- \BlankLine
- \textbf{Print:} ``After ADASYN: \texttt{balanced\_df.shape[0]} records'' \;
- \textbf{Print:} ``Balanced attack distribution: \texttt{balanced\_df["attack\_cat"].value\_counts().to\_dict()}'' \;
- \Return balanced\_df \;
- \end{algorithm}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement