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
PredictionIOのPython対応計画
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Shinsuke Sugaya
July 03, 2017
Technology
4.2k
0
Share
PredictionIOのPython対応計画
PredictionIOでPythonをどのように利用できるようにするかを説明します。
Shinsuke Sugaya
July 03, 2017
More Decks by Shinsuke Sugaya
See All by Shinsuke Sugaya
FessのAI検索モード:検索システムとLLMへの取り組み
marevol
0
100
社内ドキュメント検索システム構築のノウハウ
marevol
0
430
LastaFluteでKotlinをはじめよう
marevol
0
470
日本最大級の求人検索エンジン「スタンバイ」を支える技術
marevol
2
1k
Fess/Elasticsearchを使った業務で使える?全文検索への道
marevol
0
1.3k
PredictionIO構築入門
marevol
0
4.3k
全文検索システムFessを用いた 検索システム構築入門
marevol
0
3k
ESFluteによるElasticsearchでのO/Rマッパーを用いた開発
marevol
0
300
Elasticsearchベースの全文検索システムFess
marevol
0
270
Other Decks in Technology
See All in Technology
バイブコーディングで3倍早く⚪⚪を作ってみた
samakada
0
190
[最強DB講義]推薦システム | 評価編
recsyslab
PRO
0
110
AzureのIaC管理からログ調査まで、随所に役立つSkillsとCustom-Instructions / Boosting IaC and Log Analysis with Skills
aeonpeople
0
280
運用システムにおけるデータ活用とPlatform
sansantech
PRO
0
140
Hacobu Tech Deck
hacobu
PRO
0
130
AndroidアプリとCopilot Studioの統合
nakasho
0
170
需要創出(Chatwork)×供給(BPaaS) フライホイールとMoat 実行能力の最適配置とAI戦略
kubell_hr
0
1.1k
PyCon JPに学ぶ『決め方の決め方』: TechLead Conference 2026
terapyon
1
100
データ定義の混乱と戦う 〜 管理会計と財務会計 〜
wonohe
0
150
Keeping Ruby Running on Cygwin
fd0
0
180
COBOL婆さんの伝説
poropinai1966
0
110
20260428_Product Management Summit_Loglass_JoeHirose
loglassjoe
3
4.1k
Featured
See All Featured
Leading Effective Engineering Teams in the AI Era
addyosmani
9
1.9k
Joys of Absence: A Defence of Solitary Play
codingconduct
1
350
Facilitating Awesome Meetings
lara
57
6.8k
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.7k
Bridging the Design Gap: How Collaborative Modelling removes blockers to flow between stakeholders and teams @FastFlow conf
baasie
0
520
Making the Leap to Tech Lead
cromwellryan
135
9.8k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
Everyday Curiosity
cassininazir
0
200
Why Mistakes Are the Best Teachers: Turning Failure into a Pathway for Growth
auna
0
120
Why You Should Never Use an ORM
jnunemaker
PRO
61
9.8k
BBQ
matthewcrist
89
10k
Raft: Consensus for Rubyists
vanstee
141
7.4k
Transcript
Apache BizReach, Inc. Shinsuke Sugaya PredictionIO勉強会 第2回 Python対応計画
自己紹介 名前:菅谷 信介 会社:株式会社ビズリーチ AI室 興味があること: ・機械学習やDeep Learning等で解決方法を考える ・オープンソースのプロダクトを作る
Topics ・PredictionIOのPython対応を考える
PredictionIOの Python対応状況
Pythonを使えません…
がしかし… ・Pythonの機械学習系ライブラリは多い →scikit-learn, TensorFlow, Chainer,... ・Jupyterとかで分析したい →matplotlibで普通にグラフを書きたい この手のニーズは普通にあるのでは?
どう実現するか? PredictionIOは主に以下の機能がある ・イベントサーバ →RESTでデータを登録するので、Python対応不要 ・学習処理 →Spark上で動くので、Python対応必要 ・予測サーバ →Spark MLであれば、対応不要 →scikit-learnなどのモデルを作った場合は要対応
対応する箇所 ・学習処理 →PySparkを使えるようにする ・予測サーバ →Python独自のモデルへの対応 →(学習処理対応後に考える…)
PySpark
PySparkとは ・Sparkを実行するためのPython API ・pysparkを実行するとインタラクティブモードで起動 $ ./bin/pyspark Welcome to ____ __
/ __/__ ___ _____/ /__ _\ \/ _ \/ _ `/ __/ '_/ /__ / .__/\_,_/_/ /_/\_\ version 2.1.1 /_/ Using Python version 3.5.2 (default, Oct 31 2016 16:46:00) SparkSession available as 'spark'. >>>
PySparkとは ・Jupyter上でも実行できる!
PySparkの仕組み (ざっくりと…) pyspark spark-submit spark-class $ ./bin/pyspark ____ __ /
__/__ ___ _____/ /__ _\ \/ _ \/ _ `/ __/ '_/ /__ / .__/\_,_/_/ /_/\_\ version 2.1.1 /_/ >>> PYTHONSTARTUPを 指定してpythonを実行 Pythonを実行する コマンド引数を返却 Py4Jのサーバを起動 Sparkとの連携は Py4Jで行う
PIOとPySpark
前提 ・データはイベントサーバ上にある →RDDやDataFrameはPEventStoreから取る ・実行しているテンプレートの情報が必要 →pioコマンド経由で実行する
PIOでの仕組み pio pyspark pio-class $ ./bin/pyspark ____ __ / __/__
___ _____/ /__ _\ \/ _ \/ _ `/ __/ '_/ /__ / .__/\_,_/_/ /_/\_\ version 2.1.1 /_/ >>> pysparkを実行する コマンド引数を返却 pyspark spark-submit spark-class
開発 ・以下のブランチで開発を始めました https://github.com/jpioug/incubator-predictionio/tree/pyspark ・将来的にはApacheに入れる予定
課題 作業を始めると様々な壁に遭遇… ・Python上ではSpark上のPy4Jの参照 →pysparkは参照をラップして使いやすくしてる ・Python-Py4J-Java-Scalaでのアクセスが必要 →Pythonからアクセスしにくい ・PIOは主にRDDを使っている →DataFrameでない不便
これらの壁を乗り越えて pio pysparkを実行 $ export PYSPARK_PYTHON=$PYENV_ROOT/shims/python $ export PYSPARK_DRIVER_PYTHON=$PYENV_ROOT/shims/jupyter $
export PYSPARK_DRIVER_PYTHON_OPTS="notebook" $ ./bin/pio pyspark せっかくなので、Jupyterで実行する
動作確認 pysparkが読み込まれていればSparkContextがいる
便利関数作成 Scalaへアクセスする便利関数が必要
便利関数作成 PIOへアクセスする 便利関数が必要
PIOの初期化 pio trainの処理と同じように実行して初期化
DataFrameの取得 Spark側でDataFrameを作成して Python側ではpysparkのDataFrameでラップする
DataFrameでの表示 show()で内容を表示する
SQLでの表示 Viewを作成して、Spark SQLで取得
今後 ・コードを整理して、Apacheに入れたい ・予測サーバでの対応を考える ・続きはPIO勉強会#3で…
Apache Thank You