作者 |
保罗·戴特尔 哈维·戴特尔 |
丛书名 |
华章程序员书库 |
出版社 |
机械工业出版社 |
ISBN |
9782104161359 |
简要 |
简介 |
内容简介书籍计算机书籍 ---------------------------8079862 - Python程序设计:人工智能案例实践--------------------------- 本书共16章。第1~10章介绍Python编程,涉及人工智能、基本描述统计、集中趋势和分散度量、模拟、静态和动态可视化、使用CSV文件、用于数据探索和数据整理的Pandas、时间序列和简单线性回归。第11~16章提供多种实践案例研究,涉及自然语言处理、Twitter数据挖掘、IBM Watson认知计算、包含分类和回归的有监督机器学习、聚类无监督机器学习、卷积神经网络深度学习、递归神经网络深度学习、包含Hadoop/Spark/NoSQL/物联网的大数据等。 ---------------------------8078742 - Python大学教程:面向计算机科学和数据科学(英文版)--------------------------- 本书提供了一种独特的方法来讲解Python编程入门,内容符合最新的ACM/IEEECS和相关的计算课程倡议,以及由美国国家科学基金会赞助的数据科学本科课程。内容涵盖了最新的主题和应用的覆盖面,模块化架构使教师能够方便地调整文本,适应课程需求。 |
目录 |
[套装书具体书目] 8078742 - Python大学教程:面向计算机科学和数据科学(英文版) - 9787111671503 - 机械工业出版社 - 定价 169 8079862 - Python程序设计:人工智能案例实践 - 9787111678458 - 机械工业出版社 - 定价 149 ---------------------------8079862 - Python程序设计:人工智能案例实践--------------------------- 审稿人评论 译者序 前言 作者简介 开始阅读本书之前 第一部分 Python基础知识快速入门 第1章 Python及大数据概述2 1.1 简介2 1.2 快速回顾面向对象技术的基础知识3 1.3 Python5 1.4 Python库7 1.4.1 Python标准库7 1.4.2 数据科学库8 1.5 试用IPython和Jupyter Notebook9 1.5.1 使用IPython交互模式作为计算器10 1.5.2 使用IPython 解释器执行Python程序11 1.5.3 在Jupyter Notebook中编写和执行代码12 1.6 云和物联网16 1.6.1 云16 1.6.2 物联网17 1.7 大数据有多大18 1.7.1 大数据分析22 1.7.2 数据科学和大数据正在带来改变:用例23 1.8 案例研究:大数据移动应用程序24 1.9 数据科学入门:人工智能——计算机科学与数据科学的交叉学科26 1.10 小结28 第2章 Python程序设计概述29 2.1 简介29 2.2 变量和赋值语句30 2.3 算术运算31 2.4 print函数、单引号和双引号34 2.5 三引号字符串36 2.6 从用户处获取输入37 2.7 决策:if语句和比较运算符39 2.8 对象和动态类型43 2.9 数据科学入门:基础的描述性统计44 2.10 小结46 第3章 控制语句48 3.1 简介48 3.2 控制语句概述49 3.3 if语句49 3.4 if...else和if...elif...else语句50 3.5 while语句53 3.6 for语句54 3.6.1 可迭代对象、列表和迭代器55 3.6.2 内置函数range55 3.7 增强赋值56 3.8 序列控制迭代和格式化字符串56 3.9 边界值控制的迭代57 3.10 内置函数range:深入讨论59 3.11 使用Decimal类型处理货币金额59 3.12 break和continue语句63 3.13 布尔运算符and、or和not63 3.14 数据科学入门:集中趋势度量—均值、中值和众数66 3.15 小结67 第4章 函数69 4.1 简介69 4.2 函数定义70 4.3 多参数函数72 4.4 随机数生成74 4.5 案例研究:一个运气游戏76 4.6 Python标准库79 4.7 math模块中的函数80 4.8 在IPython中使用制表符自动补全81 4.9 默认参数值82 4.10 关键字参数83 4.11 不定长参数列表83 4.12 方法:属于对象的函数84 4.13 作用域规则85 4.14 import:深入讨论87 4.15 向函数传递参数:深入讨论88 4.16 递归91 4.17 函数式编程93 4.18 数据科学入门:离中趋势度量95 4.19 小结96 第5章 序列:列表和元组97 5.1 简介97 5.2 列表98 5.3 元组102 5.4 序列解包104 5.5 序列切片106 5.6 使用del声明108 5.7 将列表传递给函数109 5.8 列表排序110 5.9 序列搜索111 5.10 列表的其他方法113 5.11 使用列表模拟堆栈115 5.12 列表推导式116 5.13 生成器表达式118 5.14 过滤、映射和归约118 5.15 其他的序列处理函数120 5.16 二维列表122 5.17 数据科学入门:模拟和静态可视化124 5.17.1 掷600、60,000、6,000,000次骰子的图例124 5.17.2 实现掷骰子中不同点数出现次数和百分比的可视化126 5.18 小结132 第二部分 Python数据结构、字符串和文件 第6章 字典和集合136 6.1 简介136 6.2 字典137 6.2.1 创建字典137 6.2.2 遍历字典138 6.2.3 基本的字典操作138 6.2.4 字典的keys和values方法140 6.2.5 字典的比较141 6.2.6 示例:学生成绩字典142 6.2.7 示例:单词计数143 6.2.8 字典的update方法144 6.2.9 字典推导式145 6.3 集合146 6.3.1 集合的比较147 6.3.2 集合的数学运算148 6.3.3 集合的可变运算符和方法150 6.3.4 集合推导式151 6.4 数据科学入门:动态可视化151 6.4.1 动态可视化的工作原理152 6.4.2 实现动态可视化154 6.5 小结156 第7章 使用NumPy进行面向数组的编程158 7.1 简介158 7.2 从现有数据创建数组159 7.3 数组属性160 7.4 用特定值填充数组162 7.5 从范围创建数组162 7.6 列表与数组的性能比较:引入%timeit164 7.7 数组运算符165 7.8 NumPy计算方法167 7.9 通用函数168 7.10 索引和切片170 7.11 视图:浅拷贝171 7.12 视图:深拷贝173 7.13 重塑和转置174 7.14 数据科学入门:pandas Series和DataFrame176 7.14.1 Series177 7.14.2 DataFrame181 7.15 小结188 第8章 字符串:深入讨论190 8.1 简介190 8.2 格式化字符串191 8.2.1 表示类型191 8.2.2 字段宽度和对齐方式193 8.2.3 数字格式化193 8.2.4 字符串的format方法194 8.3 拼接和重复字符串195 8.4 去除字符串中的空白字符196 8.5 字符大小写转换196 8.6 字符串的比较运算符197 8.7 查找子字符串197 8.8 替换子字符串199 8.9 字符串拆分和连接199 8.10 字符串测试方法201 8.11 原始字符串202 8.12 正则表达式介绍202 8.12.1 re模块与fullmatch函数203 8.12.2 替换子字符串和拆分字符串207 8.12.3 其他搜索功能、访问匹配207 8.13 数据科学入门:pandas、正则表达式和数据治理210 8.14 小结214 第9章 文件和异常215 9.1 简介215 9.2 文件216 9.3 文本文件处理217 9.3.1 向文本文件中写入数据:with语句的介绍217 9.3.2 从文本文件中读取数据218 9.4 更新文本文件220 9.5 使用JSON进行序列化221 9.6 关注安全:pickle序列化和反序列化224 9.7 关于文件的附加说明224 9.8 处理异常225 9.8.1 被零除和无效输入226 9.8.2 try语句226 9.8.3 在一条except子句中捕获多个异常229 9.8.4 一个函数或方法引发了什么异常229 9.8.5 try子句的语句序列中应该书写什么代码229 9.9 finally子句229 9.10 显式地引发一个异常231 9.11 (选学)堆栈展开和回溯232 9.12 数据科学入门:使用CSV文件234 9.12.1 Python标准库模块csv234 9.12.2 将CSV文件数据读入pandas DataFrame中236 9.12.3 读取泰坦尼克号灾难数据集237 9.12.4 用泰坦尼克号灾难数据集做简单的数据分析238 9.12.5 乘客年龄直方图239 9.13 小结240 第三部分 Python高级主题 第10章 面向对象编程242 10.1 简介242 10.2 自定义Account类244 10.2.1 试用Account类245 10.2.2 Account类的定义246 10.2.3 组合:对象引用作为类的成员248 10.3 属性访问控制248 10.4 用于数据访问的property249 10.4.1 试用Time类249 10.4.2 Time类的定义251 10.4.3 Time类定义的设计说明254 10.5 模拟“私有”属性255 10.6 案例研究:洗牌和分牌模拟257 10.6.1 试用Card类和DeckOfCards类257 10.6.2 Card类:引入类属性258 10.6.3 DeckOfCards类260 10.6.4 利用Matplotlib显示扑克牌图像262 10.7 继承:基类和子类265 10.8 构建继承层次结构:引入多态性267 10.8.1 基类CommissionEmployee267 10.8.2 子类SalariedCommission-Employee270 10.8.3 以多态方式处理Commission-Employee和SalariedComm-issionEmployee273 10.8.4 关于基于对象和面向对象编程的说明274 10.9 鸭子类型和多态性274 10.10 运算符重载276 10.10.1 试用Complex类277 10.10.2 Complex类的定义278 10.11 异常类层次结构和自定义异常279 10.12 具名元组280 10.13 Python 3.7的新数据类简介281 10.13.1 创建Card数据类282 10.13.2 使用Card数据类284 10.13.3 数据类相对于具名元组的优势286 10.13.4 数据类相对于传统类的优势286 10.14 使用文档字符串和doctest进行单元测试286 10.15 命名空间和作用域290 10.16 数据科学入门:时间序列和简单线性回归293 10.17 小结300 第四部分 人工智能、云和大数据案例研究 第11章 自然语言处理304 11.1 简介304 11.2 TextBlob305 11.2.1 创建一个TextBlob对象307 11.2.2 将文本标记为句子和单词307 11.2.3 词性标注308 11.2.4 提取名词短语309 11.2.5 使用TextBlob的默认情感分析器进行情感分析309 11.2.6 使用NaiveBayesAnalyzer进行情感分析310 11.2.7 语言检测与翻译311 11.2.8 变形:复数化和单数化312 11.2.9 拼写检查和拼写校正313 11.2.10 规范化:词干提取和词形还原314 11.2.11 词频314 11.2.12 从WordNet中获取单词定义、同义词和反义词315 11.2.13 删除停用词317 11.2.14 n元318 11.3 使用柱状图和词云可视化词频319 11.3.1 使用pandas可视化词频319 11.3.2 使用词云可视化词频321 11.4 使用Textatistic库进行可读性评估324 11.5 使用spaCy命名实体识别326 11.6 使用spaCy进行相似性检测327 11.7 其他NLP库和工具328 11.8 机器学习和深度学习自然语言应用328 11.9 自然语言数据集329 11.10 小结329 第12章 Twitter数据挖掘331 12.1 简介331 12.2 Twitter API概况333 12.3 创建一个Twitter账户334 12.4 获取Twitter凭据,创建应用程序334 12.5 什么是推文336 12.6 Tweepy339 12.7 通过Tweepy进行Twitter身份验证340 12.8 获取一个Twitter账户的相关信息341 12.9 Tweepy Cursor简介:获得一个账户的关注者和朋友343 12.9.1 确定一个账户的关注者343 12.9.2 确定一个账户的关注对象345 12.9.3 获取一个用户的最新推文345 12.10 搜索最新的推文346 12.11 热门话题发现:Twitter热门话题API348 12.11.1 有热门话题的地点348 12.11.2 获取热门话题列表349 12.11.3 根据热门话题创建词云351 12.12 推文分析前的清理或预处理352 12.13 Twitter流API353 12.13.1 创建StreamListener的子类353 12.13.2 启动流处理356 12.14 推文情感分析357 12.15 地理编码和映射361 12.15.1 获取和映射推文362 12.15.2 tweetutilities.py中的实用函数366 12.15.3 LocationListener类367 12.16 存储推文的方法368 12.17 Twitter和时间序列369 12.18 小结369 第13章 IBM Watson和认知计算370 13.1 简介370 13.2 IBM云账户和云控制台372 13.3 Watson服务372 13.4 额外的服务和工具375 13.5 Watson开发者云Python SDK377 13.6 案例研究:旅行者翻译伴侣APP377 13.6.1 准备工作378 13.6.2 运行APP379 13.6.3 SimpleLanguageTranslator.py脚本代码分析380 13.7 Watson资源390 13.8 小结391 第14章 机器学习:分类、回归和聚类392 14.1 简介392 14.1.1 scikit-learn393 14.1.2 机器学习的类别394 14.1.3 scikit-learn中内置的数据集396 14.1.4 典型的数据科学研究的步骤396 14.2 案例研究:用k近邻算法和Digits数据集进行分类(第1部分)397 14.2.1 k近邻算法398 14.2.2 加载数据集399 14.2.3 可视化数据402 14.2.4 拆分数据以进行训练和测试404 14.2.5 创建模型405 14.2.6 训练模型405 14.2.7 预测数字类别406 14.3 案例研究:利用k近邻算法和Digits数据集进行分类(第2部分)407 14.3.1 模型准确性指标407 14.3.2 k折交叉验证410 14.3.3 运行多个模型以找到最佳模型411 14.3.4 超参数调整413 14.4 案例研究:时间序列和简单线性回归413 14.5 案例研究:基于加利福尼亚房价数据集的多元线性回归418 14.5.1 加载数据集418 14.5.2 使用pandas探索数据420 14.5.3 可视化特征422 14.5.4 拆分数据以进行训练和测试426 14.5.5 训练模型426 14.5.6 测试模型427 14.5.7 可视化预测房价和期望房价427 14.5.8 回归模型指标428 14.5.9 选择最佳模型429 14.6 案例研究:无监督学习(第1部分)—降维430 14.7 案例研究:无监督学习(第2部分)—k均值聚类433 14.7.1 加载Iris数据集435 14.7.2 探索Iris数据集:使用pandas进行描述性统计436 14.7.3 使用Seaborn的pairplot可视化数据集438 14.7.4 使用KMeans估计器440 14.7.5 主成分分析降维442 14.7.6 选择最佳聚类估计器444 14.8 小结445 第15章 深度学习447 15.1 简介447 15.1.1 深度学习应用449 15.1.2 深度学习演示450 15.1.3 Keras资源450 15.2 Keras内置数据集450 15.3 自定义Anaconda环境451 15.4 神经网络452 15.5 张量454 15.6 用于视觉的卷积神经网络:使用MNIST数据集进行多分类455 15.6.1 加载MNIST数据集457 15.6.2 数据探索457 15.6.3 数据准备459 15.6.4 创建神经网络模型461 15.6.5 训练和评价模型468 15.6.6 保存和加载模型472 15.7 用TensorBoard可视化神经网络的训练过程473 15.8 ConvnetJS:基于浏览器的深度学习训练和可视化476 15.9 针对序列的递归神经网络:使用IMDb数据集进行情感分析477 15.9.1 加载IMDb影评数据集478 15.9.2 数据探索478 15.9.3 数据准备480 15.9.4 创建神经网络481 15.9.5 训练和评价模型483 15.10 调整深度学习模型484 15.11 在ImageNet上预训练的CNN模型485 15.12 小结486 第16章 大数据:Hadoop、Spark、NoSQL和IoT488 16.1 简介488 16.2 关系数据库和结构化查询语言492 16.2.1 books数据库493 16.2.2 SELECT查询497 16.2.3 WHERE子句497 16.2.4 ORDER BY子句498 16.2.5 从多个表中合并数据:INNER JOIN499 16.2.6 INSERT INTO语句500 16.2.7 UPDATE语句501 16.2.8 DELETE FROM语句502 16.3 NoSQL和NewSQL大数据数据库简述502 16.3.1 NoSQL键-值数据库503 16.3.2 NoSQL文档数据库503 16.3.3 NoSQL列式数据库504 16.3.4 NoSQL图数据库504 16.3.5 NewSQL数据库505 16.4 案例研究:MongoDB JSON文档数据库506 16.4.1 创建MongoDB Atlas集群506 16.4.2 将推文存入MongoDB中507 16.5 Hadoop515 16.5.1 概述516 16.5.2 通过MapReduce汇总Romeo-AndJuliet.txt中的单词长度518 16.5.3 在Microsoft Azure HDInsight中创建Apache Hadoop集群518 16.5.4 Hadoop流520 16.5.5 实现映射器520 16.5.6 实现归约器521 16.5.7 准备运行MapReduce示例522 16.5.8 运行MapReduce作业523 16.6 Spark525 16.6.1 概述525 16.6.2 Docker和Jupyter Docker堆栈526 16.6.3 使用Spark的单词计数529 16.6.4 Microsoft Azure上的Spark单词计数532 16.7 Spark流:使用pyspark-notebookDocker堆栈计算Twitter主题标签535 16.7.1 将推文流式传输到套接字535 16.7.2 总结推文主题标签,介绍Spark SQL538 16.8 物联网和仪表板543 16.8.1 发布和订阅545 16.8.2 使用Freeboard仪表板可视化PubNub示例实时流545 16.8.3 用Python模拟一个连接互联网的恒温器547 16.8.4 使用freeboard.io创建仪表板549 16.8.5 创建一个Python PubNub订阅服务器550 16.9 小结554 索引556 ---------------------------8078742 - Python大学教程:面向计算机科学和数据科学(英文版)--------------------------- 第1章 计算机和Python简介 1 1.1 引言 2 1.2 硬件和软件 3 1.2.1 摩尔定律 4 1.2.2 计算机组成 4 1.3 数据层级 6 1.4 机器语言、汇编语言和高级语言 9 1.5 对象技术简介 10 1.6 操作系统 13 1.7 Python简介 16 1.8 (语言)库 18 1.8.1 Python标准库 18 1.8.2 数据科学库 18 1.9 其他常见编程语言 20 1.10 试用:使用IPython和Jupyter Notebook 21 1.10.1 将IPython交互模型用作计算器 21 1.10.2 使用IPython解释器执行Python程序 23 1.10.3 在Jupyter Notebook中编写和执行代码 24 1.11 Internet和WWW 29 1.11.1 Internet:网际网 29 1.11.2 WWW:用户友善的Internet 30 1.11.3 计算和资源云 30 1.11.4 物联网 31 1.12 软件技术 32 1.13 大数据 33 1.13.1 大数据分析 38 1.13.2 数据科学和大数据案例研究 39 1.14 数据科学入门:大数据移动应用案例研究 40 第2章 Python程序设计简介 49 2.1 引言 50 2.2 变量和赋值语句 50 2.3 算术操作 52 2.4 print函数、单引号字符串和双引号字符串 56 2.5 三引号字符串 58 2.6 从用户处获得输入 59 2.7 判断:if语句与比较操作 61 2.8 对象和动态类型 66 2.9 数据科学入门:基本统计功能 68 2.10 小结 70 第3章 控制语句和程序设计 73 3.1 引言 74 3.2 算法 74 3.3 伪代码 75 3.4 控制语句 75 3.5 if语句 78 3.6 if...else和if...elif...else语句 80 3.7 while语句 85 3.8 for语句 86 3.8.1 迭代、列表和迭代器 88 3.8.2 内置range函数 88 3.9 增量赋值 89 3.10 程序设计:通过序列控制重复 90 3.10.1 需求声明 90 3.10.2 算法的伪代码形式 90 3.10.3 在Python中为算法编码 91 3.10.4 格式化字符串简介 92 3.11 程序设计:通过哨兵控制重复 93 3.12 程序设计:嵌套控制结构 97 3.13 内置函数range:进一步讨论 101 3.14 使用Decimal类型表达货币总量 102 3.15 break和continue语句 105 3.16 布尔操作and、or和not 106 3.17 数据科学入门:趋势的度量—均值、中值、众数 109 3.18 小结 111 第4章 函数 119 4.1 引言 120 4.2 函数的定义 120 4.3 多参数函数 123 4.4 随机数生成器 125 4.5 案例研究:机会游戏 128 4.6 Python标准库 131 4.7 math模块函数 132 4.8 使用IPython的tab补全功能 133 4.9 缺省形参值 135 4.10 关键字实参 136 4.11 任意实参表 136 4.12 方法:归属于对象的函数 138 4.13 作用域规则 138 4.14 import:进一步讨论 140 4.15 给函数传递实参:进一步讨论 142 4.16 函数调用栈 145 4.17 函数式程序设计 146 4.18 数据科学入门:数据分布的度量 148 4.19 小结 150 第5章 序列:列表和元组 155 5.1 引言 156 5.2 列表 156 5.3 元组 161 5.4 序列拆包 163 5.5 序列切片 166 5.6 del语句 169 5.7 给函数传递列表 171 5.8 排序列表 172 5.9 搜索序列 174 5.10 其他列表方法 176 5.11 用列表模拟栈 178 5.12 列表解析 179 5.13 生成器表达式 181 5.14 过滤器、映射和约简 182 5.15 其他序列处理函数 185 5.16 二维列表 187 5.17 数据科学入门:模拟和静态可视化 191 5.17.1 600、60000和6000000次掷骰子的图示 191 5.17.2 掷骰子实验的序列和百分比的可视化 193 5.18 小结 199 第6章 字典和集合 209 6.1 引言 210 6.2 字典 210 6.2.1 创建字典 210 6.2.2 在字典中遍历 212 6.2.3 基本的字典操作 212 6.2.4 字典方法keys和values 214 6.2.5 字典比较 216 6.2.6 案例研究:学生成绩字典 217 6.2.7 案例研究:词计数 218 6.2.8 字典方法update 220 6.2.9 字典解析 220 6.3 集合 221 6.3.1 集合比较 223 6.3.2 集合的数学操作 225 6.3.3 集合的可变操作和方法 226 6.3.4 集合解析 228 6.4 数据科学入门:动态可视化 228 6.4.1 了解动态可视化 228 6.4.2 实现动态可视化 231 6.5 小结 234 第7章 使用NumPy进行面向数组的编程 239 7.1 引言 240 7.2 从已有数据中创建数组 241 7.3 数组属性 242 7.4 用特定值填充数组 244 7.5 使用range创建数组 244 7.6 列表与数组的性能比较:%timeit简介 246 7.7 数组操作 248 7.8 NumPy计算方法 250 7.9 全局函数 252 7.10 索引和切片 254 7.11 视图:浅拷贝 256 7.12 深拷贝 258 7.13 转换和转置 259 7.14 数据科学入门:pandas Series和DataFrame 262 7.14.1 pandas series 262 7.14.2 DataFrame 267 7.15 小结 275 第8章 字符串:进一步讨论 283 8.1 引言 284 8.2 格式化字符串 285 8.2.1 类型声明 285 8.2.2 域宽和对齐 286 8.2.3 数值格式化 287 8.2.4 字符串format方法 288 8.3 字符串拼接和重复 289 8.4 字符串空白符剥离 290 8.5 改变字符的大小写 291 8.6 字符串比较操作 292 8.7 子串搜索 292 8.8 子串替换 294 8.9 字符串切分和合并 294 8.10 字符和字符测试方法 297 8.11 原生字符串 298 8.12 正则表达式简介 299 8.12.1 re模块和fullmatch函数 300 8.12.2 子串替换和串切分 303 8.12.3 其他搜索函数和匹配处理 304 8.13 数据科学入门:pandas、正则表达式和数据治理 307 8.14 小结 312 第9章 文件和异常 319 9.1 引言 320 9.2 文件 321 9.3 文本文件处理 321 9.3.1 写文本文件:with语句简介 322 9.3.2 读文本文件 323 9.4 更新文本文件 325 9.5 JSON序列化 327 9.6 安全问题:pickle序列化和反序列化 330 9.7 关于文件的其他说明 330 9.8 异常处理 331 9.8.1 除0异常和非法输入 332 9.8.2 try语句 332 9.8.3 在except从句中捕捉多重异常 335 9.8.4 函数或过程能够抛出什么异常 336 9.8.5 try套件应该封装什么代码 336 9.9 finally子句 336 9.10 显式引发异常 339 9.11 (可选)栈展开和回溯 339 9.12 数据科学入门:CSV文件的处理 342 9.12.1 Python标准库模块CSV 342 9.12.2 将CVS文件读入pandas DataFrame 344 9.12.3 读取Titanic Disaster数据库 346 9.12.4 对Titanic Disaster数据库进行简单的数据分析 347 9.12.5 乘客年龄直方图 348 9.13 小结 349 第10章 面向对象程序设计 355 10.1 引言 356 10.2 定制类Account 358 10.2.1 试用Account类 358 10.2.2 Account类的定义 360 10.2.3 组合:对象引用作为类的成员 361 10.3 属性的受控访问 363 10.4 数据访问的特性 364 10.4.1 试用Time类 364 10.4.2 Time类的定义 366 10.4.3 Time类定义的设计要领 370 10.5 私有属性模拟 371 10.6 案例研究:洗牌和切牌 373 10.6.1 试用Card和DeckofCards类 373 10.6.2 Card类属性简介 375 10.6.3 DeckofCards类 377 10.6.4 在Matplotlib中显示扑克图片 378 10.7 继承:基类和子类 382 10.8 构建继承层次和多态简介 384 10.8.1 基类Commission-Employee 384 10.8.2 子类SalariedCommission-Employee 387 10.8.3 CommissionEmployee和SalariedCommissionEmployee的多态处理 391 10.8.4 关于基于对象和面向对象程序设计的说明 391 10.9 鸭子类型和多态 392 10.10 操作符重载 393 10.10.1 试用Complex类 394 10.10.2 Complex类的定义 395 10.11 异常类层次和定制异常处理 397 10.12 有名元组 399 10.13 Python 3.7新数据类简介 400 10.13.1 创建Card数据类 401 10.13.2 使用Card数据类 403 10.13.3 数据类相较有名元组的优势 405 10.13.4 数据类相较传统类的优势 406 10.14 使用文档字符串和doctest进行单元测试 406 10.15 命名空间和作用域 411 10.16 数据科学入门:时间序列和简单线性回归 414 10.17 小结 423 第11章 计算机科学思维:递归、搜索、排序和大O表示法 431 11.1 引言 432 11.2 阶乘 433 11.3 阶乘的递归法 433 11.4 斐波那契数列的递归法 436 11.5 递归和循环 439 11.6 搜索和排序 440 11.7 线性搜索 440 11.8 算法效率:大O表示法 442 11.9 二叉搜索 444 11.9.1 二叉搜索的实现 445 11.9.2 二叉搜索的大O表示法 447 11.10 排序算法 448 11.11 选择排序 448 11.11.1 选择排序的实现 449 11.11.2 效用函数print_pass 450 11.11.3 选择排序的大O表示法 451 11.12 插入排序 451 11.12.1 插入排序的实现 452 11.12.2 插入排序的大O表示法 453 11.13 归并排序 454 11.13.1 归并排序的实现 454 11.13.2 归并排序的大O表示法 459 11.14 总结:本章算法的大O表示法 459 11.15 可视化算法 460 11.15.1 生成函数 462 11.15.2 实现选择排序算法的动画演示 463 11.16 小结 468 第12章 自然语言处理 477 12.1 引言 478 12.2 TextBlob 479 12.2.1 创建TextBlob 481 12.2.2 语料化:文本的断句和取词 482 12.2.3 言语分部标注 482 12.2.4 提取名词短语 483 12.2.5 使用TextBlob缺省情绪分析器进行文本情绪分析 484 12.2.6 使用NaiveBayesAnalyzer进行文本情绪分析 486 12.2.7 语言检测和翻译 487 12.2.8 屈折辨析:多元化和单一化 489 12.2.9 拼写检查和更正 489 12.2.10 规范化:词根和词性还原 490 12.2.11 词频 491 12.2.12 从WordNet中获取定义、同义词、反义词 492 12.2.13 停用词删除 494 12.2.14 n-gram模型 496 12.3 使用Bar Charts和Word Clouds进行词频可视化 497 12.3.1 使用Bar Charts进行词频可视化 497 12.3.2 使用Word Clouds进行词频可视化 500 12.4 使用Textatistic进行可读性评测 503 12.5 使用spaCy进行有名实体识别 505 12.6 使用spaCyn进行相似性评估 507 12.7 其他NLP工具和库 509 12.8 机器学习和深度学习的自然语言应用 509 12.9 自然语言数据集 510 12.10 小结 510 第13章 Twitter数据挖掘 515 13.1 引言 516 13.2 Twitter API概述 518 13.3 创建Twitter账户 519 13.4 获取Twitter证书—创建App 520 13.5 推文中有什么 521 13.6 Tweepy 525 13.7 使用Tweepy在Twitter中认证 525 13.8 从Twitter账户中获取信息 527 13.9 Tweepy Cursors简介:获取账户的关注者和好友 529 13.9.1 确定账户的关注者 529 13.9.2 确定账户关注了谁 532 13.9.3 获取用户当前的推文 532 13.10 搜索当前推文 534 13.11 趋势发现:Twitter趋势API 536 13.11.1 趋势主题位置获取 536 13.11.2 趋势主题列表获取 537 13.11.3 从趋势主题中创建词云 539 13.12 推文分析前的清理/预处理 541 13.13 Twitter流处理API 542 13.13.1 创建StreamListener的子类 543 13.13.2 流处理初始化 545 13.14 推文情感分析 547 13.15 地址匹配与映射 551 13.15.1 推文的获取和映射 552 13.15.2 twetutilities.py效用函数 556 13.15.3 LocationListener类 558 13.16 存储推文的方式 559 13.17 Twitter和时间序列 560 13.18 小结 560 第14章 IBM Watson和认知计算 565 14.1 引言:IBM Watson和认知计算 566 14.2 IBM云账户和云控制台 568 14.3 Watson服务 568 14.4 附加服务和工具 572 14.5 Watson开发者云Python SDK 573 14.6 案例研究:旅行者助手—翻译App 574 14.6.1 运行App前的准备工作 575 14.6.2 试用App 576 14.6.3 SimpleLanguageTranslator.py脚本走查 577 14.7 Watson资源 587 14.8 小结 589 第15章 机器学习:分类、回归和聚类 593 15.1 机器学习入门 594 15.1.1 Scikit-learn 595 15.1.2 机器学习的类别 596 15.1.3 Scikit-learn数据集 598 15.1.4 经典的数据科学研究步骤 599 15.2 案例研究:数字数据集上的k近邻分类法(第一部分) 599 15.2.1 k近邻算法 601 15.2.2 载入数据集 602 15.2.3 可视化数据 606 15.2.4 划分训练集和测试集 608 15.2.5 创立模型 609 15.2.6 训练模型 610 15.2.7 预测数字类别 610 15.3 案例研究:数字数据集上的k近邻分类法(第二部分) 612 15.3.1 模型的准确性度量 612 15.3.2 k折交叉验证 616 15.3.3 多模型寻优 617 15.3.4 超参调优 619 15.4 案例研究:时间序列和简单线性回归 620 15.5 案例研究:加州订房数据集上的多线性回归 625 15.5.1 载入数据集 626 15.5.2 用pandas观察数据集 628 15.5.3 特征的可视化 630 15.5.4 划分训练集和测试集 634 15.5.5 训练模型 634 15.5.6 测试模型 635 15.5.7 预期及预测价格的可视化 636 15.5.8 回归模型度量 637 15.5.9 最佳模型选择 638 15.6 案例研究:无监督机器学习—降维 639 15.7 案例研究:无监督机器学习—k均值聚类 642 15.7.1 载入Iris数据集 644 15.7.2 观察Iris数据集:使用pandas进行统计描述 646 15.7.3 使用Seaborn pairplot可视化数据集 647 15.7.4 使用评估器KMeans 650 15.7.5 使用主成分分析法进行降维 652 15.7.6 选择最佳聚类评估器 655 15.8 小结 656 第16章 深度学习 665 16.1 引言 666 16.1.1 深度学习应用 668 16.1.2 深度学习演示程序 669 16.1.3 Keras资源 669 16.2 Keras内置数据集 669 16.3 Anaconda定制化环境 670 16.4 神经网络 672 16.5 张量 674 16.6 视觉处理卷积神经网络和多分类器 676 16.6.1 载入MNIST数据集 677 16.6.2 数据探索 678 16.6.3 数据准备 680 16.6.4 构造神经网络 682 16.6.5 模型训练和评价 691 16.6.6 模型存储和载入 696 16.7 使用TensorBoard进行神经网络训练的可视化 697 16.8 ConvnetJS:基于浏览器的深度学习训练和可视化 700 16.9 序列处理中的循环神经网络和IMDb数据集的情感分析 701 16.9.1 载入IMDb电影评论数据集 702 16.9.2 数据探索 703 16.9.3 数据准备 705 16.9.4 构造神经网络 706 16.9.5 模型训练和评价 709 16.10 深度学习模型调参 710 16.11 ImageNet上的卷积网络模型预学习 711 16.12 强化学习 712 16.12.1 深度强化学习 713 16.12.2 OpenAI Gym 713 16.13 小结 714 第17章 大数据:Hadoop、Spark、NoSQL和IoT 723 17.1 引言 724 17.2 关系型数据库和结构化查询语言 728 17.2.1 books数据库 730 17.2.2 SELECT查询 734 17.2.3 WHERE子句 734 17.2.4 ORDER BY子句 736 17.2.5 INNER JOIN:从多个表中合并数据 737 17.2.6 INSERT INTO语句 738 17.2.7 UPDATE语句 739 17.2.8 DELETE FROM语句 739 17.3 NoSQL和NewSQL大数据数据库概述 741 17.3.1 NoSQL键值对数据库 741 17.3.2 NoSQL文档数据库 742 17.3.3 NoSQL列数据库 742 17.3.4 NoSQL图数据库 743 17.3.5 NewSQL数据库 743 17.4 案例研究:MongoDB JSON文档数据库 744 17.4.1 创建MongoDB Atlas簇 745 17.4.2 将推文注入MongoDB 746 17.5 Hadoop 755 17.5.1 Hadoop概述 755 17.5.2 使用MapReduce汇总Romeo and Juliet的词长度 758 17.5.3 在微软Azure HDInsight上创建Apache簇 758 17.5.4 Hadoop Streaming 760 17.5.5 Mapper的实现 760 17.5.6 Reducer的实现 761 17.5.7 准备运行MapReduce案例研究 762 17.5.8 运行MapReduce作业 763 17.6 Spark 766 17.6.1 Spark概述 766 17.6.2 Docker和Jupyter Docker栈 767 17.6.3 使用Spark进行词统计 770 17.6.4 在微软Azure上进行词统计 773 17.7 Spark Streaming:使用pyspark-notebook Docker栈进行Twitter哈希标注统计 777 17.7.1 将推文注入套接字 777 17.7.2 推文哈希标注累计和Spark SQL简介 780 17.8 物联网和仪表盘 786 17.8.1 发布和订阅 788 17.8.2 使用Freeboard仪表盘可视化PubNub实时采样流 788 17.8.3 使用Python模拟互联网恒温器 790 17.8.4 使用Freeboard.io创建仪表盘 792 17.8.5 创建Python PubNub订阅 794 17.9 小结 798 Contents 1Introduction to Computers and Python 1 1.1 Introduction 2 1.2 Hardware and Software 3 1.2.1 Moore’s Law 4 1.2.2 Computer Organization 4 1.3 Data Hierarchy 6 1.4 Machine Languages, Assembly Languages and High-Level Languages 9 1.5 Introduction to Object Technology 10 1.6 Operating Systems 13 1.7 Python 161.8It’s the Libraries! 18 1.8.1 Python Standard Library 18 1.8.2 Data-Science Libraries 18 1.9 Other Popular Programming Languages 20 1.10 Test-Drive: Using IPython and Jupyter Notebooks 21 1.10.1 Using IPython Interactive Mode as a Calculator 21 1.10.2 Executing a Python Program Using the IPython Interpreter 23 1.10.3 Writing and Executing Code in a Jupyter Notebook 24 1.11 Internet and World Wide Web 29 1.11.1 Internet: A Network of Networks 29 1.11.2 World Wide Web: Making the Internet User-Friendly 30 1.11.3 The Cloud 30 1.11.4 Internet of Things 31 1.12 Software Technologies 32 1.13 How Big Is Big Data 33 1.13.1 Big Data Analytics 38 1.13.2 Data Science and Big Data Are Making a Difference: Use Cases 39 1.14 Intro to Data Science: Case Study—A Big-Data Mobile Application 40 2Introduction to Python Programming 49 2.1 Introduction 50 2.2 Variables and Assignment Statements 50 2.3 Arithmetic 52 2.4 Function print and an Intro to Single- and Double-Quoted Strings 56 2.5Triple-Quoted Strings 58 2.6Getting Input from the User 59 2.7Decision Making: The if Statement and Comparison Operators 61 2.8Objects and Dynamic Typing 66 2.9Intro to Data Science: Basic Descriptive Statistics 68 2.10Wrap-Up 70 3Control Statements and Program Development 73 3.1Introduction 74 3.2Algorithms 74 3.3Pseudocode 75 3.4Control Statements 75 3.5if Statement 78 3.6if…else and if…elif…else Statements 80 3.7while Statement 85 3.8for Statement 86 3.8.1Iterables, Lists and Iterators 88 3.8.2Built-In range Function 88 3.9Augmented Assignments 89 3.10Program Development: Sequence-Controlled Repetition 90 3.10.1Requirements Statement 90 3.10.2Pseudocode for the Algorithm 90 3.10.3Coding the Algorithm in Python 91 3.10.4Introduction to Formatted Strings 92 3.11Program Development: Sentinel-Controlled Repetition 93 3.12Program Development: Nested Control Statements 97 3.13Built-In Function range: A Deeper Look 101 3.14Using Type Decimal for Monetary Amounts 102 3.15break and continue Statements 105 3.16Boolean Operators and, or and not 106 3.17Intro to Data Science: Measures of Central Tendency—Mean, Median and Mode109 3.18Wrap-Up 111 4Functions 119 4.1Introduction 120 4.2Defining Functions 120 4.3Functions with Multiple Parameters 123 4.4Random-Number Generation 125 4.5Case Study: A Game of Chance 128 4.6Python Standard Library 131 4.7math Module Functions 132 4.8Using IPython Tab Completion for Discovery 133 4.9Default Parameter Values 135 4.10Keyword Arguments 136 4.11Arbitrary Argument Lists 136 4.12Methods: Functions That Belong to Objects 138 4.13Scope Rules 138 4.14import: A Deeper Look 140 4.15Passing Arguments to Functions: A Deeper Look 142 4.16Function-Call Stack 145 4.17Functional-Style Programming 146 4.18Intro to Data Science: Measures of Dispersion 148 4.19Wrap-Up 150 5Sequences: Lists and Tuples 155 5.1Introduction 156 5.2Lists 156 5.3Tuples 161 5.4Unpacking Sequences 163 5.5Sequence Slicing 166 5.6del Statement 169 5.7Passing Lists to Functions 171 5.8Sorting Lists 172 5.9Searching Sequences 174 5.10Other List Methods 176 5.11Simulating Stacks with Lists 178 5.12List Comprehensions 179 5.13Generator Expressions 181 5.14Filter, Map and Reduce 182 5.15Other Sequence Processing Functions 185 5.16Two-Dimensional Lists 187 5.17Intro to Data Science: Simulation and Static Visualizations 191 5.17.1Sample Graphs for 600, 60,000 and 6,000,000 Die Rolls 191 5.17.2Visualizing Die-Roll Frequencies and Percentages 193 5.18Wrap-Up 199 6Dictionaries and Sets 209 6.1Introduction 210 6.2Dictionaries 210 6.2.1Creating a Dictionary 210 6.2.2Iterating through a Dictionary 212 6.2.3Basic Dictionary Operations 212 6.2.4Dictionary Methods keys and values 214 6.2.5Dictionary Comparisons 216 6.2.6Example: Dictionary of Student Grades 217 6.2.7Example: Word Counts 218 6.2.8Dictionary Method update 220 6.2.9Dictionary Comprehensions 220 6.3Sets 221 6.3.1Comparing Sets 223 6.3.2Mathematical Set Operations 225 6.3.3Mutable Set Operators and Methods 226 6.3.4Set Comprehensions 228 6.4Intro to Data Science: Dynamic Visualizations 228 6.4.1How Dynamic Visualization Works 228 6.4.2Implementing a Dynamic Visualization 231 6.5Wrap-Up 234 7Array-Oriented Programming with NumPy 239 7.1Introduction 240 7.2Creating arrays from Existing Data 241 7.3array Attributes 242 7.4Filling arrays with Specific Values 244 7.5Creating arrays from Ranges 244 7.6List vs. array Performance: Introducing %timeit 246 7.7array Operators 248 7.8NumPy Calculation Methods 250 7.9Universal Functions 252 7.10Indexing and Slicing 254 7.11Views: Shallow Copies 256 7.12Deep Copies 258 7.13Reshaping and Transposing 259 7.14Intro to Data Science: pandas Series and DataFrames 262 7.14.1pandas Series 262 7.14.2DataFrames 267 7.15Wrap-Up 275 8Strings: A Deeper Look 283 8.1Introduction 284 8.2Formatting Strings 285 8.2.1Presentation Types 285 8.2.2Field Widths and Alignment 286 8.2.3Numeric Formatting 287 8.2.4String’s format Method 288 8.3Concatenating and Repeating Strings 289 8.4Stripping Whitespace from Strings 290 8.5Changing Character Case 291 8.6Comparison Operators for Strings 292 8.7Searching for Substrings 292 8.8Replacing Substrings 294 8.9Splitting and Joining Strings 294 8.10Characters and Character-Testing Methods 297 8.11Raw Strings 298 8.12Introduction to Regular Expressions 299 8.12.1re Module and Function fullmatch 300 8.12.2Replacing Substrings and Splitting Strings 303 8.12.3Other Search Functions; Accessing Matches 304 8.13Intro to Data Science: Pandas, Regular Expressions and Data Munging 307 8.14Wrap-Up 312 9Files and Exceptions 319 9.1Introduction 320 9.2Files 321 9.3Text-File Processing 321 9.3.1Writing to a Text File: Introducing the with Statement 322 9.3.2Reading Data from a Text File 323 9.4Updating Text Files 325 9.5Serialization with JSON 327 9.6Focus on Security: pickle Serialization and Deserialization 330 9.7Additional Notes Regarding Files 330 9.8Handling Exceptions 331 9.8.1Division by Zero and Invalid Input 332 9.8.2try Statements 332 9.8.3Catching Multiple Exceptions in One except Clause 335 9.8.4What Exceptions Does a Function or Method Raise 336 9.8.5What Code Should Be Placed in a try Suite 336 9.9finally Clause 336 9.10Explicitly Raising an Exception 339 9.11(Optional) Stack Unwinding and Tracebacks 339 9.12Intro to Data Science: Working with CSV Files 342 9.12.1Python Standard Library Module csv 342 9.12.2Reading CSV Files into Pandas DataFrames 344 9.12.3Reading the Titanic Disaster Dataset 346 9.12.4Simple Data Analysis with the Titanic Disaster Dataset 347 9.12.5Passenger Age Histogram 348 9.13Wrap-Up 349 10Object-Oriented Programming 355 10.1Introduction 356 10.2Custom Class Account 358 10.2.1Test-Driving Class Account 358 10.2.2Account Class Definition 360 10.2.3Composition: Object References as Members of Classes 361 10.3Controlling Access to Attributes 363 10.4Properties for Data Access 364 10.4.1Test-Driving Class Time 364 10.4.2Class Time Definition 366 10.4.3Class Time Definition Design Notes 370 10.5Simulating “Private” Attributes 371 10.6Case Study: Card Shuffling and Dealing Simulation 373 10.6.1Test-Driving Classes Card and DeckOfCards 373 10.6.2Class Card—Introducing Class Attributes 375 10.6.3Class DeckOfCards 377 10.6.4Displaying Card Images with Matplotlib 378 10.7Inheritance: Base Classes and Subclasses 382 10.8Building an Inheritance Hierarchy; Introducing Polymorphism 384 10.8.1Base Class CommissionEmployee 384 10.8.2Subclass SalariedCommissionEmployee 387 10.8.3Processing CommissionEmployees and SalariedCommissionEmployees Polymorphically 391 10.8.4A Note About Object-Based and Object-Oriented Programming 391 10.9Duck Typing and Polymorphism 392 10.10Operator Overloading 393 10.10.1Test-Driving Class Complex 394 10.10.2Class Complex Definition 395 10.11Exception Class Hierarchy and Custom Exceptions 397 10.12Named Tuples 399 10.13A Brief Intro to Python 3.7’s New Data Classes 400 10.13.1Creating a Card Data Class 401 10.13.2Using the Card Data Class 403 10.13.3Data Class Advantages over Named Tuples 405 10.13.4Data Class Advantages over Traditional Classes 406 10.14Unit Testing with Docstrings and doctest 406 10.15Namespaces and Scopes 411 10.16Intro to Data Science: Time Series and Simple Linear Regression 414 10.17Wrap-Up 423 11Computer Science Thinking: Recursion, Searching, Sorting and Big O 431 11.1Introduction 432 11.2Factorials 433 11.3Recursive Factorial Example 433 11.4Recursive Fibonacci Series Example 436 11.5Recursion vs. Iteration 439 11.6Searching and Sorting 440 11.7Linear Search 440 11.8Efficiency of Algorithms: Big O 442 11.9Binary Search 444 11.9.1Binary Search Implementation 445 11.9.2Big O of the Binary Search 447 11.10Sorting Algorithms 448 11.11Selection Sort 448 11.11.1Selection Sort Implementation 449 11.11.2Utility Function print_pass 450 11.11.3Big O of the Selection Sort 451 11.12Insertion Sort 451 11.12.1Insertion Sort Implementation 452 11.12.2Big O of the Insertion Sort 453 11.13Merge Sort 454 11.13.1Merge Sort Implementation 454 11.13.2Big O of the Merge Sort 459 11.14Big O Summary for This Chapter’s Searching and Sorting Algorithms 459 11.15Visualizing Algorithms 460 11.15.1Generator Functions 462 11.15.2Implementing the Selection Sort Animation 463 11.16Wrap-Up 468 12Natural Language Processing(NLP) 477 12.1Introduction 478 12.2TextBlob 479 12.2.1Create a TextBlob 481 12.2.2Tokenizing Text into Sentences and Words 482 12.2.3Parts-of-Speech Tagging 482 12.2.4Extracting Noun Phrases 483 12.2.5Sentiment Analysis with TextBlob’s Default Sentiment Analyzer 484 12.2.6Sentiment Analysis with the NaiveBayesAnalyzer 486 12.2.7Language Detection and Translation 487 12.2.8Inflection: Pluralization and Singularization 489 12.2.9Spell Checking and Correction 489 12.2.10Normalization: Stemming and Lemmatization 490 12.2.11Word Frequencies 491 12.2.12Getting Definitions, Synonyms and Antonyms from WordNet 492 12.2.13Deleting Stop Words 494 12.2.14n-grams 496 12.3Visualizing Word Frequencies with Bar Charts and Word Clouds 497 12.3.1Visualizing Word Frequencies with Pandas 497 12.3.2Visualizing Word Frequencies with Word Clouds 500 12.4Readability Assessment with Textatistic 503 12.5Named Entity Recognition with spaCy 505 12.6Similarity Detection with spaCy 507 12.7Other NLP Libraries and Tools 509 12.8Machine Learning and Deep Learning Natural Language Applications 509 12.9Natural Language Datasets 510 12.10Wrap-Up 510 13Data Mining Twitter 515 13.1Introduction 516 13.2Overview of the Twitter APIs 518 13.3Creating a Twitter Account 519 13.4Getting Twitter Credentials—Creating an App 520 13.5What’s in a Tweet 521 13.6Tweepy 525 13.7Authenticating with Twitter Via Tweepy 525 13.8Getting Information About a Twitter Account 527 13.9Introduction to Tweepy Cursors: Getting an Account’s Followers and Friends 529 13.9.1Determining an Account’s Followers 529 13.9.2Determining Whom an Account Follows 532 13.9.3Getting a User’s Recent Tweets 532 13.10Searching Recent Tweets 534 13.11Spotting Trends: Twitter Trends API 536 13.11.1Places with Trending Topics 536 13.11.2Getting a List of Trending Topics 537 13.11.3Create a Word Cloud from Trending Topics 539 13.12Cleaning/Preprocessing Tweets for Analysis 541 13.13Twitter Streaming API 542 13.13.1Creating a Subclass of StreamListener 543 13.13.2Initiating Stream Processing 545 13.14Tweet Sentiment Analysis 547 13.15Geocoding and Mapping 551 13.15.1Getting and Mapping the Tweets 552 13.15.2Utility Functions in tweetutilities.py 556 13.15.3Class LocationListener 558 13.16Ways to Store Tweets 559 13.17Twitter and Time Series 560 13.18Wrap-Up 560 14IBM Watson and Cognitive Computing 565 14.1Introduction: IBM Watson and Cognitive Computing 566 14.2IBM Cloud Account and Cloud Console 568 14.3Watson Services 568 14.4Additional Services and Tools 572 14.5Watson Developer Cloud Python SDK 573 14.6Case Study: Traveler’s Companion Translation App 57 414.6.1Before You Run the App 575 14.6.2Test-Driving the App 576 14.6.3SimpleLanguageTranslator.py Script Walkthrough 577 14.7Watson Resources 587 14.8Wrap-Up 589 15Machine Learning: Classification, Regression and Clustering 593 15.1Introduction to Machine Learning 594 15.1.1Scikit-Learn 595 15.1.2Types of Machine Learning 596 15.1.3Datasets Bundled with Scikit-Learn 598 15.1.4Steps in a Typical Data Science Study 599 15.2Case Study: Classification with k-Nearest Neighbors and the Digits Dataset, Part 1 599 15.2.1k-Nearest Neighbors Algorithm 601 15.2.2Loading the Dataset 602 15.2.3Visualizing the Data 606 15.2.4Splitting the Data for Training and Testing 608 15.2.5Creating the Model 609 15.2.6Training the Model 610 15.2.7Predicting Digit Classes 610 15.3Case Study: Classification with k-Nearest Neighbors and the Digits Dataset, Part 2 612 15.3.1Metrics for Model Accuracy 612 15.3.2K-Fold Cross-Validation 616 15.3.3Running Multiple Models to Find the Best One 617 15.3.4Hyperparameter Tuning 619 15.4Case Study: Time Series and Simple Linear Regression 620 15.5Case Study: Multiple Linear Regression with the California Housing Dataset 625 15.5.1Loading the Dataset 626 15.5.2Exploring the Data with Pandas 628 15.5.3Visualizing the Features 630 15.5.4Splitting the Data for Training and Testing 634 15.5.5Training the Model 634 15.5.6Testing the Model 635 15.5.7Visualizing the Expected vs. Predicted Prices 636 15.5.8Regression Model Metrics 637 15.5.9Choosing the Best Model 638 15.6 Case Study: Unsupervised Machine Learning, Part 1—Dimensionality Reduction639 15.7 Case Study: Unsupervised Machine Learning, Part 2—k-Means Clustering642 15.7.1Loading the Iris Dataset 644 15.7.2Exploring the Iris Dataset: Descriptive Statistics with Pandas 646 15.7.3Visualizing the Dataset with a Seaborn pairplot 647 15.7.4Using a KMeans Estimator 650 15.7.5Dimensionality Reduction with Principal Component Analysis 652 15.7.6Choosing the Best Clustering Estimator 655 15.8Wrap-Up 656 16Deep Learning 665 16.1Introduction 666 16.1.1Deep Learning Applications 668 16.1.2Deep Learning Demos 669 16.1.3Keras Resources 669 16.2Keras Built-In Datasets 669 16.3Custom Anaconda Environments 670 16.4Neural Networks 672 16.5Tensors 674 16.6 Convolutional Neural Networks for Vision; Multi-Classification with the MNIST Dataset676 16.6.1Loading the MNIST Dataset 677 16.6.2Data Exploration 678 16.6.3Data Preparation 680 16.6.4Creating the Neural Network 682 16.6.5Training and Evaluating the Model 691 16.6.6Saving and Loading a Model 696 16.7Visualizing Neural Network Training with TensorBoard 697 16.8ConvnetJS: Browser-Based Deep-Learning Training and Visualization 700 16.9Recurrent Neural Networks for Sequences; Sentiment Analysis with the IMDb Dataset701 16.9.1Loading the IMDb Movie Reviews Dataset 702 16.9.2Data Exploration 703 16.9.3Data Preparation 705 16.9.4Creating the Neural Network 706 16.9.5Training and Evaluating the Model 709 16.10Tuning Deep Learning Models 710 16.11Convnet Models Pretrained on ImageNet 711 16.12Reinforcement Learning 712 16.12.1Deep Q-Learning 713 16.12.2OpenAI Gym 713 16.13Wrap-Up 714 17Big Data: Hadoop, Spark, NoSQL and IoT 723 17.1Introduction 724 17.2Relational Databases and Structured Query Language (SQL) 728 17.2.1A books Database 730 17.2.2SELECT Queries 734 17.2.3WHERE Clause 734 17.2.4ORDER BY Clause 736 17.2.5Merging Data from Multiple Tables: INNER JOIN 737 17.2.6INSERT INTO Statement 738 17.2.7UPDATE Statement 739 17.2.8DELETE FROM Statement 739 17.3NoSQL and NewSQL Big-Data Databases: A Brief Tour 741 17.3.1NoSQL Key–Value Databases 741 17.3.2NoSQL Document Databases 742 17.3.3NoSQL Columnar Databases 742 17.3.4NoSQL Graph Databases 743 17.3.5NewSQL Databases 743 17.4Case Study: A MongoDB JSON Document Database 744 17.4.1Creating the MongoDB Atlas Cluster 745 17.4.2Streaming Tweets into MongoDB 746 17.5Hadoop 75517.5.1Hadoop Overview 755 17.5.2Summarizing Word Lengths in Romeo and Juliet via MapReduce 758 17.5.3Creating an Apache Hadoop Cluster in Microsoft Azure HDInsight 758 17.5.4Hadoop Streaming 760 17.5.5Implementing the Mapper 760 17.5.6Implementing the Reducer 761 17.5.7Preparing to Run the MapReduce Example 762 17.5.8Running the MapReduce Job 763 17.6Spark 766 17.6.1Spark Overview 766 17.6.2Docker and the Jupyter Docker Stacks 767 17.6.3Word Count with Spark 770 17.6.4Spark Word Count on Microsoft Azure 773 17.7 Spark Streaming: Counting Twitter Hashtags Using the pyspark-notebook Docker Stack777 17.7.1Streaming Tweets to a Socket 777 17.7.2Summarizing Tweet Hashtags; Introducing Spark SQL 780 17.8Internet of Things and Dashboards 786 17.8.1Publish and Subscribe 788 17.8.2Visualizing a PubNub Sample Live Stream with a Freeboard Dashboard 788 17.8.3Simulating an Internet-Connected Thermostat in Python 790 17.8.4Creating the Dashboard with Freeboard.io 792 17.8.5Creating a Python PubNub Subscriber 794 17.9Wrap-Up 798 |