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 给定一棵二叉树的先序遍历 ...
随机推荐
- 2.04-proxy-handler
import urllib.request def create_proxy_handler(): url = "https://blog.csdn.net/m0_37499059/arti ...
- jQuery 短信验证码倒计时
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- PHP 2 语句 数据类型 字符串函数 常量
在 PHP 中,有两种基本的输出方法:echo 和 print. 在本教程中,我们几乎在每个例子中都会用到 echo 和 print.因此,本节为您讲解更多关于这两条输出语句的知识. PHP echo ...
- Shell 文本处理三剑客之grep
grep ♦参数 -E,--extended-regexp 模式是扩展正则表达式 -i,--ignore-case 忽略大小写 -n,--line-number 打印行号 -v,--invert-ma ...
- scipy 安装错误及解决
pip 安装 scipy 时,因为是编译安装,所以如果缺少一些编译库,会报很多错误,以下总结可能缺失的安装包: sudo apt-get install gfortran sudo apt-get i ...
- 20175330 2018-2019-2 《Java程序设计》第八周学习总结
# **教材学习内容总结### 本周学习<Java程序设计>第十五章:*** 泛型: 泛型(Generics)的主要目的是可以建立具有类型安全的集合框架,如链表.散列映射等数据结构.泛型类 ...
- Android Wear创建一个通知
创建Android Wear的通知实际上和手机上创建没啥区别,主要是多了几个新类,只要用熟悉了一切都好办了.(如果只是测试通知,则直接运行wear app就能够看到效果) 创建一个简单的wear通知分 ...
- face recognition[variations of softmax][ArcFace]
本文来自<ArcFace: Additive Angular Margin Loss for Deep Face Recognition>,时间线为2018年1月.是洞见的作品,一作目前在 ...
- 【原创】一个线程oom,进程里其他线程还能运行吗?
引言 这题是一个网友@大脸猫爱吃鱼给我的提问,出自今年校招美团三面的一个真题.大致如下 一个进程有3个线程,如果一个线程抛出oom,其他两个线程还能运行么? 先说一下答案,答案是还能运行 不瞒大家说, ...
- Maven报错Archive for required library:某.jar' in project '项目名'
Maven报错Archive for required library:某.jar' in project '项目名'cannot be read or is not a valid ZIP file ...