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
420
1
Share
Polarsを活用した機械学習ジョブの高速化
Yudai Hayashi
February 22, 2024
More Decks by Yudai Hayashi
See All by Yudai Hayashi
技術キャッチアップ効率化を実現する記事推薦システムの構築
yudai00
4
350
Off-Policy Evaluation and Learning for Matching Markets
yudai00
0
130
ジョブマッチングプラットフォームにおける推薦アルゴリズムの活用事例
yudai00
0
130
ユーザーのプロフィールデータを活用した推薦精度向上の取り組み
yudai00
0
730
MCP Clientを活用するための設計と実装上の工夫
yudai00
1
1.3k
人とシゴトのマッチングを実現するための機械学習技術
yudai00
1
110
MCPを理解する
yudai00
18
15k
データバリデーションによるFeature Storeデータ品質の担保
yudai00
1
270
「仮説行動」で学んだ、仮説を深め ていくための方法
yudai00
8
2k
Featured
See All Featured
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.7k
Future Trends and Review - Lecture 12 - Web Technologies (1019888BNR)
signer
PRO
0
3.5k
A better future with KSS
kneath
240
18k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
What's in a price? How to price your products and services
michaelherold
247
13k
The SEO Collaboration Effect
kristinabergwall1
1
430
Leveraging LLMs for student feedback in introductory data science courses - posit::conf(2025)
minecr
1
240
Git: the NoSQL Database
bkeepers
PRO
432
67k
Embracing the Ebb and Flow
colly
88
5k
The Art of Programming - Codeland 2020
erikaheidi
57
14k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
35
3.4k
Producing Creativity
orderedlist
PRO
348
40k
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による高速化の恩恵が大 きくなる可能性 • 遅延評価によって大規模データも効率的に扱える