Gartner力推的“百页机器学习书”,“舒服”搞定概念+代码(附下载)

栏目: 数据库 · 发布时间: 4年前

内容简介:作者:曹培信去年十二月,一本名为《TheHundred-Page Machine LearningBook》的机器学习教程迅速走火,它由Gartner公司机器学习团队负责人、人工智能博士AndriyBurkov撰写,这本书如标题所言,去除封面目录才128页,但是却包含了机器学习50多年以来有实用价值的各种材料。

Gartner力推的“百页机器学习书”,“舒服”搞定概念+代码(附下载)

大数据文摘出品

作者:曹培信

去年十二月,一本名为《TheHundred-Page Machine LearningBook》的机器学习教程迅速走火,它由Gartner公司机器学习团队负责人、人工智能博士AndriyBurkov撰写,这本书如标题所言,去除封面目录才128页,但是却包含了机器学习50多年以来有实用价值的各种材料。

作者介绍说:“机器学习的初学者将在本书中获得足够的细节,可以很‘舒服’地理解书的内容;有经验的实践者可以使用这本书作为进一步自我完善的指南。”

Gartner力推的“百页机器学习书”,“舒服”搞定概念+代码(附下载)

这本书讲了什么?

这本书一共分为两大部分,在介绍了机器学习的基本知识之后,本书首先用8章讲了SupervisedLearning(监督式学习),而后用3章介绍了UnsupervisedLearning(非监督式学习)和其他学习方式。

具体目录如下图所示:

Gartner力推的“百页机器学习书”,“舒服”搞定概念+代码(附下载)

示例代码已经开源

如今,这本书所有涉及到的项目代码都在GitHub上开源啦!

Gartner力推的“百页机器学习书”,“舒服”搞定概念+代码(附下载)

也就是说,大家可以一边看书学习,一边用开源的代码进行实验了。不得不说,这些代码对新手真的太友好了,内容特别详细。

比如多元高斯分布(GaussianMixture Model GMM)这个内容,作者在书的9.2.4进行了详细的讲解:

Gartner力推的“百页机器学习书”,“舒服”搞定概念+代码(附下载)

在GitHub上也有对应的详细代码:


 

importnumpy as np

importscipy as sp

importmatplotlib

importmatplotlib.pyplot as plt

importmath


fromsklearn.neighbors import KernelDensity


importscipy.integrate as integrate

fromsklearn.kernel_ridge import KernelRidge


matplotlib.rcParams['mathtext.fontset']= 'stix'

matplotlib.rcParams['font.family']= 'STIXGeneral'

matplotlib.rcParams.update({'font.size':18})


mu1,sigma1 = 3.0, 1.0

mu2,sigma2 = 8.0, 3.5


defsample_points():

s1= np.random.normal(mu1, math.sqrt(sigma1), 50)


s2= np.random.normal(mu2, math.sqrt(sigma2), 50)

return list(s1) + list(s2)


defcompute_bi(mu1local, sigma1local, mu2local, sigma2local, phi1local,phi2local):

bis= []

forxi in x:

bis.append((sp.stats.norm.pdf(xi, mu1local, math.sqrt(sigma1local)) *phi1local)/(sp.stats.norm.pdf(xi, mu1local, math.sqrt(sigma1local)) *phi1local + sp.stats.norm.pdf(xi, mu2local, math.sqrt(sigma2local)) *phi2local))

return bis

#generate points used to plot

x_plot= np.linspace(-2, 12, 100)

#generate points and keep a subset of them

x =sample_points()


colors= ['red', 'blue', 'orange', 'green']

lw = 2

mu1_estimate= 1.0

mu2_estimate= 2.0

sigma1_estimate= 1.0

sigma2_estimate= 2.0

phi1_estimate= 0.5

phi2_estimate= 0.5


count =0

whileTrue:

plt.figure(count)

axes = plt.gca()

axes.set_xlim([-2,12])

axes.set_ylim([0,0.8])

plt.xlabel("$x$")

plt.ylabel("pdf")

plt.scatter(x, [0.005] * len(x), color='navy', s=30, marker=2,label="training examples")

plt.plot(x_plot, [sp.stats.norm.pdf(xp, mu1_estimate,math.sqrt(sigma1_estimate)) for xp in x_plot], color=colors[1],linewidth=lw, label="$f(x_i \\mid \\mu_1 ,\\sigma_1^2)$")

