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之定时任务crond
定时任务说明与分类 定时任务的应用场景举例 每天晚上 12点备份/etc/目录 tar 定时任务的三种分类 crond(crontab)定时任务软件(软件包cronie),用的最多的一种 atd,应用 ...
- centos下安装 glances 的问题
开始想安装htop 然后 yum installhtop 没有 yum searchhtop 也没有 然后上github 发现一个比htop还华丽的东西. Glances 大概这个样子的. 可以一览 ...
- 深入学习Redis:Redis内存模型
每天学习一点点 编程PDF电子书.视频教程免费下载:http://www.shitanlife.com/code 一.Redis内存统计 工欲善其事必先利其器,在说明Redis内存之前首先说明如何统计 ...
- len()方法
len() 方法返回对象(字符.列表.元组等)长度或项目个数 len()方法语法: len( 对象 )
- Python:Day16 闭包、装饰器
def outer(): x = 10 def inner(): #条件一.inner就是一个内部函数 print(x) #条件二.引用外部作用域的一个变量,因为x在函数外部的,所以是外部作用域的变量 ...
- gcc 找不到 boot python 链接库的问题: /usr/bin/ld: cannot find -lboost_python
问题: Ubuntu 14.04,gcc 4.8.4,以默认方式编译 boost 1.67 后,使用 Boost.Python 时,gcc 提示找不到 boost python 链接库. 方案: 查看 ...
- Python+自动化测试框架的设计编写
Python之一个简单的自动化测试框架:https://baijiahao.baidu.com/s?id=1578211870226409536&wfr=spider&for=pc h ...
- (admin.E108) The value of 'list_display[4]'报错解决方案
参考资料:虫师-<web接口开发与自动化测试:基于python语言> 日常学习Django框架中,创建了用户模型,但是页面功能验证时候,提示不能进行列表字段操作,debug好久,才找到问题 ...
- Spring Boot 之发送邮件
Spring Boot 之发送邮件 简介 API 配置 实战 引入依赖 配置邮件属性 Java 代码 完整示例 引申和引用 简介 Spring Boot 收发邮件最简便方式是通过 spring-boo ...
- Spring MVC 5 + Thymeleaf 基于Java配置和注解配置
Spring MVC 5 + Thymeleaf 注解配置 Spring的配置方式一般为两种:XML配置和注解配置 Spring从3.0开始以后,推荐使用注解配置,这两种配置的优缺点说的人很多,我就不 ...