pandas 绘图 机器学习看特征相关性
pandas 绘图
import numpy as np
import tflearn
from tflearn.layers.core import dropout
from tflearn.layers.normalization import batch_normalization
from tflearn.data_utils import to_categorical
from sklearn.model_selection import train_test_split
import sys
import pandas as pd
from pandas import Series,DataFrame
import matplotlib.pyplot as plt data_train = pd.read_csv("feature_with_dnn_todo2.dat")
data_train.info()
import matplotlib.pyplot as plt
print(data_train.columns) for col in data_train.columns[1:]:
fig = plt.figure()
fig.set(alpha=0.2)
plt.figure()
data_train[data_train.label == 0.0][col].plot()
data_train[data_train.label == 1.0][col].plot()
data_train[data_train.label == 2.0][col].plot()
data_train[data_train.label == 3.0][col].plot()
plt.xlabel(u"sample data id")
plt.ylabel(col)
plt.title(col)
plt.legend((u'white', u'cdn',u'tunnel', u"msad"),loc='best')
plt.show()
结果:
Index(['label', 'flow_cnt', 'len(srcip_arr)', 'len(dstip_arr)',
'subdomain_num', 'uniq_subdomain_ratio',
'np.average(dns_request_len_arr)', 'np.average(dns_reply_len_arr)',
'np.average(subdomain_tag_num_arr)', 'np.average(subdomain_len_arr)',
'np.average(subdomain_weird_len_arr)',
'np.average(subdomain_entropy_arr)', 'A_rr_type_ratio',
'incommon_rr_type_rato', 'valid_ipv4_ratio', 'uniq_valid_ipv4_ratio',
'request_reply_ratio', 'np.max(dns_request_len_arr)',
'np.max(dns_reply_len_arr)', 'np.max(subdomain_tag_num_arr)',
'np.max(subdomain_len_arr)', 'np.max(subdomain_weird_len_arr)',
'np.max(subdomain_entropy_arr)', 'avg_distance', 'std_distance'],
dtype='object')

