Skip to Content
機械学習デザインパターン ―データ準備、モデル構築、MLOpsの実践上の問題と解決
book

機械学習デザインパターン ―データ準備、モデル構築、MLOpsの実践上の問題と解決

by Valliappa Lakshmanan, Sara Robinson, Michael Munn, 鷲崎 弘宜, 竹内 広宜, 名取 直毅, 吉岡 信和
October 2021
Beginner to intermediate
414 pages
6h 25m
Japanese
O'Reilly Japan, Inc.
Content preview from 機械学習デザインパターン ―データ準備、モデル構築、MLOpsの実践上の問題と解決

6章再現性のパターン

単体テストのようなベストプラクティスでは、プログラムを走らせたらいつも同じ結果が決定的に返されることを前提としています。

def sigmoid(x):
    return 1.0 / (1 + np.exp(-x))

class TestSigmoid(unittest.TestCase):
    def test_zero(self):
        self.assertAlmostEqual(sigmoid(0), 0.5)

    def test_neginf(self):
        self.assertAlmostEqual(sigmoid(float("-inf")), 0)

    def test_inf(self):
        self.assertAlmostEqual(sigmoid(float("inf")), 1)

このような実行の再現性は、機械学習を使う上では確保困難となります。訓練中、機械学習のモデルのパラメータは乱数で初期化され、訓練データによって調整されるためです。そこで例えばscikit-learnで実装された単純なk平均法のアルゴリズムでは、毎回同じ結果を返すために以下にあるようにrandom_stateの値を設定します。

def cluster_kmeans(X):
    from sklearn import cluster
    k_means = cluster.KMeans(n_clusters=10, random_state=10)
    labels = k_means.fit(X).labels_[::]
    return labels

訓練における再現性を保つためには、乱数のシードだけではなく、いろいろな管理要素の値を固定する必要があります。さらに機械学習には、訓練やデプロイ、再訓練など、さまざまな工程があります。そのため、しばしばそれらの工程をまたがって再現性を保つことが重要になります。 ...

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

プログラミング・ビットコイン ―ゼロからビットコインをプログラムする方法

プログラミング・ビットコイン ―ゼロからビットコインをプログラムする方法

Jimmy Song, 中川 卓俊, 住田 和則, 中村 昭雄, 星野 靖子
情報アーキテクチャ 第4版 ―見つけやすく理解しやすい情報設計

情報アーキテクチャ 第4版 ―見つけやすく理解しやすい情報設計

Louis Rosenfeld, Peter Morville, Jorge Arango, 篠原 稔和, 岡 真由美
行動を変えるデザイン ―心理学と行動経済学をプロダクトデザインに活用する

行動を変えるデザイン ―心理学と行動経済学をプロダクトデザインに活用する

Stephen Wendel, 武山 政直, 相島 雅樹, 反中 望, 松村 草也
戦略的データサイエンス入門 ―ビジネスに活かすコンセプトとテクニック

戦略的データサイエンス入門 ―ビジネスに活かすコンセプトとテクニック

Foster Provost, Tom Fawcett, 竹田 正和, 古畠 敦, 瀬戸山 雅人, 大木 嘉人, 藤野 賢祐, 宗定 洋平, 西谷 雅史, 砂子 一徳, 市川 正和, 佐藤 正士

Publisher Resources

ISBN: 9784873119564Other