1 Star 0 Fork 1

wszhs/adversarial-attack-on-IDS

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
train_ids_gbt.py 1.07 KB
一键复制 编辑 原始数据 按行查看 历史
dlshu 提交于 2020-06-09 01:22 . Add files via upload
import numpy as np
import torch
import sys
import torch.nn as nn
import matplotlib.pyplot as plt
import torch.nn.functional as F
import torch.optim as optim
from torch.utils import data
from torchvision import transforms
from torch.utils.data import DataLoader, Dataset
from torch.autograd import Variable
import time
import math
import pickle
from sklearn.ensemble import GradientBoostingClassifier
from utils import *
from models import *
cuda = torch.cuda.is_available()
device = torch.device('cuda' if cuda else 'cpu')
# Hyperparameters of the code
b_m_ratio=2
gbt_ids_model_dir = './trained_models/gbt_ids_model.pkl'
X_tr_pool, Y_tr_pool, X_te, Y_te = create_datasets(train_ratio=0.8, b_m_ratio=b_m_ratio)
# train gradient boosted tree ids model
gbt_ids_model = GradientBoostingClassifier(n_estimators=100, learning_rate=1.0, max_depth=4, random_state=0).fit(X_tr_pool, Y_tr_pool)
test_acc_gbt = gbt_ids_model.score(X_te, Y_te)
print("Test accuracy of gradient boosted tree IDS: {:.2f}%".format(test_acc_gbt))
# with open(gbt_ids_model_dir, 'wb') as f:
# pickle.dump(gbt_ids_model, f)
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/zhanghangsheng/adversarial-attack-on-IDS.git
git@gitee.com:zhanghangsheng/adversarial-attack-on-IDS.git
zhanghangsheng
adversarial-attack-on-IDS
adversarial-attack-on-IDS
master

搜索帮助