matplotlib

Python boxplots having different whisker lengths

淺唱寂寞╮ 提交于 2021-01-25 17:01:55
问题 I was using the DataFrame.boxplot() function in Pandas, which I believe calls the matplotlib.pyplot.boxplot() . The documentation says that the default whisker length of these boxplots should be 1.5IQR, but I don't understand why the upper/lower whiskers of the same box are of different lengths in the plot. (I have not done any specific configurations) Sorry I wanted to post the image but I do not have enough reputation, so I put it on a free image hosting site instead, link: http://postimg

Python boxplots having different whisker lengths

北城余情 提交于 2021-01-25 17:01:05
问题 I was using the DataFrame.boxplot() function in Pandas, which I believe calls the matplotlib.pyplot.boxplot() . The documentation says that the default whisker length of these boxplots should be 1.5IQR, but I don't understand why the upper/lower whiskers of the same box are of different lengths in the plot. (I have not done any specific configurations) Sorry I wanted to post the image but I do not have enough reputation, so I put it on a free image hosting site instead, link: http://postimg

吴恩达深度学习学习笔记——C1W2——神经网络基础——作业2——用神经网络的思路实现Logistic回归

谁说胖子不能爱 提交于 2021-01-24 14:30:06
可以明确的说,如果不自己一步步调试作业代码,很难看懂作业内容。 这里主要梳理一下作业的主要内容和思路,完整作业文件可参考: http://localhost:8888/tree/Andrew-Ng-Deep-Learning-notes/assignments/C1W2 作业完整截图,参考本文结尾:作业完整截图。 作业指导及目标 Logistic Regression with a Neural Network mindset(用神经网络的思路实现Logistic回归) Welcome to your first (required) programming assignment! You will build a logistic regression classifier to recognize cats. This assignment will step you through how to do this with a Neural Network mindset, and so will also hone your intuitions about deep learning. Instructions: Do not use loops (for/while) in your code, unless the instructions explicitly ask

K-均值聚类算法

二次信任 提交于 2021-01-24 14:17:32
聚类是一种无监督的学习,它将相似的对象归到同一个簇中。 K-均值算法将数据点归为K个簇,每个簇的质心采用簇中所含数据点的均值构成。 K-均值算法 的工作流程:首先随机确定K个初始点为质心,然后将数据集中的每个点非配到一个簇中,分配原则是分给距离最近的质心所在的簇。然后每个簇的质心更新为该簇所有数据点的平均值。 伪代码: 随机创建K个质心: 当任意一个点的簇分配结果发生改变时: 对数据集中的每个数据点: 对每个质心: 计算质心到数据点的距离 将数据点分配给距离最近的质心所在簇 对每一个簇,计算簇中所有数据点的均值作为质心(更新质心) K-均值聚类支持函数:加载文件、欧式距离计算、随机初始化质心 from numpy import * def loadDataSet(filename): dataSet=[] f=open(filename) for line in f.readlines(): curLine=line.strip().split('\t') floatLine=list(map(float,curLine)) dataSet.append(floatLine) return dataSet def distEclud(vecA,vecB): return sqrt(sum(power(vecA-vecB,2))) def randCent(dataSet,k): n

用Matplotlib轻松复刻分析图,看看哪个城市买房最自由

旧城冷巷雨未停 提交于 2021-01-24 13:59:13
作者 | 费弗里 来源 | Python大数据分析 简介 前不久「贝壳研究院」基于其丰富的房地产相关数据资源,发布了「2020 新一线城市居住报告」: 图1 而在这个报告中有几张数据可视化作品还是比较可圈可点的,作为(在模仿中精进数据可视化)系列文章的开篇之作,我将基于我观察原始数据可视化作品进而构思出的方式,以纯Python的方式模仿复刻图2所示作品: 图2 复刻过程 2.1 观察原作品 其实原作品咋一看上去有点复杂,但经过观察,将原始图片主要元素拆分成几个部分来构思复现方式,还是不算复杂的,我总结为以下几部分: 「1 坐标系部分」 稍微懂点数据可视化的人应该都可以看出原作品的坐标不是常规的笛卡尔坐标系,而是极坐标系,这里复现原作品极坐标系的难点在于,其并不是完整的极坐标系,即左边略小于半圆的区域是隐藏了参考线的。 因此与其在matplotlib中极坐标系的基础上想方法隐藏部分参考线,不如逆向思维,从构造参考线的角度出发,自己组织构造参考线,会更加的自由和灵活。 「2 颜色填充」 这里的「颜色填充」指的是以居住自由指数折线为中线,在购房自由指数折线与租房自由指数折线之间的颜色填充区域,但困难的是这里当购房自由指数高于租房自由指数时对应的颜色为浅蓝绿色,而反过来则变为灰色,与购房自由指数、租房自由指数的颜色相呼应。 图3 2.2 开始动手! 综合考虑前面这些难点

