【深度学习】CICIDS 2019,入侵检测,SVM支持向量机,随机森林,DNN训练,混淆矩阵

文章目录

  • 数据集介绍
  • Python环境
  • 随机森林训练结果
  • SVM支持向量机训练结果
  • DNN训练结果
  • 所有代码下载

数据集介绍

下载:https://www.kaggle.com/datasets/tarundhamor/cicids-2019-dataset

数据个数:

    # 删除label中是WebDDoS的数据
    df = df[df['Label'] != 'WebDDoS']

在这里插入图片描述

Python环境

pandas
scipy
scikit-learn==1.3
torch
matplotlib
seaborn
numpy

随机森林训练结果

特征重要程度:
Max Packet Length: 0.0684
Packet Length Mean: 0.0637
Avg Fwd Segment Size: 0.0579
Fwd Packet Length Max: 0.0569
Average Packet Size: 0.0569
Subflow Fwd Bytes: 0.0522
Fwd Packet Length Min: 0.0505
Fwd Packet Length Mean: 0.0501
Min Packet Length: 0.0474
Total Length of Fwd Packets: 0.0401
act_data_pkt_fwd: 0.0301
ACK Flag Count: 0.0300
Flow Bytes/s: 0.0263
Init_Win_bytes_forward: 0.0232
Inbound: 0.0224
Flow IAT Max: 0.0210
Flow IAT Std: 0.0193
Flow IAT Min: 0.0182
Fwd IAT Max: 0.0169
Flow IAT Mean: 0.0162
Total Fwd Packets: 0.0162
Protocol: 0.0161
Flow Duration: 0.0156
Fwd IAT Min: 0.0155
Fwd IAT Total: 0.0146
Fwd IAT Std: 0.0144
Subflow Fwd Packets: 0.0125
Fwd IAT Mean: 0.0121
Fwd Packets/s: 0.0120
Flow Packets/s: 0.0115
URG Flag Count: 0.0086
Bwd Packets/s: 0.0083
Packet Length Variance: 0.0076
min_seg_size_forward: 0.0067
Init_Win_bytes_backward: 0.0058
Bwd Header Length: 0.0052
Total Backward Packets: 0.0044
Packet Length Std: 0.0044
Bwd IAT Total: 0.0036
Subflow Bwd Bytes: 0.0034
Down/Up Ratio: 0.0028
Bwd IAT Max: 0.0026
Avg Bwd Segment Size: 0.0023
Bwd IAT Mean: 0.0021
Bwd Packet Length Max: 0.0021
Fwd Packet Length Std: 0.0019
Total Length of Bwd Packets: 0.0019
Bwd Packet Length Mean: 0.0018
Fwd Header Length.1: 0.0017
CWE Flag Count: 0.0017
Fwd Header Length: 0.0017
Subflow Bwd Packets: 0.0016
Bwd IAT Min: 0.0015
Idle Std: 0.0012
Bwd Packet Length Min: 0.0011
Idle Max: 0.0011
Active Min: 0.0008
Bwd IAT Std: 0.0008
Active Mean: 0.0006
Idle Mean: 0.0006
Idle Min: 0.0004
Bwd Packet Length Std: 0.0004
Fwd PSH Flags: 0.0003
RST Flag Count: 0.0003
Active Max: 0.0001
Active Std: 0.0001
SYN Flag Count: 0.0001
Bwd PSH Flags: 0.0000
Fwd URG Flags: 0.0000
Bwd URG Flags: 0.0000
FIN Flag Count: 0.0000
PSH Flag Count: 0.0000
ECE Flag Count: 0.0000
Fwd Avg Bytes/Bulk: 0.0000
Fwd Avg Packets/Bulk: 0.0000
Fwd Avg Bulk Rate: 0.0000
Bwd Avg Bytes/Bulk: 0.0000
Bwd Avg Packets/Bulk: 0.0000
Bwd Avg Bulk Rate: 0.0000
SimillarHTTP: 0.0000
{'BENIGN': {'precision': 0.9965305156915313, 'recall': 0.9992093611638204, 'f1-score': 0.9978681405448085, 'support': 6324.0}, 'DrDoS_DNS': {'precision': 0.8426485397784491, 'recall': 0.52296875, 'f1-score': 0.6453914384882375, 'support': 6400.0}, 'DrDoS_LDAP': {'precision': 0.4552080170057698, 'recall': 0.70265625, 'f1-score': 0.5524909392468825, 'support': 6400.0}, 'DrDoS_MSSQL': {'precision': 0.43775933609958506, 'recall': 0.0659375, 'f1-score': 0.11461162411732753, 'support': 6400.0}, 'DrDoS_NTP': {'precision': 0.9717636167258139, 'recall': 0.9840625, 'f1-score': 0.9778743886344227, 'support': 6400.0}, 'DrDoS_NetBIOS': {'precision': 0.8055891441623001, 'recall': 0.936875, 'f1-score': 0.8662862096366395, 'support': 6400.0}, 'DrDoS_SNMP': {'precision': 0.9993749023284888, 'recall': 0.99921875, 'f1-score': 0.9992968200640675, 'support': 6400.0}, 'DrDoS_SSDP': {'precision': 0.6196612283071807, 'recall': 0.93171875, 'f1-score': 0.744305061474131, 'support': 6400.0}, 'Syn': {'precision': 0.9995313964386129, 'recall': 0.99984375, 'f1-score': 0.9996875488204968, 'support': 6400.0}, 'UDP-lag': {'precision': 0.6013483146067415, 'recall': 0.418125, 'f1-score': 0.4932718894009216, 'support': 6400.0},
'lDos': {'precision': 0.5524492234169653, 'recall': 0.7225, 'f1-score': 0.6261340555179418, 'support': 6400.0}, 'accuracy': 0.7527444400204767, 'macro avg': {'precision': 0.7528967485964944, 'recall': 0.7530105101058019, 'f1-score': 0.7288380105405342, 'support': 70324.0}, 'weighted avg': {'precision': 0.7526334506285287, 'recall': 0.7527444400204767, 'f1-score': 0.7285472664150532, 'support': 70324.0}}
整体准确率: 0.75
平均准确率: 0.75, 平均召回率: 0.75