plt.plot(x_plot, [sp.stats.norm.pdf(xp, mu2_estimate,math.sqrt(sigma2_estimate)) for xp in x_plot], color=colors[3],linewidth=lw, label="$f(x_i \\mid \\mu_2 ,\\sigma_2^2)$")

plt.plot(x_plot, [sp.stats.norm.pdf(xp, mu1, math.sqrt(sigma1)) forxp in x_plot], color=colors[0], label="true pdf")

plt.plot(x_plot, [sp.stats.norm.pdf(xp, mu2, math.sqrt(sigma2)) forxp in x_plot], color=colors[0])


plt.legend(loc='upper right')

plt.tight_layout()


fig1 = plt.gcf()

fig1.subplots_adjust(top = 0.98, bottom = 0.1, right = 0.98, left =0.08, hspace = 0, wspace = 0)

fig1.savefig('../../Illustrations/gaussian-mixture-model-' +str(count) + '.eps', format='eps', dpi=1000, bbox_inches = 'tight',pad_inches = 0)

fig1.savefig('../../Illustrations/gaussian-mixture-model-' +str(count) + '.pdf', format='pdf', dpi=1000, bbox_inches = 'tight',pad_inches = 0)

fig1.savefig('../../Illustrations/gaussian-mixture-model-' +str(count) + '.png', dpi=1000, bbox_inches = 'tight', pad_inches = 0)

#plt.show()

bis1 = compute_bi(mu1_estimate, sigma1_estimate, mu2_estimate,sigma2_estimate, phi1_estimate, phi2_estimate)

bis2 = compute_bi(mu2_estimate, sigma2_estimate, mu1_estimate,sigma1_estimate, phi2_estimate, phi1_estimate)

#print bis1[:5]

#print bis2[:5]

mu1_estimate = sum([bis1[i] * x[i] for i in range(len(x))]) /sum([bis1[i] for i in range(len(x))])

mu2_estimate = sum([bis2[i] * x[i] for i in range(len(x))]) /sum([bis2[i] for i in range(len(x))])


sigma1_estimate = sum([bis1[i] * (x[i] - mu1_estimate)**2 for i inrange(len(x))]) / sum([bis1[i] for i in range(len(x))])

sigma2_estimate = sum([bis2[i] * (x[i] - mu2_estimate)**2 for i inrange(len(x))]) / sum([bis2[i] for i in range(len(x))])

#print mu1_estimate, mu2_estimate

#print sigma1_estimate, sigma2_estimate

phi1_estimate = sum([bis1[i] for i in range(len(x))])/float(len(x))

phi2_estimate = 1.0 - phi1_estimate


print phi1_estimate


count += 1


plt.close(count)


ifcount > 50:

break

如何获得书和代码

书的链接:

http://themlbook.com/wiki/doku.php?id=start

代码链接:

https://github.com/aburkov/theMLbook

当然,文摘菌也帮大家下载并整理好了书和代码,后台回复 “100页” 就可以获得啦,赶紧开始学习起来吧!

实习/全职编辑记者招聘ing

加入我们,亲身体验一家专业科技媒体采写的每个细节,在最有前景的行业,和一群遍布全球最优秀的人一起成长。坐标北京·清华东门,在大数据文摘主页对话页回复 “招聘” 了解详情。简历请直接发送至zz@bigdatadigest.cn

Gartner力推的“百页机器学习书”,“舒服”搞定概念+代码(附下载)

点「在看」的人都变好看了哦


以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

爱上Arduino

爱上Arduino

Massimo Banzi / 于欣龙、郭浩赟 / 人民邮电出版社 / 2012-10 / 38.00元

《硬件开源电子设计平台:爱上Arduino(第2版)》全面透彻地介绍了arduino的相关内容,它会给你带来许多项目的点子,并帮助你顺利地实现从开始策划直到完成安装的全过程。由于《硬件开源电子设计平台:爱上Arduino(第2版)》是arduino项目合作创始人massimobanzi所著,其中一定融入了创始人对开源硬件的独到见解。《硬件开源电子设计平台:爱上Arduino(第2版)》内容完全考虑......一起来看看 《爱上Arduino》 这本书的介绍吧!

JSON 在线解析
JSON 在线解析

在线 JSON 格式化工具

RGB转16进制工具
RGB转16进制工具

RGB HEX 互转工具

MD5 加密
MD5 加密

MD5 加密工具