日本「AI 鱼脸识别」项目,每分钟识别 100 条

放肆的年华 提交于 2021-01-24 13:58:03
来源 | HyperAI超神经 头图 | 视觉中国 近日,日本的一个 AI 分拣鱼类项目进入实验阶段。这将有望改善日本渔业劳动力老龄化及短缺的社会现状。 日本作为岛国,其独特的地理位置,让国民自古以来就跟鱼结下了不解之缘,甚至形成了其独特的「鱼文化」。因此,日本无论是在养鱼、捕鱼还是吃鱼方面,都堪称国际代表。 但是近年来,日本渔业却面临劳动力老龄化与短缺的压力,为此,相关部门正在推动渔业的自动化作业,以及时弥补人力空缺。 AI 看图识鱼,每分钟分装 100 条 餐桌上每一道鲜美的海鱼背后,都离不开渔民的辛苦工作。每一次的出海,渔民们不仅负责将海鲜打捞上船,为了保证渔获的新鲜,他们还要在最短的时间里将其分拣、冲洗、冷藏。 时间的紧迫,往往让他们顾不得天气状况,于是顶着烈日或冒雨作业都是家常便饭。 打渔这份艰辛的工作,越来越难以吸引年轻人。人口老龄化、劳动力短缺,成为制约日本渔业发展的一大因素。 近日,日本青森县八户市则开启了一项前所未有的实验——使用配备有 AI 系统与摄像头的设备,代替渔民,对捕捞上来的活鱼进行自动分类。 在短短 35 分钟的时间里,这台设备就分拣了约 1 吨的鲑鱼、鳕鱼、青花鱼和鲱鱼。 这一项目从 2018 年就已启动,日本农业、林业和渔业部出资 1.3 亿日元(约合人民币 812.7 万元),共同委托青森县产业技术中心食品研究所

How to plot 3d gaussian distribution with matplotlib?

*爱你&永不变心* 提交于 2021-01-24 13:54:59
问题 I have obtained the means and sigmas of 3d Gaussian distribution, then I want to plot the 3d distribution with python code, and obtain the distribution figure. 回答1: This is based on documentation of mpl_toolkits and an answer on SO based on scipy multinormal pdf: import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D import numpy as np from scipy.stats import multivariate_normal x, y = np.mgrid[-1.0:1.0:30j, -1.0:1.0:30j] # Need an (N, 2) array of (x, y) pairs. xy = np.column

How to plot 3d gaussian distribution with matplotlib?

|▌冷眼眸甩不掉的悲伤 提交于 2021-01-24 13:54:33
问题 I have obtained the means and sigmas of 3d Gaussian distribution, then I want to plot the 3d distribution with python code, and obtain the distribution figure. 回答1: This is based on documentation of mpl_toolkits and an answer on SO based on scipy multinormal pdf: import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D import numpy as np from scipy.stats import multivariate_normal x, y = np.mgrid[-1.0:1.0:30j, -1.0:1.0:30j] # Need an (N, 2) array of (x, y) pairs. xy = np.column

How to plot 3d gaussian distribution with matplotlib?

☆樱花仙子☆ 提交于 2021-01-24 13:54:23
问题 I have obtained the means and sigmas of 3d Gaussian distribution, then I want to plot the 3d distribution with python code, and obtain the distribution figure. 回答1: This is based on documentation of mpl_toolkits and an answer on SO based on scipy multinormal pdf: import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D import numpy as np from scipy.stats import multivariate_normal x, y = np.mgrid[-1.0:1.0:30j, -1.0:1.0:30j] # Need an (N, 2) array of (x, y) pairs. xy = np.column

How to plot 3d gaussian distribution with matplotlib?

时光毁灭记忆、已成空白 提交于 2021-01-24 13:54:07
问题 I have obtained the means and sigmas of 3d Gaussian distribution, then I want to plot the 3d distribution with python code, and obtain the distribution figure. 回答1: This is based on documentation of mpl_toolkits and an answer on SO based on scipy multinormal pdf: import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D import numpy as np from scipy.stats import multivariate_normal x, y = np.mgrid[-1.0:1.0:30j, -1.0:1.0:30j] # Need an (N, 2) array of (x, y) pairs. xy = np.column