Process finished with exit code 0

SVM支持向量机训练结果


{'BENIGN': {'precision': 0.9767441860465116, 'recall': 0.6402439024390244, 'f1-score': 0.7734806629834254, 'support': 656.0}, 'DrDoS_DNS': {'precision': 0.7, 'recall': 0.010869565217391304, 'f1-score': 0.021406727828746176, 'support': 644.0}, 'DrDoS_LDAP': {'precision': 0.31919406150583246, 'recall': 0.9525316455696202, 'f1-score': 0.4781572676727562, 'support': 632.0}, 'DrDoS_MSSQL': {'precision': 0.0, 'recall': 0.0, 'f1-score': 0.0, 'support': 652.0}, 'DrDoS_NTP': {'precision': 0.688212927756654, 'recall': 0.8418604651162791, 'f1-score': 0.7573221757322176, 'support': 645.0}, 'DrDoS_NetBIOS': {'precision': 0.7403100775193798, 'recall': 0.8995290423861853, 'f1-score': 0.81218993621545, 'support': 637.0}, 'DrDoS_SNMP': {'precision': 0.9861111111111112, 'recall': 1.0, 'f1-score': 0.993006993006993, 'support': 639.0}, 'DrDoS_SSDP': {'precision': 0.6170212765957447, 'recall': 0.23311897106109325, 'f1-score': 0.338389731621937, 'support': 622.0}, 'Syn': {'precision': 0.6777301927194861, 'recall': 1.0, 'f1-score': 0.8079132099553287, 'support': 633.0}, 'UDP-lag': {'precision': 0.4148148148148148, 'recall': 0.17582417582417584, 'f1-score': 0.24696802646086002, 'support': 637.0},
'lDos': {'precision': 0.4900662251655629, 'recall': 0.8144654088050315, 'f1-score': 0.61193148257531, 'support': 636.0}, 'accuracy': 0.5960472060287217, 'macro avg': {'precision': 0.6009277157486452, 'recall': 0.5971311978562547, 'f1-score': 0.5309787467320931, 'support': 7033.0}, 'weighted avg': {'precision': 0.6011068239694879, 'recall': 0.5960472060287217, 'f1-score': 0.5306623678089073, 'support': 7033.0}}
整体准确率: 0.60
平均准确率: 0.60, 平均召回率: 0.60
==============================
svm_classification

