1 Star 0 Fork 0

烟雨江南 / OneClassSVM

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
UseModel_2.py 1.01 KB
一键复制 编辑 原始数据 按行查看 历史
mridul22 提交于 2017-11-19 19:35 . First commit
# coding: utf-8
import numpy as np
import pandas as pd
from sklearn import utils
import matplotlib
#Read csv file using pandas
read_data = pd.read_csv('Test_file_without_class.csv', low_memory=False)
print("Data File read successfully.")
from sklearn.externals import joblib
model = joblib.load('one_class_svm_2.model')
print("Loaded the One Class SVM Model successfully.")
applicable_features = [
"duration",
"src_bytes",
"dst_bytes" ]
read_data = read_data[applicable_features]
# normalise the read_data - which leads to better accuracy and reduces numerical instability.
read_data["duration"] = np.log((read_data["duration"] + 0.1).astype(float))
read_data["src_bytes"] = np.log((read_data["src_bytes"] + 0.1).astype(float))
read_data["dst_bytes"] = np.log((read_data["dst_bytes"] + 0.1).astype(float))
# then predict with
values = (model.predict(read_data))
with open('predicted.txt','w+') as f:
for value in values:
f.write(str(value) + '\n')
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/yanyu_jiangnan/OneClassSVM.git
git@gitee.com:yanyu_jiangnan/OneClassSVM.git
yanyu_jiangnan
OneClassSVM
OneClassSVM
master

搜索帮助

344bd9b3 5694891 D2dac590 5694891