Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Polarsを活用した機械学習ジョブの高速化
Search
Yudai Hayashi
February 22, 2024
440
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Polarsを活用した機械学習ジョブの高速化
Yudai Hayashi
February 22, 2024
More Decks by Yudai Hayashi
See All by Yudai Hayashi
技術キャッチアップ効率化を実現する記事推薦システムの構築
yudai00
4
370
Off-Policy Evaluation and Learning for Matching Markets
yudai00
0
150
ジョブマッチングプラットフォームにおける推薦アルゴリズムの活用事例
yudai00
0
170
ユーザーのプロフィールデータを活用した推薦精度向上の取り組み
yudai00
0
770
MCP Clientを活用するための設計と実装上の工夫
yudai00
1
1.4k
人とシゴトのマッチングを実現するための機械学習技術
yudai00
1
120
MCPを理解する
yudai00
18
15k
データバリデーションによるFeature Storeデータ品質の担保
yudai00
1
290
「仮説行動」で学んだ、仮説を深め ていくための方法
yudai00
8
2.1k
Featured
See All Featured
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
16k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
133
19k
GraphQLの誤解/rethinking-graphql
sonatard
75
12k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
249
1.3M
GraphQLとの向き合い方2022年版
quramy
50
15k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
28
3.6k
RailsConf 2023
tenderlove
30
1.5k
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
2
420
Building the Perfect Custom Keyboard
takai
2
810
Jamie Indigo - Trashchat’s Guide to Black Boxes: Technical SEO Tactics for LLMs
techseoconnect
PRO
0
290
Collaborative Software Design: How to facilitate domain modelling decisions
baasie
1
260
Tell your own story through comics
letsgokoyo
1
990
Transcript
© 2024 Wantedly, Inc. Polarsを活用した機械学習ジョブの 高速化 みんなのPython勉強会#101 Jan. 22 2024
- Yudai Hayashi
© 2024 Wantedly, Inc. INTERNAL ONLY 自己紹介 林 悠大 • 経歴:
◦ 東京大学工学系研究科でPh.D取得 ◦ 2022年にウォンテッドリーにデータサイ エンティストとして新卒入社。推薦シス テムの開発を行う • X: @python_walker • 趣味: ◦ 読書 ◦ 音楽聴くこと ◦ ウイスキー
© 2024 Wantedly, Inc. INTERNAL ONLY ジョブを高速化するモチベーション 実験 評価 改善
機械学習のPDCAサイクル • 機械学習ジョブの実行には長い時間が かかることが多い • ジョブの待ち時間を減らしてサイクルを 高速に回したい ここではpolarsを使ってテーブルデータの処理を高速化する手法を紹介 実験設計 > 1 h
© 2024 Wantedly, Inc. INTERNAL ONLY PolarsとPandas 主にPython Rust シングルコア
マルチコア 実装 処理 データの 持ち方 行指向 列指向 インメモリ インメモリ、遅延評価 polarsはpandasと同様、テーブルデータの処理をするためのライブラリ データ型 DataFrame, Series DataFrame, Series 10万 x 100 のDataFrameどうし のinner joinにかかる時間
© 2024 Wantedly, Inc. INTERNAL ONLY 実務におけるpolarsによる高速化の効果 日付をintに変換して差を計算 欠損時には欠損を残す when構文を使って条件分岐
結果を格納するカラム名を指定 Pandas Polars • 50 min → 1 min に 実行時間が短縮 • applyが不要になった ことで改善幅が大きく なった
© 2024 Wantedly, Inc. INTERNAL ONLY 遅延評価によるさらなる高速化・メモリ節約 公式ドキュメントより “...in the
lazy API the query is only evaluated once it is 'needed'.” Eager API ここで評価される Lazy API • 評価を遅らせることで処理速度を最適化 (↑の例だと6 %高速化(10万x100の大 きさのデータ)) • 必要なデータだけを読み込むので大規模データを扱う際にも有用 上から順番に処理
© 2024 Wantedly, Inc. INTERNAL ONLY まとめ • テーブルデータの処理にPolarsを使うことで高速化する手法を紹介 •
Pandasでapplyを使う必要がある処理はPolarsによる高速化の恩恵が大 きくなる可能性 • 遅延評価によって大規模データも効率的に扱える