Appscanner实验还原code1
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 ##########
########## TRAINTESTBOUNDARY = 0.75 #PICKLE_NAME = 'lg-new-new-65-withnoise-statistical.p'
PICKLE_NAME = 'trunc-dataset1-noisefree-statistical.p' print('Loading ' + PICKLE_NAME + '...')
flowlist = pickle.load(open(PICKLE_NAME, 'rb'),encoding='iso-8859-1')
print('Done...')
print('') print('Flows loaded: ' + str(len(flowlist))) p = []
r = []
f = []
a = [] for i in range(5):
########## PREPARE STUFF
examples = []
trainingexamples = []
testingexamples = [] #classifier = svm.SVC(gamma=0.001, C=100, probability=True)
classifier = ensemble.RandomForestClassifier() ########## GET FLOWS
for package, time, flow in flowlist:
examples.append((flow, package))
print('') ########## SHUFFLE DATA to ensure classes are "evenly" distributed
random.shuffle(examples) ########## TRAINING
trainingexamples = examples[:int(TRAINTESTBOUNDARY * len(examples))] 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
counter = 0
correct = 0 testingexamples = examples[int(TRAINTESTBOUNDARY * len(examples)):] X_test = []
y_test = []
y_pred = [] for flow, package in testingexamples:
X_test.append(flow)
y_test.append(package) ##### y_pred = classifier.predict(X_test)
print("########################")
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实验还原code1的更多相关文章
- Appscanner实验还原code3
# Author: Baozi #-*- codeing:utf-8 -*- import _pickle as pickle from sklearn import ensemble import ...
- Appscanner实验还原code2
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 给定一棵二叉树的先序遍历 ...
随机推荐
- 为什么swift是面向协议的编程--对面向对象机制的改进
主要目标是提供抽象能力和解决值类型的多态问题 Actually, Abrahams says, those are all attributes of types, and classes are j ...
- 最长回文(manacher模板)
#include<iostream> #include<algorithm> #include<cstring> #include<cstdio> us ...
- 【转】js中通过docment.cookie获取到的内容不完整! 在浏览器的application里的cookie里可以看到完整的cookie,个别字段无法通过document.cookie获取。 是否有其他办法可以获取到??
js中通过docment.cookie获取到的内容不完整!在浏览器的application里的cookie里可以看到完整的cookie,个别字段无法通过document.cookie获取.是否有其他办 ...
- 【vue】在移动端使用better-scroll 实现滚动效果
安装依赖:(c)npm install better-scroll --save 引入: import BScroll from 'better-scroll' 格式: var obj = new B ...
- 微信硬件平台(八) 3-0ESP8266向微信服务器请求设备绑定的用户
1调试助手 请求URL: https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=自己微信ID&a ...
- [ASP.NET]ScriptManager控件使用 转载
目录 概述 局部刷新 错误处理 类型系统扩展 注册定制脚本 注册 Web 服务 在客户端脚本中使用认证和个性化服务 ScriptManagerProxy 类 添加 ScriptManager 控件 客 ...
- Fastcgi工作原理
FastCGI是一个可伸缩的,高速地在HTTP server和动态脚本语言间的接口 FastCGI优点 这种方式可以让HTTP服务器专一的处理静态请求或者将动态脚本服务器返回给客户端,很大程度上提高了 ...
- bootstrapvalidator 用法
1.引入js.css 2.用法 API:http://bootstrapvalidator.votintsev.ru/api/ 参考博客:https://blog.csdn.net/u01393846 ...
- buildroot使用介绍
buildroot是Linux平台上一个构建嵌入式Linux系统的框架.整个Buildroot是由Makefile脚本和Kconfig配置文件构成的.你可以和编译Linux内核一样,通过buildro ...
- 任务调度工具Quartz入门笔记
一,导包 1)官网下载:http://www.quartz-scheduler.org/downloads/ 2)Maven <dependency> <groupId>org ...