作者 |
[意]迪诺·埃斯波西托(Dino Esposito) 弗朗西斯科·埃斯波西托(Francesco Esposito) |
丛书名 |
经典原版书库 |
出版社 |
机械工业出版社 |
ISBN |
9787111671817 |
简要 |
简介 |
内容简介书籍计算机书籍 本书介绍学习深度学习的基础知识,了解机器学习流程:产生可交付模型的步骤,掌握进行预测,改进决策,并应用概率方法,以及通过分类和聚类对数据进行分组机器学习可以解决哪些问题。提出了一系列可以用来解决现实问题的算法,以及利用神经网络的深度学习技术。本书适合对于想要构建机器学习应用程序的专业人员。 |
目录 |
第一部分 机器学习基础 第1章 人类是如何学习的 3 迈向思考型机器 4 机器推理的曙光 4 哥德尔不完备定理 4 计算机的形式化 5 迈向人类思想的形式化 5 人工智能学科的诞生 6 学习原理 7 什么是智能软件 7 神经元是如何工作的 8 大棒加胡萝卜法 14 应变能力 15 人工智能的形式 16 原始智能 16 专家系统 16 自治系统 19 人工情感的形式 20 小结 22 第2章 智能软件 23 应用人工智能 23 软件智能的发展 24 专家系统 25 通用人工智能 27 无监督学习 27 监督学习 29 小结 32 第3章 映射问题和算法 33 基本问题 33 对象分类 34 结果预测 36 对象分组 38 更复杂的问题 40 图像分类 41 目标检测 41 文本分析 42 自动机器学习 42 AutoML平台概述 42 AutoML模型构建器实战 45 小结 48 第4章 机器学习解决方案的一般步骤 49 数据收集 50 组织中的数据驱动文化 50 存储选项 51 数据准备 52 提高数据质量 53 清洗数据 53 特征工程 54 最终确定训练数据集 56 模型选择及训练 58 算法速查表 59 神经网络案例 61 评估模型性能 62 模型部署 64 选择合适的主机平台 64 公开API 65 小结 66 第5章 数据因素 67 数据质量 67 数据有效性 68 数据收集 69 数据完整性 70 完备性 70 唯一性 70 及时性 71 准确性 71 一致性 71 什么是数据科学家 71 工作中的数据科学家 72 数据科学家的工具箱 73 数据科学家和软件开发人员 73 小结 74 第二部分 .NET中的机器学习 第6章 .NET方式 77 为什么用/不用Python 78 为什么Python在机器学习中如此受欢迎 78 Python机器学习库的分类 80 基于Python模型的端到端解决方案 82 ML.NET简介 83 在ML.NET中创建和使用模型 84 学习环境的要素 87 小结 91 第7章 实现ML.NET管道 93 从数据开始 93 探索数据集 94 应用公共数据转换 94 关于数据集的注意事项 95 训练步骤 96 选择算法 96 测量算法的实际值 97 计划测试阶段 97 指标预览 98 从客户端应用程序中预测价格 99 获取模型文件 99 设置ASP.NET应用程序 99 预测出租车费用 100 设计适当的用户界面 102 质疑数据和解决问题的方法 103 小结 103 第8章 ML.NET任务和算法 105 ML.NET的整体框架 105 涉及的类型和接口 105 数据表示 107 支持的 109 分类任务 111 二进制分类 111 多类分类 116 聚类任务 122 准备工作数据 122 训练模型 123 评估模型 124 迁移学习 126 建立图像分类器的步骤 127 应用必要的数据转换 127 模型的构建和训练 129 关于迁移学习的补充说明 131 小结 132 第三部分 浅层学习基础 第9章 机器学习的数学基础 135 统计数据 135 均值 136 众数 138 中位数 139 偏差和方差 141 方差 142 偏差 144 数据表示 145 五数概括法 145 直方图 146 散点图 148 散点图矩阵 148 以适当的比例绘制 149 小结 150 第10章 机器学习的度量 151 统计与机器学习 151 机器学习的终极目标 152 从统计模型到机器学习模型 153 机器学习模型的评价 155 从数据集到预测 155 测量模型的精度 157 为处理准备数据 162 缩放 162 标准化 163 归一化 163 小结 163 第11章 进行简单预测:线性回归 165 问题 165 用数据指导预测结果 166 对关系做假设 167 线性算法 169 总体思路 169 确定代价函数 170 普通的最小二乘算法 171 梯度下降算法 174 判断算法的好坏 178 改进解决方案 178 多项式方法 178 正则化 179 小结 180 第12章 进行复杂的预测和决策:决策树 181 问题 181 什么是树 182 机器学习中的树 183 基于树的算法示例 183 基于树的算法的设计原理 185 决策树与专家系统 185 树算法的种类 186 分类树 187 CART算法的工作原理 187 ID3算法的工作原理 191 回归树 194 算法的工作原理 194 剪枝 195 小结 196 第13章 进行更好的决策:集成学习算法 197 问题 197 bagging技术 198 随机森林算法 198 算法步骤 200 优点与缺点 202 boosting技术 203 boosting的功能 203 梯度boosting 206 优点与缺点 210 小结 210 第14章 概率方法:朴素贝叶斯 211 贝叶斯统计快速入门 211 贝叶斯概率简介 212 基本符号 212 贝叶斯定理 214 一个实用的代码审查示例 215 贝叶斯统计在分类中的应用 216 问题的初始表述 217 简化的有效分子式 217 贝叶斯分类器实践 218 朴素贝叶斯分类器 219 通用算法 219 多项式朴素贝叶斯 220 伯努利朴素贝叶斯 223 高斯朴素贝叶斯 224 朴素贝叶斯回归 226 贝叶斯线性回归的基础 226 贝叶斯线性回归的应用 228 小结 228 第15章 对数据进行分组:分类与聚类 229 有监督分类的基本方法 230 K–近邻算法 230 算法步骤 232 应用场景 234 支持向量机 235 算法概述 235 数学知识回顾 239 算法步骤 240 无监督聚类 245 应用案例:缩减数据集 245 K–均值算法 246 K–模型算法 247 DBSCAN算法 248 小结 251 第四部分 深度学习基础 第16章 前馈神经网络 255 神经网络简史 255 McCulloch-Pitt神经元 255 前馈网络 256 更复杂的网络 256 人工神经元的类型 257 感知机神经元 257 逻辑神经元 260 训练神经网络 263 整体学习策略 263 反向传播算法 264 小结 270 第17章 神经网络的设计 273 神经网络概览 273 激活函数 274 隐层 277 输出层 281 构建神经网络 282 现成的框架 282 你的第一个Keras神经网络 284 神经网络与其他算法 287 小结 289 第18章 其他类型的神经网络 291 前馈神经网络的常见问题 291 递归神经网络 292 有状态神经网络的结构 292 LSTM神经网络 295 卷积神经网络 298 图像分类与识别 298 卷积层 299 池化层 301 全连接层 303 神经网络的进一步发展 304 生成对抗神经网络 304 自动编码器 305 小结 307 第19章 情感分析:端到端解决方案 309 为训练准备数据 310 对问题进行形式化 310 获取数据 311 处理数据 311 关于中间格式的注意事项 313 训练模型 313 选择生态系统 314 建立单词字典 314 选择训练器 315 网络的其他方面 319 客户端应用 321 获取模型的输入 321 从模型中预测 322 将响应转化为可用信息 323 小结 323 第五部分 思考 第20章 面向现实世界的AI云服务 327 Azure认知服务 327 Azure机器学习工作室 329 Azure机器学习服务 331 数据科学虚拟机 333 本地服务 333 SQL Server机器学习服务 333 机器学习服务器 334 微软数据处理服务 334 Azure数据湖 334 Azure Databricks 334 Azure HDInsight 335 用于Apache Spark的.NET 335 Azure数据分享 336 Azure数据工厂 336 小结 336 第21章 人工智能的商业愿景 339 工业界对AI的看法 339 挖掘潜能 339 AI可以为你做什么 340 面临的挑战 342 端到端解决方案 343 我们就叫它咨询吧 344 软件和数据科学之间的界线 344 敏捷AI 346 小结 349 Contents PART I LAYING THE GROUNDWORK OF MACHINE LEARNING Chapter 1 How Humans Learn 3 The Journey Toward Thinking Machines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4 The Dawn of Mechanical Reasoning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4 Godel’s Incompleteness Theorems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4 Formalization of Computing Machines. . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 Toward the Formalization of Human Thought . . . . . . . . . . . . . . . . . . . . . 5 The Birth of Artificial Intelligence as a Discipline . . . . . . . . . . . . . . . . . . . 6 The Biology of Learning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 What Is Intelligent Software, Anyway . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 How Neurons Work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 The Carrot-and-Stick Approach . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 Adaptability to Changes . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . 15 Artificial Forms of Intelligence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 Primordial Intelligence . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . 16 Expert Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 Autonomous Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 Artificial Forms of Sentiment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .20 Summary . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . .22 Chapter 2 Intelligent Software 23 Applied Artificial Intelligence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .23 Evolution of Software Intelligence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .24 Expert Systems . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . .25 General Artificial Intelligence . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . .27 Unsupervised Learning . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . .27 Supervised Learning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .29 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .32 Chapter 3 Mapping Problems and Algorithms 33 Fundamental Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .33 Classifying Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .34 Predicting Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .36 Grouping Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .38 More Complex Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .40 Image Classification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41 Object Detection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41 Text Analytics . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . . . . . . . . . .42 Automated Machine Learning . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . .42 Aspects of an AutoML Platform . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .42 The AutoML Model Builder in Action . . . . . . . . . . . . . . . . . . . . . . . . . . . .45 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .48 Chapter 4 General Steps for a Machine Learning Solution 49 Data Collection . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . . .50 Data-Driven Culture in the Organization . . . . . . . . . . . . . . . . . . . . . . . . .50 Storage Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51 Data Preparation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .52 Improving Data Quality . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .53 Cleaning Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .53 Feature Engineering . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . .54 Finalizing the Training Dataset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .56 Model Selection and Training . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .58 The Algorithm Cheat Sheet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .59 The Case for Neural Networks . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . 61 Evaluation of the Model Performance . . . . . . . . . . . . . . . . . . . . . . . . . . .62 Deployment of the Model. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .64 Choosing the Appropriate Hosting Platform . . . . . . . . . . . . . . . . . . . . .64 Exposing an API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .65 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . .66 Chapter 5 The Data Factor 67 Data Quality . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .67 Data Validity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .68 Data Collection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .69 Data Integrity . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . .70 Completeness . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .70 Uniqueness . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . .. . . . . . . . .70 Timeliness . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71 Accuracy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ... . . . . 71 Consistency . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71 What’s a Data Scientist, Anyway . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71 The Data Scientist at Work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .72 The Data Scientist Tool Chest . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .73 Data Scientists and Software Developers . . . . . . . . . . . . . . . . . . . . . . . . .73 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .74 PART II MACHINE LEARNING IN .NET Chapter 6 The .NET Way 77 Why (Not) Python . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .78 Why Is Python So Popular in Machine Learning . . . . . . . . . . . . . . . . . .78 Taxonomy of Python Machine Learning Libraries . . . . . . . . . . . . . . . . .80 End-to-End Solutions on Top of Python Models . . . . . . . . . . . . . . . . . .82 Introducing ML.NET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .83 Creating and Consuming Models in ML.NET . . . . . . . . . . . . . . . .. . . . .84 Elements of the Learning Context . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .87 Summary . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 91 Chapter 7 Implementing the ML.NET Pipeline 93 The Data to Start From . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .93 Exploring the Dataset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .94 Applying Common Data Transformations . . . . . . . . . . . . . . . . . . . . . . . .94 Considerations on the Dataset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .95 The Training Step . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . . . .96 Picking an Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .96 Measuring the Actual Value of an Algorithm . . . . . . . . . . . . . . . . . . . . .97 Planning the Testing Phase . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . .97 A Look at the Metrics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .98 Price Prediction from Within a Client Application . . . . . . . . . . . . . . . . . . . . . . .99 Getting the Model File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .99 Setting Up the ASP.NET Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . .99 Making a Taxi Fare Prediction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .100 Devising an Adequate User Interface . . . . . . . . . . . . . . . . . . . . . . . . . . .102 Questioning Data and Approach to the Problem . . . . . . . . . . . . . . . .103 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .103 Chapter 8 ML.NET Tasks and Algorithms 105 The Overall ML.NET Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .105 Involved Types and Interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .105 Data Representation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107 Supported Catalogs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .109 Classification Tasks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .111 Binary Classification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .111 Multiclass Classification . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . 116 Clustering Tasks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .122 Preparing Data for Work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .122 Training the Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .123 Evaluating the Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .124 Transfer Learning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126 Steps for Building an Image Classifier . . . . . . . . . . . . . . . . . . . . . . . . . . . 127 Applying Necessary Data Transformations . . . . . . . . . . . . . . . . . . . . . . 127 Composing and Training the Model . . . . . . . . . . . . . . . . . . . . . . . . . . . .129 Margin Notes on Transfer Learning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132 PART III FUNDAMENTALS OF SHALLOW LEARNING Chapter 9 Math Foundations of Machine Learning 135 Under the Umbrella of Statistics . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . 135 The Mean in Statistics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136 The Mode in Statistics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138 The Median in Statistics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139 Bias and Variance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . 141 The Variance in Statistics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .142 The Bias in Statistics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .144 Data Representation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . .145 Five-number Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .145 Histograms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .146 Scatter Plots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148 Scatter Plot Matrices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .148 Plotting at the Appropriate Scale . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .149 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .150 Chapter 10 Metrics of Machine Learning 151 Statistics vs. Machine Learning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151 The Ultimate Goal of Machine Learning . . . . . . . . . . . . . . . . . . . . . . . . . 152 From Statistical Models to Machine Learning Models . . . . . . . . . . . . 153 Evaluation of a Machine Learning Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155 From Dataset to Predictions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155 Measuring the Precision of a Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157 Preparing Data for Processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .162 Scaling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .162 Standardization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .163 Normalization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .163 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .163 Chapter 11 How to Make Simple Predictions: Linear Regression 165 The Problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .165 Guessing Results Guided by Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .166 Making Hypotheses About the Relationship . . . . . . . . . . . . . . . . . . . . . 167 The Linear Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .169 The General Idea . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .169 Identifying the Cost Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170 The Ordinary Least Square Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . 171 The Gradient Descent Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174 How Good Is the Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178 Improving the Solution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178 The Polynomial Route . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178 Regularization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .180 Chapter 12 How to Make Complex Predictions and Decisions: Trees 181 The Problem . . . . . . . .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181 What’s a Tree, Anyway . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .182 Trees in Machine Learning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .183 A Sample Tree-Based Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .183 Design Principles for Tree-Based Algorithms . . . . . . . . . . . . . . . . . . . . . . . . . .185 Decision Trees versus Expert Systems . . . . . . . . . . . . . . . . . . . . . . . . . . .185 Flavors of Tree Algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .186 Classification Trees . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187 How the CART Algorithm Works . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187 How the ID3 Algorithm Works . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191 Regression Trees. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . .194 How the Algorithm Works . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .194 Tree Pruning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .195 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .196 Chapter 13 How to Make Better Decisions: Ensemble Methods 197 The Problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197 The Bagging Technique . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .198 Random Forest Algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .198 Steps of the Algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .200 Pros and Cons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .202 The Boosting Technique . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .203 The Power of Boosting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .203 Gradient Boosting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .206 Pros and Cons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .210 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .210 Chapter 14 Probabilistic Methods: Na.ve Bayes 211 Quick Introduction to Bayesian Statistics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211 Introducing Bayesian Probability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .212 Some Preliminary Notation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .212 Bayes’ Theorem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .214 A Practical Code Review Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215 Applying Bayesian Statistics to Classification . . . . . . . . . . . . . . . . . . . . . . . . . .216 Initial Formulation of the Problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217 A Simplified (Yet Effective) Formulation . . . . . . . . . . . . . . . . . . . . . . . . . 217 Practical Aspects of Bayesian Classifiers . . . . . . . . . . . . . . . . . . . . . . . . .218 Na.ve Bayes Classifiers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .219 The General Algorithm . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . .219 Multinomial Na.ve Bayes . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . .220 Bernoulli Na.ve Bayes . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . .223 Gaussian Na.ve Bayes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .224 Na.ve Bayes Regression . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .226 Foundation of Bayesian Linear Regression . . . . . . . . . . . . . . . . . . . . . .226 Applications of Bayesian Linear Regression . . . . . . . . . . . . . . . . . . . . . .228 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . .228 Chapter 15 How to Group Data: Classification and Clustering 229 A Basic Approach to Supervised Classification . . . . . . . . . . . . . . . . . . . . . . . . .230 The K-Nearest Neighbors Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . .230 Steps of the Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .232 Business Scenarios . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .234 Support Vector Machine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .235 Overview of the Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .235 A Quick Mathematical Refresher . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .239 Steps of the Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .240 Unsupervised Clustering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .245 A Business Case: Reducing the Dataset . . . . . . . . . . . . . . . . . . . . . . . . . .245 The K-Means Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .246 The K-Modes Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .247 The DBSCAN Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .248 Summary . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . . . . . . . 251 PART IV FUNDAMENTALS OF DEEP LEARNING Chapter 16 Feed-Forward Neural Networks 255 A Brief History of Neural Networks . . . . . . . . . . . . . . . . . . . . . . . . . . .255 The McCulloch-Pitt Neuron . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .255 Feed-Forward Networks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .256 More Sophisticated Networks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .256 Types of Artificial Neurons . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . .257 The Perceptron Neuron . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . .257 The Logistic Neuron . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .260 Training a Neural Network . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .263 The Overall Learning Strategy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .263 The Backpropagation Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .264 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . .270 Chapter 17 Design of a Neural Network 273 Aspects of a Neural Network . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .273 Activation Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .274 Hidden Layers . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . .277 The Output Layer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .281 Building a Neural Network . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . .282 Available Frameworks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .282 Your First Neural Network in Keras. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .284 Neural Networks versus Other Algorithms . . . . . . . . . . . . . . . . . . . . . .287 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .289 Chapter 18 Other Types of Neural Networks 291 Common Issues of Feed-Forward Neural Networks . . . . . . . . . . . . . . . . . . . .291 Recurrent Neural Networks . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . .292 Anatomy of a Stateful Neural Network . . . . . . . . . . . . . . . . . . . . . . . . . .292 LSTM Neural Networks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .295 Convolutional Neural Networks . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . .298 Image Classification and Recognition . . . . . . . . . . . . . . . . . . . . . . . . . . .298 The Convolutional Layer . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . .299 The Pooling Layer . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . .301 The Fully Connected Layer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .303 Further Neural Network Developments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .304 Generative Adversarial Neural Networks. . . . . . . . . . . . . . . . . . . . . . . .304 Auto-Encoders . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . .305 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .307 Chapter 19 Sentiment Analysis: An End-to-End Solution 309 Preparing Data for Training . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . .310 Formalizing the Problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .310 Getting the Data. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 311 Manipulating the Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 311 Considerations on the Intermediate Format . . . . . . . . . . . . . . . . . . . . . 313 Training the Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 313 Choosing the Ecosystem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .314 Building a Dictionary of Words . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .314 Choosing the Trainer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 315 Other Aspects of the Network . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 319 The Client Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .321 Getting Input for the Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .321 Getting the Prediction from the Model . . . . . . . . . . . . . . . . . . . . . . . . .322 Turning the Response into Usable Information . . . . . . . . . . . . . . . . . .323 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .323 PART V FINAL THOUGHTS Chapter 20 AI Cloud Services for the Real World 327 Azure Cognitive Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .327 Azure Machine Learning Studio . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .329 Azure Machine Learning Service . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 331 Data Science Virtual Machines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .333 On-Premises Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . .333 SQL Server Machine Learning Services . . . . . . . . . . . . . . . . . . . . . . . . . .333 Machine Learning Server . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . .334 Microsoft Data Processing Services . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . .334 Azure Data Lake . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .334 Azure Databricks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .334 Azure HDInsight . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .335 .NET for Apache Spark . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .335 Azure Data Share . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .336 Azure Data Factory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .336 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .336 Chapter 21 The Business Perception of AI 339 Perception of AI in the Industry . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .339 Realizing the Potential . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .339 What Artificial Intelligence Can Do for You . . . . . . . . . . . . . . . . . . . . . .340 Challenges Around the Corner . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .342 End-to-End Solutions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .343 Let’s Just Call It Consulting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ..344 The Borderline Between Software and Data Science . . . . . . . . . . . . .344 Agile AI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .346 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .349 Index 351 |