代码拉取完成,页面将自动刷新
# 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')
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。