Macro-average Precision: 0.6014285714285714
Macro-average Recall: 0.5971428571428571

Process finished with exit code 0

DNN训练结果

C:\ProgramData\miniconda3\envs\dlib_align\python.exe C:\Users\Administrator\PycharmProjects\pythonProject3\cicids2019\x07_0DNN训练.py
训练数据的总数据形状 torch.Size([281292, 56])
训练数据的标签形状 torch.Size([281292, 11])
测试数据的总数据形状 torch.Size([70324, 56])
测试数据的标签形状 torch.Size([70324, 11])
Training Progress:   3%|| 1/30 [00:23<11:09, 23.10s/it]Epoch 1/30, Loss: 0.7203, Accuracy: 0.70
Training Progress:   7%|| 2/30 [00:45<10:29, 22.48s/it]Epoch 2/30, Loss: 0.6408, Accuracy: 0.70
Epoch 3/30, Loss: 0.6217, Accuracy: 0.71
Training Progress:  13%|█▎        | 4/30 [01:29<09:36, 22.18s/it]Epoch 4/30, Loss: 0.6075, Accuracy: 0.72
Epoch 5/30, Loss: 0.5966, Accuracy: 0.72
Training Progress:  20%|██        | 6/30 [02:13<08:49, 22.05s/it]Epoch 6/30, Loss: 0.5975, Accuracy: 0.72
Training Progress:  23%|██▎       | 7/30 [02:34<08:25, 22.00s/it]Epoch 7/30, Loss: 0.5947, Accuracy: 0.72
Epoch 8/30, Loss: 0.6020, Accuracy: 0.72
Training Progress:  30%|███       | 9/30 [03:18<07:41, 21.99s/it]Epoch 9/30, Loss: 0.6100, Accuracy: 0.72
Training Progress:  33%|███▎      | 10/30 [03:40<07:18, 21.90s/it]Epoch 10/30, Loss: 0.6152, Accuracy: 0.72
Training Progress:  37%|███▋      | 11/30 [04:03<06:59, 22.10s/it]Epoch 11/30, Loss: 0.6161, Accuracy: 0.71
Epoch 12/30, Loss: 0.6089, Accuracy: 0.72
Training Progress:  43%|████▎     | 13/30 [04:45<06:06, 21.54s/it]Epoch 13/30, Loss: 0.6007, Accuracy: 0.71
Epoch 14/30, Loss: 0.5893, Accuracy: 0.72
Training Progress:  50%|█████     | 15/30 [05:27<05:20, 21.34s/it]Epoch 15/30, Loss: 0.5800, Accuracy: 0.73
Training Progress:  53%|█████▎    | 16/30 [05:48<04:59, 21.38s/it]Epoch 16/30, Loss: 0.5779, Accuracy: 0.73
Training Progress:  57%|█████▋    | 17/30 [06:09<04:34, 21.15s/it]Epoch 17/30, Loss: 0.5786, Accuracy: 0.72
Training Progress:  60%|██████    | 18/30 [06:30<04:12, 21.02s/it]Epoch 18/30, Loss: 0.5861, Accuracy: 0.72
Training Progress:  63%|██████▎   | 19/30 [06:50<03:50, 20.92s/it]Epoch 19/30, Loss: 0.5963, Accuracy: 0.72
Epoch 20/30, Loss: 0.6042, Accuracy: 0.71
Training Progress:  70%|███████   | 21/30 [07:30<03:03, 20.43s/it]Epoch 21/30, Loss: 0.6054, Accuracy: 0.71
Epoch 22/30, Loss: 0.6027, Accuracy: 0.72
Training Progress:  77%|███████▋  | 23/30 [08:11<02:23, 20.44s/it]Epoch 23/30, Loss: 0.5938, Accuracy: 0.72
Training Progress:  80%|████████  | 24/30 [08:32<02:02, 20.42s/it]Epoch 24/30, Loss: 0.5836, Accuracy: 0.72
Epoch 25/30, Loss: 0.5760, Accuracy: 0.73
Training Progress:  87%|████████▋ | 26/30 [09:12<01:21, 20.39s/it]Epoch 26/30, Loss: 0.5753, Accuracy: 0.73
Epoch 27/30, Loss: 0.5745, Accuracy: 0.73
Training Progress:  93%|█████████▎| 28/30 [09:53<00:40, 20.43s/it]Epoch 28/30, Loss: 0.5813, Accuracy: 0.73
Epoch 29/30, Loss: 0.5922, Accuracy: 0.70
Training Progress: 100%|██████████| 30/30 [10:34<00:00, 21.15s/it]
Epoch 30/30, Loss: 0.5993, Accuracy: 0.71
{'0': {'precision': 0.988443881589362, 'recall': 0.9873497786211258, 'f1-score': 0.987896527173483, 'support': 6324.0}, '1': {'precision': 0.6740442655935613, 'recall': 0.41875, 'f1-score': 0.5165767154973014, 'support': 6400.0}, '2': {'precision': 0.42294757665677546, 'recall': 0.668125, 'f1-score': 0.5179890975166566, 'support': 6400.0}, '3': {'precision': 0.4377224199288256, 'recall': 0.0384375, 'f1-score': 0.07066934788853778, 'support': 6400.0}, '4': {'precision': 0.9512785072563925, 'recall': 0.8603125, 'f1-score': 0.9035116508040696, 'support': 6400.0}, '5': {'precision': 0.760898282694848, 'recall': 0.9, 'f1-score': 0.8246241947029349, 'support': 6400.0}, '6': {'precision': 0.9897706137631742, 'recall': 0.9978125, 'f1-score': 0.9937752878929349, 'support': 6400.0}, '7': {'precision': 0.5691368959748057, 'recall': 0.90359375, 'f1-score': 0.6983877785157901, 'support': 6400.0}, '8': {'precision': 0.9998436522826767, 'recall': 0.99921875, 'f1-score': 0.9995311034698343, 'support': 6400.0}, '9': {'precision': 0.5366459627329192, 'recall': 0.3375, 'f1-score': 0.41438848920863314, 'support': 6400.0},
'10': {'precision': 0.5114308018289283, 'recall': 0.7165625, 'f1-score': 0.5968634086028504, 'support': 6400.0},
'accuracy': 0.711307661680223, 'macro avg': {'precision': 0.7129238963911154, 'recall': 0.7116056616928296, 'f1-score': 0.6840194182975478, 'support': 70324.0}, 'weighted avg': {'precision': 0.7126261386003886, 'recall': 0.711307661680223, 'f1-score': 0.6836910146192221, 'support': 70324.0}}
整体准确率: 0.71
==============================
dnn_classification
Macro-average Precision: 0.7185714285714287
Macro-average Recall: 0.7121428571428573

