Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Unit testしてますか?
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
tsho
July 12, 2023
Programming
700
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Unit testしてますか?
2023/7/12 MLOps 勉強会 LT 発表
tsho
July 12, 2023
More Decks by tsho
See All by tsho
20260930_Gemma4_Hands-on
tsho
0
110
Benchmarking Vector Databases: pgvector vs. LanceDB
tsho
0
170
Google IO 2026で進化をとげた Google AI Studio
tsho
0
31
20260321_エンベディングってなに?RAGってなに?エンベディングの説明とGemini Embedding 2 の紹介
tsho
0
280
AI Agentにおける評価指標とAgent GPA
tsho
1
570
Scale SciPy with jax.shard_map - jax.shard_mapで SciPy をスケール
tsho
0
170
Developer Advocate / Community Managerなるには?
tsho
0
880
25/04/12 - Build with AI Hands-on Appendix
tsho
1
110
Other Decks in Programming
See All in Programming
難しいけど、読めた。- OSSの入口に立った話。
sts11142
0
130
速く作れる。その次は、速く確かめられる開発へ 〜AIネイティブ開発を支える、Shift Down〜 / Can build fast. Next, moving to development where we can verify fast.
rkaga
7
5.1k
半永久的に提供し続けられるプライベートクラウドを目指して ― 利用者の認知負荷を抑えるAPI抽象化とハードウェア世代交代の基盤設計
tomokon
0
270
一人だけ、Kiroが静止する日
hideg
0
140
コードレビューのボトルネックを"する側"と"される側"の両面から解消する
yub0n
1
550
スマート反転とウェブアクセシビリティ
camiha
0
220
iOSDCのペンライトを自動制御したい!
akkeylab
0
140
AI時代のコードレビューは人に向けるな、仕組みに向けろ
texmeijin
5
2.6k
AGENTS.md Is Not Enough:Build Skills, Don't Download Them
lx_t
0
130
動作中のプログラムの中身をリアルタイムに覗く / Realtime Debugger for CSharp with Roslyn
prota
1
1.6k
AHC070解法紹介
eijirou
0
140
UPDATE をやめる — EF Core でマスタをバージョン管理する
panda728
PRO
0
980
Featured
See All Featured
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
50
10k
More Than Pixels: Becoming A User Experience Designer
marktimemedia
3
540
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
1
340
Navigating the moral maze — ethical principles for Al-driven product design
skipperchong
2
590
Balancing Empowerment & Direction
lara
6
1.3k
Navigating Weather and Climate Data
rabernat
0
540
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
203
76k
技術選定の審美眼(2025年版) / Understanding the Spiral of Technologies 2025 edition
twada
PRO
120
120k
Crafting Experiences
bethany
1
360
Making Projects Easy
brettharned
120
6.8k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
16
2.2k
Transcript
Unit testしてますか?
自己紹介 名前:tsho (Sho Tanaka) 都内の IT 会社で日本や APAC を中心に ML
のコンサル タントやソリューションを提供。MLOps 勉強会の運営の1 人。 本発表は所属する組織とは関係なく、 個人の見解と調べたことを発表いたします。
話すこと & 対象 初心者 中級者 上級者 データサイエンティスト ◯ ◯ ✕
MLエンジニア/ ソフトウェアエンジニア ◯ △ ✕ エンジニア中級者などは退屈かもしれません。 最近 Python で unittest 書き始めた人の簡単な紹介 (Rspec で test 書い たことあるマン) 最新の話とかではない古くからある話をします。
なんでこの話をするのか? テストの話が本勉強会で少ないな 懇親会とかで話していてテストの話を知らない人が意外といるかな と思ったから
ML Systemsにおけるテスト Figure 1. Elements for ML systems. Adapted from
Hidden Technical Debt in Machine Learning Systems. https://cloud.google.com/architecture/mlops-continuous-delivery-and-automation-pipelines-in-machine-learning
テストのおおまかな種類 継続的にモデルを作り、デプロイしてビジネスに使うためにもテストは必要 大まかなテストの種類 - 単体テスト(Unit test) - 結合テスト(統合テスト) - E2Eテスト
*テストの分け方は人や定義によって多少ことなることが多いです。今回は分け方の議論はしないのでここでこれ以上の話はい たしません
単体テスト(Unit Test) クラスや関数などのプログラムの単位ごとにテストのこと ML systemでいうと - 前処理 - モデリング -
予測 など 上記部分で機能テストをすることに該当します。 テストの種類と技法 - Qiita
Python における Unit Test 標準 library に unittest が入っている -
Pytest など 3rd party の library もありますがここでは触れません。 • Test 用の Python ファイルを作る • Test の関数は ‘test_’ で始める 参考 https://docs.python.org/ja/3/library/unittest.html
〜 〜 実際の例(githubのコードより) 参考 https://github.com/google/gps_building_blocks/blob/master/py/gps_building_blocks/ml/preprocessing/vif_test.py
数ヶ月実施してみて 世間で言われているとおり導入コストは高い ただ、コードが増えていくにつれ、Unite testがあるときにありがたみを感じる(ないとつ らい....)。 テストするためにコードをまとめる癖がつくので可読性もあがる(気がしている)。
補足 同じデータでも必ずしもアウトプットが一致する場合でないケースがあります。 例:モデルの byte データが変わる etc. そういった場合は、mock などを使って、該当の関数、method が呼び出されたか確認 することもできます。
もちろんアウトプットの確認よりゆるいテストになるので、アウトプットの確認ができるなら されたほうがよいと思います。
さいごに MLに限らず、大規模なプロダクトや改善が多いプロダクトで品質を保証するためにUnit testは重要です。 しかし、実装コストは高いのですべての人に薦めるやり方ではありません。 もし興味があれば、すでにつかっているライブラリの単体テストに使えるメソッドなどを確 認して使うのをおすすめします(例、pandas や numpy などの assert
など)。
参考 第21回 MLOps 勉強会 普通のプロダクトのテストと機械学習を含んだプロダクトのテス トの違い Python pandas テストの書き方についてメモ -
c-bata web