Skip to Content
Think Stats 第3版 ―Pythonで学ぶ統計学入門
book

Think Stats 第3版 ―Pythonで学ぶ統計学入門

by Allen B. Downey, 大橋 真也
October 2025
Intermediate to advanced
328 pages
3h 56m
Japanese
O'Reilly Japan, Inc.
Content preview from Think Stats 第3版 ―Pythonで学ぶ統計学入門

10章最小二乗法

10章と11章では、データにモデルをフィットさせるという考え方を紹介します。ここで言うモデルとは、変数間の関係性の数学的記述(例えば直線など)と、ランダムな変動の記述(例えば正規分布など)から構成されます。

モデルがデータに「適合(フィット)」するとは、一般的にモデルとデータ間の距離である誤差を最小化するということを意味します。まずは最も広く使われている方法の1つである、最小二乗法と呼ばれる二乗誤差の和を最小化する手法から始めましょう。

また、最初は2つの変数だけを扱うモデルから始め、11章では、より多くの変数を扱うモデルを紹介します。

10.1 最小二乗法

最初の例として、8章で登場した「8.1 ペンギンの体重測定」のシナリオに戻りましょう。あなたは南極でペンギンの個体数を調査する研究者だとします。データ収集の一環として、あなたは捕獲したペンギンの測定や計測を行い、無傷で解放します。

すぐにわかることですが、ペンギンを正確に計測するのは容易ではありません。翼やくちばしの大きさなどは測定できても、体重データがない個体も出てきます。このような欠損値を補完する(このプロセスをインピュテーションとも呼びます)ために、他の測定値から体重を推定できないかを検討しましょう。

まずは、南極のパーマー基地の研究者らが2007年から2010年にかけて収集したデータを用いて、体重と他の測定値との関係を探ることから始めてみましょう。このデータは自由に利用可能で、ダウンロード方法は10章のノートブック(chap10.ipynb)で説明しています。

データの読み込みにはread_csv関数を使います。

penguins = pd.read_csv("penguins_raw.csv").dropna(subset=["Body ...
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

SRE サイトリライアビリティエンジニアリング ―Googleの信頼性を支えるエンジニアリングチーム

SRE サイトリライアビリティエンジニアリング ―Googleの信頼性を支えるエンジニアリングチーム

Betsy Beyer, Chris Jones, Jennifer Petoff, Niall Richard Murphy, 澤田 武男, 関根 達夫, 細川 一茂, 矢吹 大輔, Sky株式会社 玉川 竜司
MLOps実装ガイド ―本番運用を見据えた開発戦略

MLOps実装ガイド ―本番運用を見据えた開発戦略

Yaron Haviv, Noah Gift, 井伊 篤彦, 入江 美穂, 張 凡, 樋口 千洋

Publisher Resources

ISBN: 9784814401376Publisher Website