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 ...
随机推荐
- POJ 1002 UVA 755 487--3279 电话排序 简单但不容易的水题
题意:给你许多串字符串,从中提取电话号码,输出出现复数次的电话号码及次数. 以下是我艰难的AC历程:(这题估计是我刷的题目题解次数排前的了...) 题目不是很难理解,刚开始想到用map,但stl的ma ...
- 10.26最后的模拟DAY2 数字对[暴力]
数字对 [题目描述] 小H是个善于思考的学生,现在她又在思考一个有关序列的问题. 她的面前浮现出一个长度为n的序列{ai},她想找出一段区间[L, R](1 <= L <= R <= ...
- golang 之 bson 与 struct 转换
bson的介绍不说了golang下的解析包找到2个 一个是mongo的http://labix.org/gobson,另外一个比较小众https://github.com/sbunce/bson这里用 ...
- 文本框文字垂直居中 CSS
<html> <head> <style type="text/css"> #text { height:20px; vertical-alig ...
- 用来代替本机IP的万能IP:127.0.0.1
用来代替本机IP的通用IP:127.0.0.1
- C语言的一些常见细节
C语言的一些常见细节 对于C语言,不同的编译器采用了不同的实现,并且在不同平台上表现也不同.脱离具体环境探讨C的细节行为是没有意义的,以下是我所使用的环境,大部分内容都经过测试,且所有测试结果基于这个 ...
- Web Api初试
Web Api初试 前言 ASP.NET Web API 与之前的内建HTTP服务解决方案的不同之处在于,它一开始就是围绕HTTP协议及其消息语义构建起来的.与WCF REST或ASP.NET AJA ...
- Android Chronometer控件使用,计时器
Android Chronometer实现了一个简单的计时器,继承自TextView,因此可以使用TextView的text控制属性来控制时间显示的颜色.字体大小等:可以定义时间显示格式,默认“MM: ...
- bat编程基本知识
1 声明变量 ::注意=前后不要留空格.随便说一下,在bat中,连续两个冒号表示注释 set var1=test 如果要引用这个变量的话,可以这样写:%var1% 2 echo off/on echo ...
- Arduino 各种模块篇 光敏感应模块 light sensor
It looks like this one: This one isn't a digital light sensor, so it's very simple. http://www.seeed ...