Process finished with exit code 0

混淆矩阵
在这里插入图片描述

所有代码下载

https://docs.qq.com/sheet/DUEdqZ2lmbmR6UVdU?tab=BB08J2

在这里插入图片描述

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:/a/711616.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

简单的心电图信号分割方法

代码很简单&#xff0c;很容易看懂。 import pandas as pdimport matplotlib.pyplot as plt #headers [Name, Age, Marks]df pd.read_csv(samples-folder/samples2.csv) dfdf.drop(0)dfdf.drop(1)# print(df) if(len(df.columns) 3): df.columns [sample interval, sig…

linux中安装jdk

1.查看jdk是否安装 java -version 2.搜索java yum -y list java* 3. 安装 yum install -y java-1.8.0-openjdk.x86_64 安装完成 验证

2024年实体门店和企业怎么做短视频矩阵?一文带你了解清楚

不知道大家有没有刷到过这个直播间&#xff0c;潮汕一位做牛丸的大哥&#xff0c;看起来直播间内容平平无奇&#xff0c;也就几十个人的直播间观看&#xff0c;但是他通过短视频矩阵的方式卖了150万单牛丸你敢信&#xff1f; 那你猜猜他通过短视频矩阵发了多少条视频&#xff…

python-求f(x,n)

[题目描述] 输入&#xff1a; 输入 &#x1d465;和 &#x1d45b;。输出&#xff1a; 函数值&#xff0c;保留两位小数。样例输入1 4.2 10 样例输出1 3.68 来源/分类&#xff08;难度系数&#xff1a;一星&#xff09; 完整代码如下&#xff1a; x,nmap(eval,input().split(…