。。。。
输入数据样例:
label,flow_cnt,len(srcip_arr),len(dstip_arr),subdomain_num,uniq_subdomain_ratio,np.average(dns_request_len_arr),np.average(dns_reply_len_arr),np.average(subdomain_tag_num_arr),np.average(subdomain_len_arr),np.average(subdomain_weird_len_arr),np.average(subdomain_entropy_arr),A_rr_type_ratio,incommon_rr_type_rato,valid_ipv4_ratio,uniq_valid_ipv4_ratio,request_reply_ratio,np.max(dns_request_len_arr),np.max(dns_reply_len_arr),np.max(subdomain_tag_num_arr),np.max(subdomain_len_arr),np.max(subdomain_weird_len_arr),np.max(subdomain_entropy_arr),avg_distance,std_distance
0.0,1.0,1.0,1.0,1.0,1.0,35.0,148.0,1.0,3.0,0.0,0.0,1.0,0.0,1.0,1.0,0.142857142857,35.0,148.0,1.0,3.0,0.0,-0.0,0,0
0.0,10.0,1.0,3.0,6.0,0.6,42.7,143.5,1.83333333333,8.5,0.0,2.75986309274,0.6,0.0,0.2,0.2,0.0117096018735,44.0,287.0,2.0,10.0,0.0,2.94770277922,2.2,1.46969384567
0.0,100.0,1.0,2.0,50.0,0.5,49.63,62.96,1.0,7.7,0.0,2.41418035734,0.51,0.0,0.26,0.01,0.00100745516825,56.0,134.0,1.0,14.0,0.0,3.27761343682,7.14285714286,2.65729646253
0.0,100.0,1.0,3.0,17.0,0.17,46.11,70.53,1.0,4.47058823529,0.0,1.29411764706,0.4,0.0,0.13,0.05,0.00108436347864,54.0,631.0,1.0,12.0,0.0,3.0,5.1875,1.84454432042
0.0,100.0,1.0,4.0,50.0,0.5,45.8,59.59,1.0,5.8,0.0,2.06068705052,0.5,0.0,0.22,0.01,0.00109170305677,46.0,126.0,1.0,6.0,0.0,2.58496250072,4.14285714286,0.925820099773
0.0,100.0,11.0,7.0,26.0,0.26,42.64,58.51,1.0,4.80769230769,0.0,1.53846153846,0.84,0.0,0.7,0.25,0.00117260787992,47.0,201.0,1.0,5.0,0.0,2.0,1.28,0.825590697622
。。。
pandas 绘图 机器学习看特征相关性的更多相关文章
- pandas绘图总结
转自:http://blog.csdn.net/genome_denovo/article/details/78322628 pandas绘图总结 pandas中的绘图函数(更加详细的绘图资料可参考p ...
- 什么是机器学习的特征工程?【数据集特征抽取(字典,文本TF-Idf)、特征预处理(标准化,归一化)、特征降维(低方差,相关系数,PCA)】
2.特征工程 2.1 数据集 2.1.1 可用数据集 Kaggle网址:https://www.kaggle.com/datasets UCI数据集网址: http://archive.ics.uci ...
- matplotlib + pandas绘图
利用pandas处理日期数据,并根据日期绘制增长率曲线. 处理的json文本内容如下: # pd.json [{"name": "A", "date& ...
- 机器学习: 特征脸算法 EigenFaces
人脸识别是机器学习和机器视觉领域非常重要的一个研究方向,而特征脸算法是人脸识别里非常经典的一个算法,EigenFaces 是基于PCA (principal component analysis) 即 ...
- Python之Pandas绘图,设置显示中文问题
# -*- coding: utf-8 -*- # author:baoshan import pandas as pd import matplotlib.pyplot as plt plt.rcP ...
- [Python]-pandas模块-机器学习Python入门《Python机器学习手册》-03-数据整理
<Python机器学习手册--从数据预处理到深度学习> 这本书类似于工具书或者字典,对于python具体代码的调用和使用场景写的很清楚,感觉虽然是工具书,但是对照着做一遍应该可以对机器学习 ...
- [Python]-pandas模块-机器学习Python入门《Python机器学习手册》-02-加载数据:加载文件
<Python机器学习手册--从数据预处理到深度学习> 这本书类似于工具书或者字典,对于python具体代码的调用和使用场景写的很清楚,感觉虽然是工具书,但是对照着做一遍应该可以对机器学习 ...
- Python数据科学手册-机器学习之特征工程
特征工程常见示例: 分类数据.文本.图像. 还有提高模型复杂度的 衍生特征 和 处理 缺失数据的填充 方法.这个过程被叫做向量化.把任意格式的数据 转换成具有良好特性的向量形式. 分类特征 比如房屋数 ...
- pandas绘图
#encoding:utf8 import pandas as pd import numpy as np import matplotlib.pyplot as plt df = pd.DataFr ...
随机推荐
- Yii 2.0 query模式语法
项目使用Yii 2.0版本开发,个人一直喜好使用(new \yii\db\Query())模式操作数据,把增.删.查.改这4种情况的写法整理出来,方便查阅和记忆. 增加 - insert use Yi ...
- python爬取百度文库所有内容
转载自 GitHub 的 Jack-Cherish 大神 基本环境配置 版本:python3 系统:Windows 相关模块: import requests import re import jso ...
- 第二十节:Scrapy爬虫框架之使用Pipeline存储
在上两节当中,我们爬取了360图片,但是我们需要将图片下载下来,这将如何下载和存储呢? 下边叙述一下三种情况:1.将图片下载后存储到MongoDB数据库:2.将图片下载后存储在MySQL数据库:3.将 ...
- 杭电 2803 The MAX(sort)
Description Giving N integers, V1, V2,,,,Vn, you should find the biggest value of F. Input Each tes ...
- 【01】emmet系列之基础介绍
[01]emmet系列之基础介绍 [02]emmet系列之HTML语法 [03]emmet系列之CSS语法 [04]emmet系列之编辑器 [05]emmet系列之各种缩写 相关网址 官网:http: ...
- Leetcode 150.逆波兰表达式求值
逆波兰表达式求值 根据逆波兰表示法,求表达式的值. 有效的运算符包括 +, -, *, / .每个运算对象可以是整数,也可以是另一个逆波兰表达式. 说明: 整数除法只保留整数部分. 给定逆波兰表达式总 ...
- 《C语言程序设计(第四版)》阅读心得(一)
本篇开始写我个人觉得谭浩强老师的<C语言程序设计(第四版)>中之前没有认识到,或者忘了的知识.因为本科学过,所以有些简单的东西就没有放进来了,所以可能并不是太全面. 第一章程序设计与语言 ...
- Windows Server 2012 防火墙如何添加端口例外的方法(转)
Windows Server 2012 防火墙如何添加端口例外的方法 Windows Server 2012 防火墙如何添加端口例外的方法 在Windows Server 2012系统中,如果用户想在 ...
- Amoeba新版本MYSQL读写分离配置
标签:mysql 数据库 读写分离 休闲 amoeba 原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 .作者信息和本声明.否则将追究法律责任.http://skyson.blog.5 ...
- int *ptr=(int *)(&a+1)问题的探讨
从网络上看到这样一道有意思的题目,是关于数组与指针的问题,描述如下: main() { ]={,,,,}; ); printf(),*(ptr-)); } 输出为:2,5 请解释以上代码的输出结果. ...