Python Data Visualization Cookbook 2.9.2
import numpy as np
import matplotlib.pyplot as plt def is_outlier(points, threshold=3.5):
if len(points.shape) == 1:
points = points[:, None] # Find the median number of points
median = np.median(points, axis=0) diff = np.sum((points - median)**2, axis=-1)
diff = np.sqrt(diff)
MAD = np.median(diff) MZS = 0.6745 * diff / MAD return MZS > threshold # Create 100 random numbers
x = np.random.random(100) # The number of the histogram buckets
buckets = 50 # Add in a few outliers
x = np.r_[x, -49, 95, 100, -100] # The function 'is_outlier()' return a array of boolean
# If True, get the element; else pass the element
# For example:
# x = [1,2,3,4]
# y = x[array([False,True,True,False])]
# y is [2,3]
filtered = x[~is_outlier(x)] # Create a new figure
plt.figure() # Define the width of the figure
plt.subplot(211)
# Drawing histogram
# histogram(arr,bins,normed,facecolor,edgecolor,alpha,histtype)
plt.hist(x, buckets)
plt.xlabel('Raw') plt.subplot(212)
plt.hist(filtered, buckets)
plt.xlabel('Cleaned') # Show the figure
plt.show()
Python Data Visualization Cookbook 2.9.2的更多相关文章
- Python Data Visualization Cookbook 2.2.2
import csv filename = 'ch02-data.csv' data = [] try: with open(filename) as f://用with语句将数据文件绑定到对象f r ...
- [Machine Learning with Python] Data Visualization by Matplotlib Library
Before you can plot anything, you need to specify which backend Matplotlib should use. The simplest ...
- 7 Tools for Data Visualization in R, Python, and Julia
7 Tools for Data Visualization in R, Python, and Julia Last week, some examples of creating visualiz ...
- 学习笔记之Introduction to Data Visualization with Python | DataCamp
Introduction to Data Visualization with Python | DataCamp https://www.datacamp.com/courses/introduct ...
- Data Visualization – Banking Case Study Example (Part 1-6)
python信用评分卡(附代码,博主录制) https://study.163.com/course/introduction.htm?courseId=1005214003&utm_camp ...
- 学习笔记之Bokeh Data Visualization | DataCamp
Bokeh Data Visualization | DataCamp https://www.datacamp.com/courses/interactive-data-visualization- ...
- 学习笔记之Data Visualization
Data visualization - Wikipedia https://en.wikipedia.org/wiki/Data_visualization Data visualization o ...
- Data Visualization 课程 笔记1
对数据可视化比较有兴趣,因此最近在看coursera上伊利诺伊大学香槟分校的数据可视化课程,做了一些笔记. 1. 定义 Data visualization is a high bandwidth c ...
- DATA VISUALIZATION – PART 2
A Quick Overview of the ggplot2 Package in R While it will be important to focus on theory, I want t ...
随机推荐
- 使用TotoriseSVN的分支/标签功能
使用TotoriseSVN的分支/标签功能 http://blog.sina.com.cn/s/blog_5383588c0100o1oo.html 原来在新建一个项目文件夹后,再把Trunk.Bra ...
- vs中web配置可浏览json数据文件
在日常的前端开发中,我们会制作一些数据文件,常用的有后缀名为json的文件,但是vs在启动项目时,是不能浏览json文件的,常见的错误提示如下图所示 解决这个错误,只需要在web.config文件中配 ...
- Unicode(UTF&UCS)深度历险
Unicode(UTF&UCS)深度历险 计算机网络诞生后,大家慢慢地发现一个问题:一个字节放不下一个字符了!因为需要交流,本地化的文字需要能够被支持. 最初的字符集使用7bit来存储字符,因 ...
- VS2012的安装项目只能用InstallShield Limited Edition
[吐槽]VS2012的安装项目只能用InstallShield Limited Edition[附资源下载] 以前版本的Visual Stuido中安装项目都可以使用微软自家的Visual Stu ...
- C语言和C++篇
C语言和C++篇 基本上所有主流的编程语言都有String的标准库,因为字符串操作是我们每个程序员几乎每天都要遇到的.想想我们至今的代码,到底生成和使用了多少String!标题上所罗列的语言,可以看成 ...
- Python自动化测试 -ConfigParser模块读写配置文件
C#之所以容易让人感兴趣,是因为安装完Visual Studio, 就可以很简单的直接写程序了,不需要做如何配置. 对新手来说,这是非常好的“初体验”, 会激发初学者的自信和兴趣. 而有些语言的开发环 ...
- hdu 2828 Buy Tickets(线段树)
一道不算复杂的线段树,就是数据处理需要好好想一下. 将输入的所有数据从后往前输入,对于最后一个值,如果它想插入第i个位置,那么他就必须在前面留下i-1个位置.对于倒数第二个人,如果他想插入j位置,那么 ...
- UVa-Where's Waldorf?
题目地址:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...
- 行业介绍:车载DVD MID 导航用料一般包含国腾LVDS芯片GM8284C/GM8283
车载DVD MID 导航用料一般包含国腾LVDS芯片 GM8284C/GM8283/替代SN75LVDS83,THC63LVDM83C , 音频ES7144/CS4344, 龙讯MHL HDMI芯片 ...
- magnum devstack部署
magnum安装 安装条件: 至少要10G以上内存的机器.亲测使用6G的虚拟机,所有操作均有至少一秒延迟. 硬盘至少50G 良好的上网环境 操作步骤参见快速入门 以下是我操作的步骤记录 sudo mk ...