Skip to Content
基于scikit-learn和PyTorch的实践机器学习
book

基于scikit-learn和PyTorch的实践机器学习

by Aurélien Géron
October 2025
Intermediate to advanced
878 pages
12h 53m
Chinese
O'Reilly Media, Inc.
Content preview from 基于scikit-learn和PyTorch的实践机器学习

第 2 章 端到端机器学习项目 端到端机器学习项目

本作品已使用人工智能进行翻译。欢迎您提供反馈和意见:translation-feedback@oreilly.com

在本章中,你将通过一个端到端的示例项目,假装自己是一家房地产公司最近聘用的数据科学家。这个例子是虚构的;目的是说明机器学习项目的主要步骤,而不是学习房地产业务的任何知识。以下是我们要经历的主要步骤:

  1. 纵观全局。

  2. 获取数据。

  3. 探索数据并将其可视化,以获得洞察力。

  4. 为机器学习算法准备数据。

  5. 选择一个模型并对其进行训练。

  6. 微调模型

  7. 展示解决方案。

  8. 启动、监控和维护系统。

使用真实数据

当 您学习机器学习时,最好使用真实世界的数据而不是人工数据集进行实验。幸运的是,有成千上万的开放数据集可供选择,涉及各个领域。以下是几个常用的开放数据存储库,你可以用来获取数据:

在本章中,我们将使用 StatLib 数据库中的加州住房价格数据集 (见图 2-1)。1(见图 2-1)。该数据集基于 1990 年加州人口普查的数据。它并不是最近的数据(当时在湾区买一套好房子仍然是负担得起的),但它有许多可供学习的特质,因此我们将假装它是最近的数据。出于教学目的,我添加了一个分类属性,并删除了一些特征。

Map of California displaying housing price data with colored dots representing median house values and dot size indicating population density.
图 2-1. 加州房价

纵观全局

欢迎来到机器学习住房公司!你们的第一项任务是使用加利福尼亚州的人口普查数据来建立该州的房价模型。这些数据包括加州每个街区组的人口、收入中位数和房价中位数等指标。街区组是美国人口普查局公布抽样数据的最小地理单元(一个街区组通常有 600 到 3000 人)。我简称它们为 "区"。

您的模型应从这些数据中学习,并能够在考虑到所有其他指标的情况下预测任何地区的房价中位数。

提示

既然你是一位条理清晰的数据科学家,那么首先应该拿出你的机器学习项目清单 。你可以从https://homl.info/checklist 上的清单开始;它对大多数机器学习项目都很适用,但一定要根据自己的需要进行调整。在本章中,我们将讨论许多清单项目,但也会跳过一些项目,因为它们不言自明,或者将在后面的章节中讨论。

问题框架

要问老板的第一个问题是,业务目标到底是什么。建立一个模型可能不是最终目标。公司希望如何使用这一模型并从中获益?了解目标非常重要,因为它将决定你如何构建问题框架、选择哪种算法、使用哪种性能指标来评估你的模型,以及你将花费多少精力来调整模型。

你的老板回答说,你的模型的输出结果(对某一地区住房价格中位数的预测)对于确定是否值得在某一地区投资至关重要。更具体地说,你的模型输出将与其他一些信号一起输入另一个机器学习系统(见图 2-2)。2因此,让我们的房价模型尽可能准确是非常重要的。

下一个要问老板的问题是,当前的解决方案是什么样的(如果有的话)。目前的情况往往会给你提供一个业绩参考,以及如何解决问题的见解。你的老板回答说,地区房价目前是由专家手动估算的:一个团队收集一个地区的最新 ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

编写整洁的Python代码(第2版)

编写整洁的Python代码(第2版)

Posts & Telecom Press, Mariano Anaya
生成式人工智能可视化

生成式人工智能可视化

Priyanka Vergadia, Valliappa Lakshmanan
AI工程

AI工程

Chip Huyen

Publisher Resources

ISBN: 0642572270117