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

news2024/11/27 12:34:12

文章目录

  • 数据集介绍
  • 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

在这里插入图片描述

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

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

Java Web学习笔记26——Element常用组件

常见组件&#xff1a; 就是一个复制和粘贴的过程。 Table表格&#xff1a;用于展示多条结构类的数据&#xff0c;可对数据进行排序、筛选、对比或其他自定义操作。 常见组件-分页主键&#xff1a; Pagination&#xff1a;分页&#xff1a;当数据量比较多时&#xff0c;使用分…

第七届全国颗粒材料计算力学会议召开,DEMms多尺度离散模拟软件受关注

近日&#xff0c;第七届全国颗粒材料计算力学会议暨第四届计算颗粒技术国际研讨会在南京召开。会议聚焦颗粒材料的力学理论及模型、计算分析与软件开发、工程应用和相关前沿方向中的关键科学问题和难点技术问题&#xff0c;开展广泛的学术交流和讨论。 会议期间&#xff0c;积鼎…

【Python列表解锁】:掌握序列精髓,驾驭动态数据集合

文章目录 &#x1f680;一、列表&#x1f308;二、常规操作&#x1f4a5;增&#x1f4a5;删&#x1f4a5;改&#x1f4a5;查 ⭐三、补充操作 &#x1f680;一、列表 列表是一个能够存储多个同一或不同元素的序列 列表&#xff1a;list ---- [] 列表属于序列类型&#xff08;容器…

WWDC 2024前瞻:苹果如何用AI技术重塑iOS 18和Siri

苹果下周的全球开发者大会有望成为这家 iPhone 制造商历史上的关键时刻。在 WWDC 上&#xff0c;这家库比蒂诺科技巨头将展示如何选择将人工智能技术集成到其设备和软件中&#xff0c;包括通过与 OpenAI 的历史性合作伙伴关系。随着重大事件的临近&#xff0c;有关 iOS 18 及其…

高能来袭|联想拯救者携手《黑神话:悟空》玩转东方神话世界

从2020年首次发布实机演示视频以来&#xff0c;《黑神话&#xff1a;悟空》便在全球范围内获得了广泛关注&#xff0c;成为国产3A游戏的现象级爆款。6月&#xff0c;联想拯救者正式宣布成为《黑神话&#xff1a;悟空》全球官方合作伙伴&#xff0c;致力于共同革新国产游戏体验&…

老师必备!一文教你如何高效收集志愿填报信息

高考志愿填报季&#xff0c;对于每一位老师来说&#xff0c;无疑是一场信息收集与管理的硬仗。如何在众多的志愿信息中&#xff0c;高效、准确地掌握每位学生的志愿意向&#xff1f; 高考志愿填报的重要性。不仅是学生人生的一个重要转折点&#xff0c;也是老师教育生涯中的一次…

Elasticsearch 认证模拟题 - 15

一、题目 原索引 task1 的字段 title 字段包含单词 The&#xff0c;查询 the 可以查出 1200 篇文档。重建 task1 索引为 task1_new&#xff0c;重建后的索引&#xff0c; title 字段查询 the 单词&#xff0c;不能匹配到任何文档。 PUT task1 {"mappings": {"…

Latex中表格(3)

Latex中的表格 一、多行或多列单元格 这篇主要说Latex中表格出现多行或者多列单元格的形式. 一、多行或多列单元格 可能用到的宏包 \usepackage{booktabs}\usepackage{multirow} 代码&#xff1a; \begin{table}[h!] \centering \caption{Your caption here} \begin{tabul…

斯坦福天才少女创5亿独角兽!Pika获8000万融资,金牌团队首曝光

斯坦福天才少女创立的公司Pika&#xff0c;继续书写传奇。 GPT-4o深夜发布&#xff01;Plus免费可用&#xff01;https://www.zhihu.com/pin/1773645611381747712 没体验过OpenAI最新版GPT-4o&#xff1f;快戳最详细升级教程&#xff0c;几分钟搞定&#xff1a;升级ChatGPT-4o …

地图之战争迷雾/地图算法/自动导航(一)

