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 ...
随机推荐
- 2013.2.A&&3.A
半期考之后,磨磨蹭蹭的刷了两套长乐的模拟题[=-=我现在实在是不敢恭维自己的刷题速度]感觉貌似很久没有来这里喂食了,就顺便yy下题解好了 2013.2.A: ice :BFS和spfa都可以,我打了个 ...
- [新概念英语II 笔记] Lesson 3: Please Send Me a Card
发现身边很多程序员都能看懂英文技术文章的60%-80%内容,但大家都有一个毛病,就是不会说,不会写作,在逛英文技术社区的时候,想发表点什么评论,总担心自己写的话有错误.究其原因, 我觉得主要原因是因为 ...
- 无穷字符串问题--CSDN上的面试题(原创)
网上看到一道奇怪的题,分享一下:http://hero.csdn.net/Question/Details?ID=307&ExamID=302 发布公司:CSDN 有 效 期:2014-02- ...
- 用Winrar批量解压缩有密码文件方法,只需输入一次密码
老王上传的文件多是RAR压缩格式的, 每个系列下载完,都20多集,解压缩的时候要一个一个的输入密码,太浪费时间. 1) 把下载的需要解压缩的文件统一放到一个文件夹下. 2) 启动winrar程序 (从 ...
- - 高级篇:二,IL设置静态属性,字段和类型转换
- 高级篇:二,IL设置静态属性,字段和类型转换 静态属性赋值 先来看 Reflector反射出的IL源码(感谢Moen的提示),这次用 Release模式编译,去掉那些无用的辅助指令 public ...
- make deb for debian/ubuntu, package software for debian/ubuntu
here you may find useful information: =====================X8---------------------------------8X==== ...
- All about Performing User-Managed Database Recovery
Automatic Recovery with SET AUTORECOVERY ======================================== Issuing SET AUTORE ...
- C/C++ 内存对齐
一.什么是对齐,以及为什么要对齐: 1. 现代计算机中内存空间都是按照byte划分的,从理论上讲似乎对任何类型的变量的访问可以从任何地址开始,但实际情况是在访问特定变量的时候经常在特定的内存地址访问, ...
- Java基础知识拾遗(一)
Java Threads 1. 创建线程的三种方法? 继承Thread类: 实现Runnable接口: 使用Executor框架创建一个线程池. 每个线程都有优先级(Thread.MAX_PRIORI ...
- php 写商城网站的总结吧
---恢复内容开始--- 在兄弟连培训,这半个月在做一期项目,期间学到了很多东西,可是还有好多没有学会灵活运用.今天在登录界面加入验证码的时候,form提交不过去input里面的验证码,session ...