Python机器学习入门与实战(以实操为基础,以入行为目的,快速帮助你掌握Python机器学习相关技能) (桑园) (Z-Library)
Python
No Description
338
Views
0
Downloads
0.00
Total Donations
Registered users can read the full content for free
Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.
Page
1
(This page has no text content)
Page
2
目录 版权信息 版 权 内容提要 前言 第Ⅰ篇 机器学习入门篇 第1章 机器学习入门之机器学习基础 1.1 做第一个吃螃蟹的人——理解机器学习 1.2 机器学习研究的主要任务 1.2.1 监督学习 1.2.2 非监督学习 1.3 如何选择合适的算法 1.4 机器学习研究问题的一般步骤 1.5 小结 第Ⅱ篇 工具模块使用篇 第2章 机器学习模块之数组计算NumPy
Page
3
2.1 从“人机大战”谈NumPy模块的妙用 2.2 NumPy模块的数组对象 2.2.1 创建数组对象 2.2.2 数组对象类型的说明 2.2.3 随机数生成数组 2.3 NumPy模块中数组的广播 2.3.1 数组广播的原则 2.3.2 数组广播的妙用 2.4 NumPy模块中数组的操作 2.4.1 基本的索引 2.4.2 切片的索引 2.4.3 布尔型索引 2.4.4 数组的转置和轴变换 2.4.5 元素的重复操作:repeat()和tile() 2.5 通用方法:快速的元素级数组方法 2.6 利用数组进行运算 2.6.1 用数学方法进行统计 2.6.2 数组中布尔值的统计 2.6.3 将条件逻辑表述为数组运算 2.6.4 数组的合并和拆分 2.6.5 数组的排序
Page
4
2.6.6 数组的集合运算 2.7 数组文件的输入和输出 2.7.1 将数组以二进制的形式读取文件 2.7.2 存取文本文件 2.8 小结 第3章 机器学习模块之数据分析Pandas 3.1 Pandas数据结构的介绍 3.1.1 Series数据结构 3.1.2 Series数据类型的运算 3.1.3 DataFrame数据结构 3.1.4 DataFrame数据的修改 3.1.5 DataFrame中的索引对象 3.1.6 层次化索引 3.2 Pandas数据结构中的基本数据操作 3.2.1 重新索引 3.2.2 删除指定轴上的项 3.2.3 算术运算和数据对齐 3.3 数据处理 3.3.1 判断缺失数据 3.3.2 删除缺失数据 3.3.3 填充缺失数据
Page
5
3.3.4 移除重复数据 3.3.5 替换数据 3.3.6 排列和随机采样 3.4 方法的应用与映射 3.4.1 排序和排名 3.4.2 带有重复值的轴索引 3.4.3 汇总和计算描述统计 3.4.4 相关系数和协方差 3.5 数据的读取和存储 3.5.1 读取文本文件格式的数据 3.5.2 将数据写出到文本格式 3.6 字符串操作 3.7 合并数据集 3.7.1 数据库风格的DataFrame合并 3.7.2 索引上的合并 3.7.3 轴向的连接 3.7.4 分组合并统计 3.7.5 透视表 3.8 小结 第4章 机器学习模块之图形展示Matplotlib 4.1 Matplotlib绘图入门
Page
6
4.1.1 Figure 和subplot 4.1.2 颜色、标记和线型 4.1.3 坐标轴标记 4.1.4 添加图例 4.1.5 注解 4.1.6 将图表保存到文件 4.2 Matplotlib的绘图方法 4.2.1 线型图 4.2.2 饼图 4.2.3 直方图 4.2.4 条形图 4.2.5 散点图 4.3 小结 第Ⅲ篇 专业技能提升篇 第5章 机器学习算法之算法综述 5.1 从算法巧断小说悬疑情节 5.2 KNN算法概述 5.2.1 使用KNN算法分析生活日常事件 5.2.2 KNN算法的数据准备:使用Python导入数据 5.2.3 如何测试分类器
Page
7
5.3 KNN实战示例:对美颜程度打分 5.3.1 准备数据:从图像和美颜等级表格中解析数据 5.3.2 分析数据:使用Matplotlib创建散点图 5.3.3 测试算法:作为完整程序验证分类器 5.4 KNN实战示例:手写字识别系统 5.4.1 准备数据:将图像转换为测试向量 5.4.2 测试算法:使用KNN算法识别手写数字 5.5 KNN算法面试题解答 5.6 KNN算法自测题 5.7 小结 第6章 机器学习算法之决策树 6.1 巧断推理案引入决策树的妙用 6.2 决策树算法概述 6.2.1 决策树的构造 6.2.2 决策树的信息熵 6.2.3 决策树的信息增益 6.2.4 主播带货能力分析阐释熵及信息增益计算 6.3 决策树创建实战示例:公司老板发红包 6.3.1 公司老板发红包案例说明 6.3.2 熵值的计算算法实现 6.3.3 划分数据集算法实现
Page
8
6.3.4 递归创建决策树 6.4 决策树画法实战示例:公司老板发红包 6.4.1 注解的使用 6.4.2 构造注解树 6.5 决策树测试存储实战示例:公司老板发红包 6.5.1 决策树测试算法 6.5.2 决策树的存储 6.6 决策树预测实战示例:预测海选歌手是否入围 6.6.1 海选歌手入围流程 6.6.2 准备数据、分析数据 6.7 决策树的剪枝 6.7.1 剪枝的概念 6.7.2 预剪枝 6.7.3 后剪枝 6.8 决策树面试题解答 6.9 决策树自测题 6.10 小结 第7章 机器学习算法之朴素贝叶斯 7.1 解决逃命问题引入朴素贝叶斯 7.2 对贝叶斯决策的理解 7.2.1 条件概率解释案例:公司团建
Page
9
7.2.2 使用条件概率进行分类 7.2.3 基于贝叶斯决策理论对分类方法的认识 7.3 使用朴素贝叶斯进行商品的情感分析 7.3.1 使用朴素贝叶斯进行商品的情感分析概述 7.3.2 读取商品评论并切分成文本 7.3.3 构建词向量 7.3.4 用词向量计算概率 7.3.5 对算法的改进 7.3.6 利用概率值进行分类 7.3.7 测试算法 7.4 实战示例:金庸和古龙小说风格判别 7.4.1 收集数据 7.4.2 准备数据 7.4.3 分析数据 7.4.4 测试算法 7.5 朴素贝叶斯面试题解答 7.6 朴素贝叶斯自测题 7.7 小结 第8章 机器学习算法之逻辑回归 8.1 巧析力道学引入逻辑回归 8.2 逻辑回归概述
Page
10
8.2.1 逻辑回归的sigmoid函数 8.2.2 基于最优化方法的最佳回归系数确定 8.2.3 梯度上升算法 8.3 逻辑回归实战示例:鸢尾花分类实现逻辑回归 8.3.1 鸢尾花分类数据集的准备处理 8.3.2 鸢尾花分类逻辑回归sigmoid函数的实现 8.3.3 鸢尾花分类逻辑回归梯度上升函数的实现 8.3.4 鸢尾花分类逻辑回归画出决策边界 8.3.5 鸢尾花分类逻辑回归梯度上升算法的改进 8.4 逻辑回归实战示例:商铺扣点方式 8.4.1 商铺扣点方式的数据读取和处理 8.4.2 商铺扣点方式的逻辑回归分类实现 8.4.3 商铺扣点方式的逻辑回归分类算法的测试 8.5 逻辑回归算法面试题解答 8.6 逻辑回归算法自测题 8.7 小结 第9章 机器学习算法之支持向量机 9.1 巧分落花引入支持向量机 9.2 SVM算法概念 9.2.1 线性可分 9.2.2 超平面
Page
11
9.2.3 SVM 9.3 SVM算法实战示例:电视台黄金时段节目满意度 9.3.1 电视台黄金时段节目满意度数据的读取 9.3.2 选取两个不同Alpha值的辅助函数 9.3.3 Alpha值不允许超过边界范围的辅助函数 9.3.4 SMO算法原理的实现 9.3.5 计算不同的回归系数 9.3.6 SVM分界线的绘制 9.4 SVM算法面试题解答 9.5 SVM算法自测题 9.6 小结 第10章 机器学习算法之AdaBoost 10.1 巧析北斗阵法引入AdaBoost 10.2 AdaBoost算法概述 10.2.1 AdaBoost算法的具体思想 10.2.2 AdaBoost的弱分类器是单层决策树 10.2.3 AdaBoost的数据权重 10.2.4 AdaBoost的投票表决 10.2.5 AdaBoost强分类过程 10.3 AdaBoost算法实现 10.3.1 决策树数据根据阈值进行分类算法的实现
Page
12
10.3.2 单层决策树算法的实现 10.3.3 AdaBoost算法的实现 10.4 AdaBoost算法实战示例:商品购买预测 10.4.1 商品购买预测的数据读取实现 10.4.2 商品购买预测的测试函数实现 10.4.3 商品购买预测的程序整合 10.5 AdaBoost算法面试题解答 10.6 AdaBoost算法自测题 10.7 小结 第11章 机器学习算法之线性回归 11.1 解决论剑问题引入线性回归 11.2 线性回归算法概述 11.2.1 线性回归模型 11.2.2 线性回归的最小二乘法 11.3 线性回归实战示例:钓鱼久坐与鱼重量关系 11.3.1 钓鱼久坐与鱼重量关系研究的数据读取 11.3.2 钓鱼久坐与鱼重量关系研究的最佳拟合直线 11.3.3 钓鱼久坐与鱼重量关系研究的最佳拟合直线的绘制 11.4 线性回归中的过拟合和欠拟合 11.4.1 线性回归中的过拟合 11.4.2 线性回归中的欠拟合
Page
13
11.5 局部加权线性回归 11.5.1 局部加权线性回归的解释 11.5.2 局部加权线性回归的代码实现 11.5.3 局部加权线性回归的测试 11.6 线性回归实战示例:结合年龄和BMI拟合减肥花销 11.6.1 结合年龄和BMI拟合减肥花销的数据读取 11.6.2 结合年龄和BMI拟合减肥花销直线的函数实现 11.7 线性回归提高:岭回归和套索回归 11.7.1 岭回归 11.7.2 套索回归 11.8 岭回归实战示例:分析抖音视频点击率和收藏 11.8.1 岭回归分析抖音视频点击率和收藏的数据读取 11.8.2 岭回归算法逻辑的实现 11.8.3 岭回归算法系数的测试 11.8.4 不同λ值的岭回归算法的最佳拟合直线 11.9 线性回归算法面试题解答 11.10 线性回归算法自测题 11.11 小结 第12章 机器学习算法之k-means 12.1 “巧施反间计”引入k-means聚类 12.2 k-means算法概述
Page
14
12.3 k-means幼儿园亲子活动 12.3.1 收集数据 12.3.2 准备数据 12.3.3 分析数据 12.3.4 实现算法 12.3.5 画出k-means算法的结果图 12.4 图像分割技术实现聚类 12.4.1 准备数据 12.4.2 距离计算 12.4.3 第一次随机质心的计算 12.4.4 k-means算法的改进 12.4.5 k-means图像分割的显示 12.5 图像分割算法的改进 12.5.1 k-means图像分割的显示 12.5.2 像素距离的改进 12.5.3 第一次随机质心的计算 12.5.4 k-means算法的改进 12.5.5 k-means图像分割的显示 12.6 k-means算法面试题解答 12.7 k-means算法自测题 12.8 小结
Page
15
第13章 机器学习算法之PCA 13.1 巧拼十八掌法引入PCA聚类 13.2 聚类的概念和分类 13.2.1 聚类的概念 13.2.2 分层凝聚聚类方法 13.2.3 PCA聚类方法 13.3 PCA聚类方法的求解步骤 13.3.1 协方差矩阵 13.3.2 奇异值求解 13.4 PCA实战示例:使用PCA实现菜品制作调料配比 13.4.1 准备数据:菜品制作调料配比表数据的读取 13.4.2 PCA算法:菜品制作调料配比表PCA降维 13.4.3 表征数据:菜品制作调料配比降维结果图示 13.5 PCA实战示例:使用PCA分析图像压缩技术 13.5.1 图像读取:Pillow模块读取图像 13.5.2 图像压缩:PCA算法实现图像压缩 13.5.3 错误率计算:图像压缩错误率的计算 13.6 PCA算法面试题解答 13.7 PCA算法自测题 13.8 小结 第Ⅳ篇 深度学习延伸篇
Page
16
第14章 深度学习延伸之卷积神经网络 14.1 认识神经网络 14.1.1 神经元 14.1.2 激活函数 14.2 认识卷积神经网络 14.2.1 卷积层 14.2.2 一维卷积过程 14.2.3 卷积神经网络输入层前向传播到卷积层 14.2.4 池化层 14.2.5 全连接层 14.3 Keras框架实现卷积神经网络 14.3.1 Keras模块介绍 14.3.2 Keras框架的安装 14.3.3 Keras框架数据集的准备 14.3.4 Keras实现CNN卷积神经网络 14.4 小结 第Ⅴ篇 项目技能实战篇 第15章 机器学习实战之验证码识别 15.1 验证码识别 15.2 图像处理的灰度化、二值化
Page
17
15.2.1 像素点 15.2.2 图像灰度化 15.2.3 图像二值化 15.3 图像分割 15.3.1 按区域划分的图像分割技术 15.3.2 按边缘划分的图像分割技术 15.3.3 图像分割技术的进阶 15.4 KNN算法测试验证码 15.4.1 Sklearn包的介绍 15.4.2 KNN算法测试验证码 15.5 小结 第16章 机器学习实战之答题卡识别 16.1 答题卡识别 16.2 OpenCV 16.2.1 OpenCV介绍 16.2.2 安装和使用OpenCV 16.2.3 OpenCV存取图像 16.2.4 OpenCV图像灰度化 16.2.5 OpenCV图像二值化 16.2.6 OpenCV边缘检测 16.3 OpenCV形态学中腐蚀与膨胀
Page
18
16.3.1 形态学中的膨胀 16.3.2 形态学中的腐蚀 16.3.3 腐蚀和膨胀的应用 16.4 OpenCV轮廓findContours和drawContours 16.5 OpenCV霍夫直线检测 16.6 答题卡识别 16.7 小结 第17章 简历分享就业之机器学习简历指导 17.1 机器学习简历中应提及的技能 17.2 机器学习简历中项目的描述 17.3 机器学习简历分享 17.4 小结
Page
19
(This page has no text content)
Page
20
版权信息 书名:Python机器学习入门与实战 ISBN:978-7-115-60190-2 本书由人民邮电出版社发行数字版。版权所有,侵权必究。 您购买的人民邮电出版社电子书仅供您个人使用,未经授权,不 得以任何方式复制和传播本书内容。 我们愿意相信读者具有这样的良知和觉悟,与我们共同保护知识 产权。 如果购买者有侵权行为,我们可能对该用户实施包括但不限于关 闭该帐号等维权措施,并可能追究法律责任。
The above is a preview of the first 20 pages. Register to read the complete e-book.
AI Reading Assistant
Whole-book reading guide from stratified index samples; jump to passages in the text
AI guide
# Python机器学习入门与实战
## 【One-Line Pitch】
A hands-on, career-oriented introduction to machine learning in Python, walking beginners from NumPy/Pandas foundations through classic algorithms (KNN, decision trees, Naive Bayes, logistic regression, SVM, AdaBoost, linear regression, k-means) with practical code examples and Chinese-context case studies. Ideal for readers who want to learn by doing rather than by theory alone.
## 【Book Arc】
- **Opening (~0%–6%)**: Introduces machine learning fundamentals — supervised vs. unsupervised learning, training/test sets — using accessible analogies (traffic lights, chess, mushroom classification), then dives into NumPy essentials: array creation, broadcasting, boolean indexing, transposition, and universal functions.
- **Early (~6%–25%)**: Covers Pandas data structures (Series, DataFrame) with practical operations: indexing, reindexing with fill methods, handling missing data (dropna, fillna, isnull), replacement, permutation/random sampling, axis-wise aggregation, string operations, and concatenation — all demonstrated with relatable examples like car pricing and membership data.
- **Early (~25%–31%)**: Introduces Matplotlib for data visualization — subplots, line styling, legends with custom fonts — then transitions into the first ML algorithm: KNN, including data preparation, classification logic, and error-rate testing with a "beauty rating" example.
- **Middle (~31%–50%)**: Explores decision trees through a detective-story analogy (solving a theft with if-else logic), covering entropy, information gain, majority voting, tree plotting, and pruning strategies. Then moves to Naive Bayes with sentiment analysis of product reviews, including TF-IDF concepts and Laplace smoothing to avoid zero probabilities.
- **Middle (~50%–63%)**: Presents logistic regression (sigmoid function, gradient descent, iris classification), SVM (hyperplanes, margins, SMO algorithm), and AdaBoost (weak classifiers, weighted voting, product-purchase prediction) — each with complete code implementations and test workflows.
- **Late (~63%–end)**: Covers linear regression variants — standard, locally weighted, ridge, and lasso — with practical examples (fishing time vs. fish weight, age/BMI vs. weight-loss spending, Douyin video metrics), then concludes with k-means clustering explained through a "kingdom of martial arts" analogy with centroid iteration logic.
## 【Key Takeaways】
- **Machine learning = learning from labeled data** (Early): Supervised learning uses training sets with features and labels to predict labels for new data; unsupervised learning finds structure without labels. This distinction frames every algorithm in the book.
- **NumPy arrays are the computational backbone** (Early): Master broadcasting, boolean indexing, transpose, reshape, and ufuncs like reduce() — these operations underpin all later ML implementations and vectorized computations.
- **Pandas makes data wrangling practical** (Early): Series and DataFrame operations — reindexing with ffill/bfill, dropna/fillna for missing data, permutation for sampling, concat for merging — are the daily tools for preparing real datasets before any modeling.
- **Decision trees are optimized if-else logic** (Middle): The algorithm selects features by information gain, uses majority voting for ties, and requires pruning (pre- or post-) to prevent overfitting — a core concept for understanding model generalization.
- **Naive Bayes simplifies via independence assumption** (Middle): Assuming features are conditionally independent drastically reduces complexity; practical tricks like Laplace smoothing (initializing counts to 1) and log-transforms prevent underflow in sentiment analysis.
- **Logistic regression turns regression into classification** (Middle): The sigmoid function maps continuous values to probabilities, enabling binary classification (e.g., iris species); gradient descent with tuned step sizes avoids oscillation during coefficient optimization.
- **Ensemble methods boost weak learners** (Middle): AdaBoost combines multiple weak classifiers (e.g., axis-parallel lines) with weighted voting, iteratively focusing on misclassified samples to build a strong classifier — demonstrated with product-purchase prediction.
- **Regularization handles multicollinearity** (Late): Ridge and lasso regression add penalties to stabilize coefficient estimates when independent variables are correlated, as shown in the Douyin video engagement example with different λ values.
## 【Reading Tips】
- **Skim the storytelling intros, focus on code**: Each chapter opens with an analogy (detective stories, martial arts, fishing) to build intuition — read these for conceptual understanding, but the real value is in the code listings and their step-by-step explanations.
- **Type out the code yourself**: The book is explicitly practice-oriented; copying and running each listing (especially in Chapters 2–3 for NumPy/Pandas) builds muscle memory that reading alone cannot provide.
- **Deep-read Chapters 5–7 for algorithm fundamentals**: KNN, decision trees, and Naive Bayes are the most thoroughly explained with both theory and complete implementations — mastering these makes later chapters (SVM, AdaBoost) much easier.
- **Watch for the "interview questions" sections**: Chapters 6 and 11 include common ML interview questions (e.g., causes of overfitting in decision trees) — these are excellent self-checks and career-prep resources.
- **Don't get stuck on math notation**: The book explains formulas in plain language alongside code; if a formula feels opaque, jump to the code implementation and work backward to understand the logic.
## 【Coverage Limits】
This guide covers the book's progression through Python ML fundamentals and eight core algorithms. The excerpts do not cover any deep learning, neural networks, or advanced model-tuning topics — the book appears focused on classical machine learning only.
##
Passage locations
Excerpt 1
20,19,21,17,18]]) print(weathers.mean(1).reshape((4,1))) meaned=weathers-weathers.mean(1).reshape((4,1)) print(meaned) print(meaned.mean(1)) 上述代码中,reshape((4...
View in text
Excerpt 2
print(member) 代码中使用concat()方法连接3个无重叠索引的Series,传入了参 数axis=1。上述代码运行结果如图3.77所示。 图3.77 Pandas实现会员concat()无重叠索引轴变换的连接的代码运行结果 从结果上看,输出了DataFrame数据结构,这是由于传入axis=1,...
View in text
Excerpt 3
_num.iteritems(),key=operator.itemgetter(1 ),reverse=True) return sorted_class_num[0][0] 这段代码中的函数接收一个传入的参数,即分类名称的列表,然后创 建class_num字典,对传入的分类名称列表进行遍历。如果键没有存储在...
View in text
Excerpt 4
as) 上述代码的运行结果如图9.6所示。 给定训练样本,弱分类器采用平行于坐标轴的直线,用AdaBoost算 法实现强分类,具体数据如表10.1所示。 表10.1 AdaBoost算法强分类过程样本数据 样本序号 1 2 3 4 5 6 7 8 9 10 样本点坐标 (2,4) (3,5) (3,2) (5,7...
View in text
Recommended for You
{{#thumbnailUrl}}
{{/thumbnailUrl}}
{{^thumbnailUrl}}
{{/thumbnailUrl}}
Loading recommended books...
Failed to load, please try again later
Tip the Site
Scan the WeChat Pay or Alipay code to tip. No login required.
WeChat Pay
Alipay