战争迷雾 TiledMap 创建黑色覆盖块&#xff0c;然后使用碰撞组件&#xff0c;控制黑色块的显示和隐藏 地图算法 在有些游戏中&#xff0c;地图需要随机生成&#xff0c;比如游戏中的迷宫等&#xff0c;这就需要地图生成的算法&#xff1b;在角色扮演类游戏中&#xff0c;角色…

【AIGC】基于大模型+知识库的Code Review实践

一、背景描述 一句话介绍就是&#xff1a;基于开源大模型 知识库的 Code Review 实践&#xff0c;类似一个代码评审助手&#xff08;CR Copilot&#xff09;。信息安全合规问题&#xff1a;公司内代码直接调 ChatGPT / Claude 会有安全/合规问题&#xff0c;为了使用 ChatGPT…

华为云服务器-云容器引擎 CCE环境构建及项目部署

1、切换地区 2、搜索云容器引擎 CCE 3、购买集群 4、创建容器节点 通过漫长的等待(五分钟左右)&#xff0c;由创建中变为运行中&#xff0c;则表明容器已经搭建成功 购买成功后&#xff0c;返回容器控制台界面 5、节点容器管理 6、创建redis工作负载 7、创建mysql工作负载 8、…

C#使用GDI对一个矩形进行任意角度旋转

C#对一个矩形进行旋转GDI绘图&#xff0c;可以指定任意角度进行旋转 我们可以认为一张图片Image&#xff0c;本质就是一个矩形Rectangle,旋转矩形也就是旋转图片 在画图密封类 System.Drawing.Graphics中&#xff0c; 矩形旋转的两个关键方法 //设置旋转的中心点 public v…

MySQL-相关日志

官方文档 1、MySQL支持的日志 MySQL有不同类型日志文件&#xff0c;用来存储不同类型的日志&#xff0c;分别为 二进制日志、错误日志、通用查询日志、慢查询日志、中继日志、数据定义语句日志 慢查询日志&#xff1a;记录所有执行时间超过 long_query_time的所有查询&#xf…

单元测试覆盖率

什么是单元测试覆盖率 关于其定义&#xff0c;先来看一下维基百科上的一段描述&#xff1a; 代码覆盖&#xff08;Code coverage&#xff09;是软件测试中的一种度量&#xff0c;描述程序中源代码被测试的比例和程度&#xff0c;所得比例称为代码覆盖率。 简单来理解&#xff…

【微信小程序】事件绑定和事件对象

文章目录 1.什么是事件绑定2.button组件3.事件绑定4.input组件 1.什么是事件绑定 小程序中绑定事件与在网页开发中绑定事件几乎一致&#xff0c;只不过在小程序不能通过on的方式绑定事件&#xff0c;也没有click等事件&#xff0c;小程序中 绑定事件使用bind方法&#xff0c;c…

反转链表 (oj题)

一、题目链接 https://leetcode.cn/problems/reverse-linked-list/submissions/538124207 二、题目思路 1.定义三个指针&#xff0c;p1先指向NULL p2指向头结点 p3指向第二个结点 2.p2的next指向p1。然后移动指针&#xff0c;p1来到p2的位置&#xff0c;p2来到p3的位置&…

双列集合基础知识

package exercise;import java.util.HashMap; import java.util.Map;public class Demo1 {public static void main(String[] args) {Map<String, String> map new HashMap<>();//在添加数据的时候&#xff0c;如果键不存在&#xff0c;那么直接把键值对对象添加到…

小主机折腾记25

10.买了惠普光驱&#xff0c;想给880g5twr安装上&#xff0c;结果发现卡扣不对 880g5twr的卡扣更长一些&#xff0c;比光驱本身长一些&#xff0c;各位如果想买的注意擦亮眼睛&#xff0c;看看卡扣跟你的主机一致与否 后续在闲鱼上买了个卡扣&#xff0c;加邮费12块钱…… 1…

手搓文件格式转换

最初目标&#xff1a; 自己搞一个免费的pdf文件转换 根据现有的开源jar 项目实现思路&#xff1a; 1. 项目原因a. 我想转换文件b. wps 文件转换 2. 最初的状态a. jar运行的b. main,输入文件路径c. 一定的编程能力的人才能得 3. 开始构思项目a. 网页版本b. 想着大家一起用 4. …