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
Polarsを活用した機械学習ジョブの高速化
Search
Yudai Hayashi
February 22, 2024
480
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Polarsを活用した機械学習ジョブの高速化
Yudai Hayashi
February 22, 2024
Transcript
7 slides
© 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による高速化の恩恵が大 きくなる可能性 • 遅延評価によって大規模データも効率的に扱える
More Decks by Yudai Hayashi
See All by Yudai Hayashi
技術キャッチアップ効率化を実現する記事推薦システムの構築
yudai00
4
400
Off-Policy Evaluation and Learning for Matching Markets
yudai00
0
190
ジョブマッチングプラットフォームにおける推薦アルゴリズムの活用事例
yudai00
0
260
ユーザーのプロフィールデータを活用した推薦精度向上の取り組み
yudai00
0
820
MCP Clientを活用するための設計と実装上の工夫
yudai00
1
1.4k
人とシゴトのマッチングを実現するための機械学習技術
yudai00
1
160
MCPを理解する
yudai00
18
16k
データバリデーションによるFeature Storeデータ品質の担保
yudai00
1
310
「仮説行動」で学んだ、仮説を深め ていくための方法
yudai00
8
2.1k
Featured
See All Featured
JAMstack: Web Apps at Ludicrous Speed - All Things Open 2022
reverentgeek
1
680
Lightning Talk: Beautiful Slides for Beginners
inesmontani
PRO
2
790
Effective software design: The role of men in debugging patriarchy in IT @ Voxxed Days AMS
baasie
1
610
コードの90%をAIが書く世界で何が待っているのか / What awaits us in a world where 90% of the code is written by AI
rkaga
63
48k
Conquering PDFs: document understanding beyond plain text
inesmontani
PRO
4
3.3k
The Mindset for Success: Future Career Progression
greggifford
PRO
0
560
Believing is Seeing
oripsolob
1
280
Making Projects Easy
brettharned
120
6.9k
Leadership Guide Workshop - DevTernity 2021
reverentgeek
1
430
sira's awesome portfolio website redesign presentation
elsirapls
0
500
Building Adaptive Systems
keathley
44
3.3k
The State of eCommerce SEO: How to Win in Today's Products SERPs - #SEOweek
aleyda
2
12k