摘要: 用等高线图可视化一个三维函数,代码如下: import numpy as np from matplotlib import pyplot as plt plt.style.use('seaborn-white') %matplotlib inline def f(x, y): z = np.sin 阅读全文
posted @ 2020-01-08 21:52 赏尔 阅读(1042) 评论(0) 推荐(0) 编辑
摘要: matplotlib.pyplot contourf coutour([X, Y,] Z,[levels], **kwargs)contour和contourf都是画三维等高线图的,不同点在于contour() 是绘制轮廓线,contourf()会填充轮廓。除非另有说明,否则两个版本的函数是相同的。 阅读全文
posted @ 2020-01-07 21:51 赏尔 阅读(4800) 评论(0) 推荐(0) 编辑
摘要: matplotlib;pyplot.axhspan() 函数允许我们添加一个跨坐标轴的水平带(矩形) matplotlib;pyplot.axvspan() 函数允许我们添加一个跨坐标轴的垂直带(矩形) 注:axhspan() 函数必须用 ymin 和 ymax 两个参数指定宽度,axvspan() 阅读全文
posted @ 2020-01-06 22:48 赏尔 阅读(1953) 评论(0) 推荐(0) 编辑
摘要: 默认效果: import matplotlib.pyplot as plt %matplotlib inline x1, y1 = range(1,5), range(2, 6) x2, y2 = range(5, 9), range(3, 7) plt.figure(figsize=(8, 5)) 阅读全文
posted @ 2020-01-05 21:45 赏尔 阅读(847) 评论(0) 推荐(0) 编辑
摘要: 1、点的样式就是标记符号,总结如下: ‘.’:点(point marker) ‘,’:像素点(pixel marker) ‘o’:圆形(circle marker) ‘v’:朝下三角形(triangle_down marker) ‘^’:朝上三角形(triangle_up marker) ‘<‘:朝 阅读全文
posted @ 2020-01-04 21:43 赏尔 阅读(2364) 评论(0) 推荐(0) 编辑
摘要: 在西方国家罗马字母阵营中,字体分为两大种类:Sans Serif和Serif,打字机体虽然也属于Sans Serif,但由于是等宽字体,所以另外独立出Monospace这一种类,例如在Web中,表示代码时常常要使用等宽字体。 Serif的意思是,在字的笔划开始及结束的地方有额外的装饰,而且笔划的粗细 阅读全文
posted @ 2020-01-02 20:40 赏尔 阅读(1454) 评论(0) 推荐(0) 编辑
摘要: 1、pyecharts 的主题样式 thm = ''' | CHALK = 'chalk' #粉笔风 | | DARK = 'dark' #暗黑风 | | ESSOS = 'essos' #厄索斯大陆 | | INFOGRAPHIC = 'infographic' #信息图 | | LIGHT = 阅读全文
posted @ 2020-01-01 22:14 赏尔 阅读(2989) 评论(0) 推荐(1) 编辑
摘要: 大数据类 Hadoop Hive 北理工镜像站点 https://archive.apache.org/dist/hadoop/common/ https://archive.apache.org/dist/hive/ http://mirror.bit.edu.cn 阅读全文
posted @ 2019-12-31 00:10 赏尔 阅读(165) 评论(0) 推荐(0) 编辑
摘要: viso https://blog.csdn.net/huangxinfeng/article/details/81182802 Matplotlib 之坐标轴及刻度 https://blog.csdn.net/wuzlun/article/details/80053277 阅读全文
posted @ 2019-12-30 23:17 赏尔 阅读(67) 评论(0) 推荐(0) 编辑
摘要: 示例 代码 sessionInfo() # 查询版本及系统和库等信息 # 工作目录设置 getwd() path <- "E:/RSpace" setwd(path) rm(list=ls()) # 清空内存中的变量 # mtcars # 展示基础安装中的 mtcars 数据集 str(mtcars 阅读全文
posted @ 2019-12-24 13:30 赏尔 阅读(5558) 评论(0) 推荐(0) 编辑
摘要: 示例 sessionInfo() # 查询版本及系统和库等信息 # 工作目录设置 getwd() path <- "E:/RSpace" setwd(path) rm(list=ls()) # 清空内存中的变量 # state.x77 # 展示基础安装中的 women 数据集 str(state.x 阅读全文
posted @ 2019-12-24 13:28 赏尔 阅读(980) 评论(0) 推荐(0) 编辑
摘要: 说明: KMeans 聚类中的超参数是 K,需要我们指定。K 值一方面可以结合具体业务来确定,另一方面可以通过肘方法来估计。K 参数的最优解是以成本函数最小化为目标,成本函数为各个类畸变程度之和,每个类的畸变程度等于该类重心与其内部成员位置距离的平方和但是平均畸变程度会随着K的增大先减小后增大,所以 阅读全文
posted @ 2019-12-19 17:53 赏尔 阅读(7586) 评论(0) 推荐(0) 编辑
摘要: sklearn.datasets.make_blobs() 是用于创建多类单标签数据集的函数,它为每个类分配一个或多个正态分布的点集。 sklearn.datasets.make_blobs( n_samples=100, # 待生成的样本的总数 n_features=2, # 每个样本的特征数 c 阅读全文
posted @ 2019-12-19 16:23 赏尔 阅读(2690) 评论(0) 推荐(0) 编辑
摘要: 1、代码 import numpy as np import pandas as pd import matplotlib.pyplot as plt # 生成数据,创建 DataFrame np.random.seed(27) data = np.random.rand(7, 3) index = 阅读全文
posted @ 2019-12-15 22:37 赏尔 阅读(1590) 评论(0) 推荐(0) 编辑
摘要: 1、用 matplotlib.pyplot.style.avaliable 可查看 matplotlib 自带的美化样式如下: ['bmh', 'classic', 'dark_background', 'fast', 'fivethirtyeight', 'ggplot', 'grayscale' 阅读全文
posted @ 2019-12-15 21:27 赏尔 阅读(6942) 评论(0) 推荐(0) 编辑
摘要: 机器学习:波士顿房价数据集 波士顿房价数据集(Boston House Price Dataset)(下载地址:http://t.cn/RfHTAgY) 使用sklearn.datasets.load_boston即可加载相关数据。 from sklearn.datasets import load 阅读全文
posted @ 2019-12-15 15:16 赏尔 阅读(5420) 评论(0) 推荐(0) 编辑
摘要: 等比数列通项为:an = a1 * qn-1 基本语法: np.logspace( start, stop, num=50, endpoint=True, base=10.0, dtype=None, axis=0, ) 示例 1: 2n np.logspace(1, 10, 10, base=2) 阅读全文
posted @ 2019-12-15 13:59 赏尔 阅读(3205) 评论(0) 推荐(0) 编辑
摘要: 一、指定颜色的方法 1、使用名称或缩写 1.1 matplotlib 内建的默认颜色缩写如下: 'b':蓝色(blue) 'g':绿色(green) 'r':红色(red) 'c':青色(cyan) 'm':洋红(magenta) 'y':黄色(yellow) 'k':黑色(black) 'w':白 阅读全文
posted @ 2019-12-14 19:07 赏尔 阅读(10533) 评论(0) 推荐(1) 编辑
摘要: 1、选择 k # 选中上面的 cell j # 选中下面的 cell 2、多选、合并和拆分 Shift+上下键 # 按住Shift进行上下键操作可复选多个cell Shift-M # 合并所选cell或合并当前cell和下方的cell Ctrl + Shift + - # 从光标所在的位置拆分cel 阅读全文
posted @ 2019-12-08 18:25 赏尔 阅读(7227) 评论(0) 推荐(0) 编辑
摘要: 1)%pwd 于显示Jupyter当前的工作空间。 2)%hist 显示当前Jupyter中,所有运行过的历史代码。 3)%who 显示当前Jupyter环境中的所有变量或名称。 4)%reset 删除当前Jupyter环境中的所有变量或名称。 5)%time 计算当前代码行的运行时长。 6)%ti 阅读全文
posted @ 2019-12-08 18:24 赏尔 阅读(1946) 评论(0) 推荐(0) 编辑
摘要: 1、依次在 anaconda prompt 窗口中执行以下两句命令 pip install jupyter_contrib_nbextensions # 安装第三方包 jupyter contrib nbextension install --user --skip-running-check # 阅读全文
posted @ 2019-12-08 17:50 赏尔 阅读(2340) 评论(0) 推荐(0) 编辑
摘要: 不论是jupyter notebook 还是 jupyter lab 都可以添加多个 python 内核,并且随意切换。 1、切换到要添加的虚拟环境,确认是否安装 ipykernel python -m ipykernel --version 如果没有安装,则安装: python -m pip in 阅读全文
posted @ 2019-12-08 17:18 赏尔 阅读(8382) 评论(0) 推荐(0) 编辑
摘要: 通过命令行窗口或 Anaconda Prompt 窗口 1、安装 Jupyter 主题 pip install jupyterthemes 2、更新 Jupyter 主题 (可选) pip install --upgrade jupyterthemes 3、查看可用的 Jupyter 主题 jt - 阅读全文
posted @ 2019-12-08 16:42 赏尔 阅读(31138) 评论(1) 推荐(3) 编辑
摘要: 1、准备环境,探索数据 import numpy as np from keras.models import Sequential from keras.layers import Dense import matplotlib.pyplot as plt # 创建数据集 rng = np.ran 阅读全文
posted @ 2019-12-08 13:41 赏尔 阅读(1156) 评论(0) 推荐(0) 编辑
摘要: 说明:此操作是在 Anaconda Prompt 窗口完成的 CPU版 tensorflow 的安装。 1、用 conda 创建虚拟环境 tensorflow python=3.6 conda create -n tensorflow python=3.6 conda activate tensor 阅读全文
posted @ 2019-12-08 10:48 赏尔 阅读(5959) 评论(0) 推荐(0) 编辑
摘要: 版本说明 Python version: 3.6.6 |Anaconda, Inc.| (default, Jun 28 2018, 11:21:07) [MSC v.1900 32 bit (Intel)] NumPy version:1.17.4 pandas version:0.25.3 sc 阅读全文
posted @ 2019-12-05 13:51 赏尔 阅读(977) 评论(0) 推荐(0) 编辑
摘要: 说明:本机系统为 win10 64 位, base 是集成于 Anaconda3 的 64 位的python,以下是创建虚拟环境 py366-32,安装 3.6.6 版的 32 为python,把 3.6.6 版的 32 为 python 添加到 Jupyter notebook 内核中的过程 . 阅读全文
posted @ 2019-12-05 13:51 赏尔 阅读(5024) 评论(0) 推荐(1) 编辑
摘要: 1、python 中的 range() 函数生成整数序列,常用于 for 循环的迭代。 示例: 2、R 语言中的 range() 函数返回一个数值向量中的最小值和最大中,常用于求极差。 示例: 按语: R 语言中的 range 函数 python 中相当于 min(x), max(x) 阅读全文
posted @ 2019-12-04 13:13 赏尔 阅读(4038) 评论(0) 推荐(0) 编辑
摘要: 等差数列的通项公式:an = a0 + n*d. 数学上 n 是可以取遍整个整个正整数集的,在现实中,n 是有范围的。 1、R 语言用 seq() 函数产生等差数列: 2、python 中 range() 函数可以生成公差为正数的整数等差数列,numpy 中的 np.linspace() 函数和 n 阅读全文
posted @ 2019-12-04 13:13 赏尔 阅读(7382) 评论(0) 推荐(0) 编辑
摘要: 1、自变量的误差条 import numpy as np import matplotlib.pyplot as plt plt.rcParams['font.sans-serif'] = 'SimHei' # 使图形中的中文正常编码显示 plt.rcParams['axes.unicode_min 阅读全文
posted @ 2019-12-03 13:13 赏尔 阅读(4430) 评论(0) 推荐(0) 编辑
摘要: 1、模拟 27 次投掷硬币的伯努利试验 代码: from scipy import stats import numpy as np p = 0.5 # 生成冻结分布函数 bernoulliDist = stats.bernoulli(p) # 模拟 27 次伯努利实验 trails = berno 阅读全文
posted @ 2019-11-30 17:46 赏尔 阅读(2124) 评论(0) 推荐(0) 编辑
摘要: # 读取数数据, 查看数据结构 df_raw <- read.csv("sms_spam.csv", stringsAsFactors=F) str(df_raw) length(df_raw$type) # 将数据分为特征值矩阵 X 和 类标向量y 两部分,将 y 换为因子 X <- df_raw 阅读全文
posted @ 2019-11-26 18:34 赏尔 阅读(734) 评论(0) 推荐(0) 编辑
摘要: 在 skilearn 的手写数据集中,每个数据点都是 0 到 9 之间手写数字的一张 8*8 灰度图像。用 PCA 将其降维到二维,并可视化数据点,如下: 1、digits 数据演示: import matplotlib.pyplot as plt from sklearn.datasets imp 阅读全文
posted @ 2019-11-26 18:32 赏尔 阅读(1093) 评论(0) 推荐(0) 编辑
摘要: # 读取数数据, 查看数据结构 df_raw <- read.csv("sms_spam.csv", stringsAsFactors=F) str(df_raw) length(df_raw$type) # 将数据分为特征值矩阵 X 和 类标向量y 两部分,将 y 换为因子 X <- df_raw 阅读全文
posted @ 2019-11-25 23:42 赏尔 阅读(597) 评论(0) 推荐(0) 编辑
摘要: 代码: x <- seq(-2*pi, 2*pi, 0.2) z <- pi*(-2:2) labels <- paste(-2:2,"π", sep="") # 绘制正弦曲线 plot(x, sin(x), type="o", pch=4, col=2, ylim=c(-1.5, 1.5), xa 阅读全文
posted @ 2019-11-11 22:25 赏尔 阅读(1617) 评论(0) 推荐(0) 编辑
摘要: 1、代码 x <- seq(-pi/2, pi/2, length=50) x1 <- seq(-1, 1, length=50) opar <- par(no.readonly=T) par(fig=c(0, 0.5, 0, 1)) # 第一子图 # 绘制正弦曲线 plot(x, sin(x), 阅读全文
posted @ 2019-11-10 22:03 赏尔 阅读(608) 评论(0) 推荐(0) 编辑
摘要: 1、代码 x <- seq(-2*pi, 2*pi, 0.1) z <- pi*(-2:2) labels <- paste(-2:2,"π", sep="") # 绘制正弦曲线 plot(x, tan(x), type="o", pch=4, col=2, ylim=c(-1.5, 1.5), x 阅读全文
posted @ 2019-11-09 22:28 赏尔 阅读(381) 评论(0) 推荐(0) 编辑
摘要: 描述: do.call 根据名称或函数以及要传递给它的参数列表构造并执行函数调用。 语法: do.call(what, args, quote = FALSE, envir = parent.frame()) 参数: what 函数或命名要调用的函数的非空字符串。 args 函数调用的参数列表。 a 阅读全文
posted @ 2019-11-08 22:21 赏尔 阅读(1302) 评论(0) 推荐(0) 编辑
摘要: 1、nchar(x):返回字符串或者字符串向量x的长度。 > nchar("I love you!") [1] 11 > nchar(c("I", "love", "you", "!")) [1] 1 4 3 1 2、grep(pattern,x):返回 pattern 在字符串向量 x 中的位置。 阅读全文
posted @ 2019-11-07 22:50 赏尔 阅读(232) 评论(0) 推荐(0) 编辑
摘要: 1、排列 2 、 组合 还有可以从 misc 模块中调用 comb 3 阶乘 n! 注: Python 的标准库 math 里有阶乘函数 factorial() 4 双阶乘 n!! 5 类似阶乘的递推公式 n(n-k)(n-2k)···(n-mk)其中,n-mk >= 1 阅读全文
posted @ 2019-11-06 22:15 赏尔 阅读(740) 评论(0) 推荐(0) 编辑