记周末百度云防御CC攻击事件

今天一早&#xff0c;收到百度智能云短信提醒&#xff0c;一位客户的网站遭遇了CC攻击。 主机吧赶紧登陆客户网站查看&#xff0c;是否正常&#xff0c;看是否需要通知客户。 结果打开正常&#xff0c;看情况并没什么影响&#xff0c;那就等攻击结果了再看吧。 下午的时候&am…

嵌入式操作系统_6.任务间通信

1.任务间通信管理 任务间通信管理也是嵌入式操作系统的关键功能之一。它主要为操作系统的应用程序提供多种类型的数据传输、任务同步/异步操作等手段。 2.操作系统任务之间的关系 由于嵌入式操作系统是为应用提供管理、硬件支持、协调任务和中断处理程序等功能&#xff0c;具备…

环保绩效评级:ABCD四个等级,你的企业处于哪个水平?

在当下社会&#xff0c;环保问题越来越受到人们的关注和重视。企业作为经济活动的重要参与者&#xff0c;其环保绩效评级直接关系到环境保护的成效。朗观视觉将详细解析环保绩效评级的ABCD四等级&#xff0c;帮助读者了解不同等级的特点和评判标准&#xff0c;进而引导企业提高…

Hexo 搭建个人博客(ubuntu20.04)

1 安装 Nodejs 和 npm 首先登录NodeSource官网&#xff1a; Nodesource Node.js DEB 按照提示安装最新的 Node.js 及其配套版本的 npm。 &#xff08;1&#xff09;以 sudo 用户身份运行下面的命令&#xff0c;下载并执行 NodeSource 安装脚本&#xff1a; sudo curl -fsSL…

Linux笔记--vi编辑器

vi编辑器 基本操作 对于vi编辑器有这几种模式 移动 当编辑一个过大的文件时通过方向键移动光标过慢所以可以使用快捷键进行移动 编辑 dw指令只能在单词第一个字母处使用 D指令删除的是当前行 查找替换 pattern指代想要搜索的内容

Spring Security——结合JWT实现令牌的验证与授权

目录 JWT&#xff08;JSON Web Token&#xff09; 项目总结 新建一个SpringBoot项目 pom.xml PayloadDto JwtUtil工具类 MyAuthenticationSuccessHandler&#xff08;验证成功处理器&#xff09; JwtAuthenticationFilter&#xff08;自定义token过滤器&#xff09; W…

ThinkPHP5.0 apache服务器配置URL重写,index.php去除

本地环境wamp .htaccess文件代码 <IfModule mod_rewrite.c>Options FollowSymlinks -MultiviewsRewriteEngine onRewriteCond %{REQUEST_FILENAME} !-dRewriteCond %{REQUEST_FILENAME} !-fRewriteRule ^(.*)$ index.php?/$1 [QSA,PT,L] </IfModule> 踩过这个坑&a…

