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
PredictionIOのPython対応計画
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Shinsuke Sugaya
July 03, 2017
Technology
4.2k
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
PredictionIOのPython対応計画
PredictionIOでPythonをどのように利用できるようにするかを説明します。
Shinsuke Sugaya
July 03, 2017
Transcript
27 slides
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
More Decks by Shinsuke Sugaya
See All by Shinsuke Sugaya
FessのAI検索モード:検索システムとLLMへの取り組み
marevol
0
1.5k
社内ドキュメント検索システム構築のノウハウ
marevol
0
470
LastaFluteでKotlinをはじめよう
marevol
0
500
日本最大級の求人検索エンジン「スタンバイ」を支える技術
marevol
2
1.1k
Fess/Elasticsearchを使った業務で使える?全文検索への道
marevol
0
1.3k
PredictionIO構築入門
marevol
0
4.3k
全文検索システムFessを用いた 検索システム構築入門
marevol
0
3.2k
ESFluteによるElasticsearchでのO/Rマッパーを用いた開発
marevol
0
360
Elasticsearchベースの全文検索システムFess
marevol
0
310
Other Decks in Technology
See All in Technology
[関西Kaggler会 20261113] 続・コミュニティコンペのススメ
nejumi
0
150
こんなに変わった! AWSネットワークの常識
shotashiratori
16
11k
人の努力に頼らないセキュリティをエンジニアリングする在り方 / An approach to engineering security that does not rely on human effort
carta_engineering
0
230
AI-Ready なデータ基盤ってなに? & 新卒未経験が、いま考えていること
imuta
0
1k
Oracle Base Database Service 技術詳細
oracle4engineer
PRO
17
120k
Kansai WordPress Meetup@大阪『ブロックテーマを作る上で知っておくべきこと
torounit
0
260
お風呂場をサーバルームにしよう
yusuke427
0
370
Context parameters で作る!はじめての型クラス
kworkdev
PRO
1
160
Linuxネットワークスタック進化の軌跡: 過去10年の歩みと最新トレンド
orimanabu
4
770
LLM 基盤と kagent v0 を全部 k8s に入れてみた / Deploy both LLM and kagent v0 in k8s
kota2and3kan
0
240
常時稼働エージェントの作り方(Claude公式ブログを資料化)
minorun365
PRO
17
28k
MCPでネットワーク障害調査を自動化する前に直すべき3つのこと
yama3133
1
640
Featured
See All Featured
Applied NLP in the Age of Generative AI
inesmontani
PRO
4
2.6k
Chasing Engaging Ingredients in Design
codingconduct
0
400
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
1
310
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
1
310
Leading Effective Engineering Teams in the AI Era
addyosmani
9
2.9k
The Director’s Chair: Orchestrating AI for Truly Effective Learning
tmiket
1
360
What's in a price? How to price your products and services
michaelherold
247
13k
技術選定の審美眼(2025年版) / Understanding the Spiral of Technologies 2025 edition
twada
PRO
121
130k
My Coaching Mixtape
mlcsv
0
390
Building Adaptive Systems
keathley
44
3.3k
Claude Code のすすめ
schroneko
67
230k
Rebuilding a faster, lazier Slack
samanthasiow
85
9.8k