-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathKitsune.cpp
More file actions
26 lines (22 loc) · 878 Bytes
/
Copy pathKitsune.cpp
File metadata and controls
26 lines (22 loc) · 878 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include "Kitsune.h"
Kitsune::Kitsune(const std::string &file_path, double limit,
size_t max_autoencoder_size, size_t FM_grace_period,
size_t AD_grace_period, double learning_rate,
double hidden_ratio) {
// 初始化数据包特征提取器(AfterImage)
this->FE = std::make_unique<FeatureExtractor>(file_path, limit);
// 初始化KitNET
this->AnomDetector = std::make_unique<KitNET>(
this->FE->get_num_features(), max_autoencoder_size, FM_grace_period,
AD_grace_period, learning_rate, hidden_ratio, nullptr);
}
double Kitsune::proc_next_packet() {
// 创建特征向量
std::vector<double> x = this->FE->get_next_vector();
if (x.empty()) {
return -1; // 错误或没有更多数据包
}
// 处理KitNET
// 将在宽限期内训练,然后对其余所有执行检测
return this->AnomDetector->process(x);
}