Appscanner实验还原code2
import _pickle as pickle
from sklearn import svm, ensemble
import random
from sklearn.metrics import accuracy_score, f1_score, precision_score, recall_score, classification_report, confusion_matrix
import numpy as np ##########
########## #TRAINING_PICKLE = 'motog-old-110-noisefree-statistical.p' # 1
TRAINING_PICKLE = 'trunc-dataset1a-noisefree-statistical.p' #
#TESTING_PICKLE = 'lg-new-new-110-noisefree-statistical.p' # 5
TESTING_PICKLE = 'trunc-dataset2-noisefree-statistical.p' # print('Loading pickles...')
trainingflowlist = pickle.load(open(TRAINING_PICKLE, 'rb'),encoding='iso-8859-1')
testingflowlist = pickle.load(open(TESTING_PICKLE, 'rb'),encoding='iso-8859-1')
print('Done...')
print('') print('Training with ' + TRAINING_PICKLE + ': ' + str(len(trainingflowlist)))
print('Testing with ' + TESTING_PICKLE + ': ' + str(len(testingflowlist)))
print('') p = []
r = []
f = []
a = [] for i in range(10):
########## PREPARE STUFF
trainingexamples = []
#classifier = svm.SVC(gamma=0.001, C=100, probability=True)
classifier = ensemble.RandomForestClassifier() ########## GET FLOWS
for package, time, flow in trainingflowlist:
trainingexamples.append((flow, package)) ########## SHUFFLE DATA to ensure classes are "evenly" distributed
random.shuffle(trainingexamples) ########## TRAINING
X_train = []
y_train = [] for flow, package in trainingexamples:
X_train.append(flow)
y_train.append(package) print('Fitting classifier...')
classifier.fit(X_train, y_train)
print('Classifier fitted!')
print('') ########## TESTING X_test = []
y_test = [] for package, time, flow in testingflowlist:
X_test.append(flow)
y_test.append(package) y_pred = classifier.predict(X_test) print((precision_score(y_test, y_pred, average="macro")))
print((recall_score(y_test, y_pred, average="macro")))
print((f1_score(y_test, y_pred, average="macro")))
print((accuracy_score(y_test, y_pred)))
print('') p.append(precision_score(y_test, y_pred, average="macro"))
r.append(recall_score(y_test, y_pred, average="macro"))
f.append(f1_score(y_test, y_pred, average="macro"))
a.append(accuracy_score(y_test, y_pred)) print(p)
print(r)
print(f)
print(a)
print('') print(np.mean(p))
print(np.mean(r))
print(np.mean(f))
print(np.mean(a))
Appscanner实验还原code2的更多相关文章
- Appscanner实验还原code3
# Author: Baozi #-*- codeing:utf-8 -*- import _pickle as pickle from sklearn import ensemble import ...
- Appscanner实验还原code1
import _pickle as pickle from sklearn import svm, ensemble import random from sklearn.metrics import ...
- 11.2.0.4rac service_name参数修改
环境介绍 )客户环境11. 两节点 rac,集群重启后,集群资源一切正常,应用cs架构,连接数据库报错,提示连接对象不存在 )分析报错原因,连接数据库方式:ip:Port/service_name方式 ...
- RAC环境修改参数生效测试
本篇文档--目的:实验测试在RAC环境下,修改数据库参数与单实例相比,需要注意的地方 --举例说明,在实际生产环境下,以下参数很可能会需要修改 --在安装数据库完成后,很可能没有标准化,初始化文档,没 ...
- vsftp -samba-autofs
摘要: 1.FTP文件传输协议,PAM可插拔认证模块,TFTP简单文件传输协议. 注意:iptables防火墙管理工具默认禁止了FTP传输协议的端口号 2.vsftpd服务程序三种认证模式?三种认证模 ...
- 【故障处理】ORA-12162 错误的处理
[故障处理]ORA-12162: TNS:net service name is incorrectly specified 一.1 场景 今天拿到一个新的环境,可是执行sqlplus / as s ...
- SDUT OJ 数据结构实验之二叉树四:(先序中序)还原二叉树
数据结构实验之二叉树四:(先序中序)还原二叉树 Time Limit: 1000 ms Memory Limit: 65536 KiB Submit Statistic Discuss Problem ...
- SDUT 3343 数据结构实验之二叉树四:还原二叉树
数据结构实验之二叉树四:还原二叉树 Time Limit: 1000MS Memory Limit: 65536KB Submit Statistic Problem Description 给定一棵 ...
- SDUT-3343_数据结构实验之二叉树四:(先序中序)还原二叉树
数据结构实验之二叉树四:(先序中序)还原二叉树 Time Limit: 1000 ms Memory Limit: 65536 KiB Problem Description 给定一棵二叉树的先序遍历 ...
随机推荐
- Linux系统高树攀登之路
Linux系统高树攀登之路 Linux作为一种操作系统已经发展了这么长的时间,已然有了很多的“粉丝”,其中不乏有“通天之力”的Linux大牛,也有能在Linux世界里“快乐畅游”的强者,同时也有想要攀 ...
- vue 数据绑定实现的核心 Object.defineProperty()
vue深入响应式原理 现在是时候深入一下了!Vue 最独特的特性之一,是其非侵入性的响应式系统.数据模型仅仅是普通的 JavaScript 对象.而当你修改它们时,视图会进行更新.这使得状态管理非常简 ...
- ORACLE SPA
注:转自http://blog.csdn.net/wish503/article/details/52066944 ------------------------------------------ ...
- php 依赖注入的实现
当A类需要依赖于B类,也就是说需要在A类中实例化B类的对象来使用时候,如果B类中的功能发生改变,也会导致A类中使用B类的地方也要跟着修改,导致A类与B类高耦合.这个时候解决方式是,A类应该去依赖B类的 ...
- 【angularjs】使用angular搭建项目,实现隔行换色
描叙:使用ng-class实现每隔3行换色 代码: <!DOCTYPE html> <html ng-app="myApp"> <head> & ...
- Linux内存管理之mmap详解
转发之:http://blog.chinaunix.net/uid-26669729-id-3077015.html Linux内存管理之mmap详解 一. mmap系统调用 1. mmap系统调用 ...
- 关于 js tofixed()保留小数位数问题
保留位数必须是数字 const num = parseFloat ('123456.33').tofixed(2); !!!! 注意 现在的的 num 是 字符串类型, 如果给它加数字的话,就会报错 ...
- C#总结(五)调用C++动态库(类型对照)
函数调用导致堆栈不对称.原因可能是托管的 PInvoke 签名与非托管的目标签名不匹配. 在dllimport中加入CallingConvention参数就行了, [DllImport(PCAP_DL ...
- Ionic1 环境破坏后程序重新恢复过程
ionic platform remove android ionic platform add android cordova plugin add cordova-plugin-network-i ...
- Java Arrays工具类的使用
Arrays 类 java.util.Arrays类能方便地操作数组,它提供的所有方法都是静态的.具有以下功能: 给数组赋值:通过fill方法. 对数组排序:通过sort方法,按升序. 比较数组:通过 ...