第12章.STM32标准库简介

目录 0. 《STM32单片机自学教程》专栏 12.1 CMSIS 标准 12.2 STM32标准库文件结构 12.2.1 主结构 12.2.2 Libraries固件库文件 CMSIS文件夹 1.core_cm3.c&core_cm3.h 2.startup启动文件 3.Stm32f10x.h 4.system_stm32f10x.c&system_stm32f10…

解决用Three.js实现嘴型和语音同步时只能播放部分部位的问题 Three.js同时渲染播放多个组件变形动画的方法

前言 参考这篇文章ThreeJSChatGPT 实现前端3D数字人AI互动&#xff0c;前面搭后端、训练模型组内小伙伴都没有什么问题&#xff0c;到前端的时候&#xff0c;脸部就出问题了。看我是怎么解决的。 好文章啊&#xff0c;可惜百度前几个都找不到&#xff0c;o(╥﹏╥)o 问题情况 …

【C++提高编程-05】----C++之Deque容器实战

&#x1f3a9; 欢迎来到技术探索的奇幻世界&#x1f468;‍&#x1f4bb; &#x1f4dc; 个人主页&#xff1a;一伦明悦-CSDN博客 ✍&#x1f3fb; 作者简介&#xff1a; C软件开发、Python机器学习爱好者 &#x1f5e3;️ 互动与支持&#xff1a;&#x1f4ac;评论 &…

ubuntu vnc

如何在Ubuntu 18.04安装VNC | myfreax sudo apt install xfce4 xfce4-goodies xorg dbus-x11 x11-xserver-utils sudo apt install tigervnc-standalone-server tigervnc-common vncserver sudo apt install xfce4 xfce4-goodies xorg dbus-x11 x11-xserver-utils sudo apt ins…

用Python向Word文档添加页眉和页脚

用Python向Word文档添加页眉和页脚 添加页眉和页脚效果代码 添加页眉和页脚 在本文中&#xff0c;我们将用python向文档中添加页眉和页脚。 效果 添加前的文档&#xff1a; 添加页眉和页脚后&#xff1a; 代码 from docx import Documentdef add_header_footer(doc_path…

【数据结构】——常见排序

文章目录 一、 冒泡排序二、 选择排序三、插入排序四、 快速排序1. hoare版本2. 优化版本3. 前后指针法4. 非递归版本 五、 堆排序六、 希尔排序七、 归并排序1. 递归版本2. 非递归版本 八、 计数排序 在开始之前先准备一个交换数据的函数&#xff0c;排序会经常用到 //交换位置…

牛客热题:兑换零钱(一)

&#x1f4df;作者主页&#xff1a;慢热的陕西人 &#x1f334;专栏链接&#xff1a;力扣刷题日记 &#x1f4e3;欢迎各位大佬&#x1f44d;点赞&#x1f525;关注&#x1f693;收藏&#xff0c;&#x1f349;留言 文章目录 牛客热题&#xff1a;兑换零钱(一)题目链接方法一&am…

解读ROS功能包模块的步骤

系列文章目录 提示:这里可以添加系列文章的所有文章的目录,目录需要自己手动添加 TODO:写完再整理 文章目录 系列文章目录前言解读ROS功能包模块的步骤前言 认知有限,望大家多多包涵,有什么问题也希望能够与大家多交流,共同成长! 推荐开发经验及方法博客专栏: [https:/…

抢占人工智能行业红利,前阿里巴巴产品专家带你15天入门AI产品经理

前言 当互联网行业巨头纷纷布局人工智能&#xff0c;国家将人工智能上升为国家战略&#xff0c;藤校核心课程涉足人工智能…人工智能领域蕴含着巨大潜力&#xff0c;早已成为业内共识。 面对极大的行业空缺&#xff0c;不少人都希望能抢占行业红利期&#xff0c;进入AI领域。…