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
Jupyter Notebook (jupyterhub)で ruby とグラフ / k-ruby 20th
Search
Koichi Shimozono
April 11, 2018
Programming
0
110
Jupyter Notebook (jupyterhub)で ruby とグラフ / k-ruby 20th
2018/04/11 の第20回 k-ruby の資料です。
Koichi Shimozono
April 11, 2018
Tweet
Share
More Decks by Koichi Shimozono
See All by Koichi Shimozono
CentOS 8 での Ruby 環境
simozono
0
200
Serverspecを使用したサーバ設定テストの実例 / かごもく No8
simozono
0
240
Other Decks in Programming
See All in Programming
Micro Frontends for Java Microservices - Devnexus 2024
mraible
PRO
0
490
Hanami and htmx
bkuhlmann
0
210
ONE WEDGE_company_guide
1wedge_one
0
480
SwiftUIで使いやすいToastの作り方 / How to build a Toast system which is easy to use in SwiftUI
lovee
3
150
Rubyでたのしむクリエイティブコーディング/Enjoy Creative coding with Ruby
chobishiba
1
180
try!Swift Tokyo 2024 参加報告 LT
akidon0000
1
220
Anthropic Cookbook のおすすめレシピ
schroneko
7
980
Tailwind CSSを本気でカスタマイズする方法
fsubal
13
5.3k
AWS CDKコントリビュートTIPS / aws-cdk-contribution-tips
gotok365
2
190
Code Reviews
bkuhlmann
4
890
Ruby GitHub Packages
bkuhlmann
0
630
Rethinking UI building strategies @ SFI 2024
letelete
0
270
Featured
See All Featured
Git: the NoSQL Database
bkeepers
PRO
422
63k
What the flash - Photography Introduction
edds
64
11k
Building an army of robots
kneath
300
41k
The Cult of Friendly URLs
andyhume
74
5.7k
From Idea to $5000 a Month in 5 Months
shpigford
377
45k
How GitHub (no longer) Works
holman
304
140k
Product Roadmaps are Hard
iamctodd
44
9.7k
The Brand Is Dead. Long Live the Brand.
mthomps
49
29k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
14
1.6k
The World Runs on Bad Software
bkeepers
PRO
61
6.7k
The Illustrated Children's Guide to Kubernetes
chrisshort
31
46k
No one is an island. Learnings from fostering a developers community.
thoeni
16
2.1k
Transcript
Jupyter Notebook (jupyterhub)で rubyとグラフ 鹿児島大学学術情報基盤センター 下園幸一
[email protected]
2018/04/11 第20回 K-Ruby
1
Jupyter Notebook 概説(1) ジュパイターでもジュピターでもいいみたい ◦ http://youglish.com/search/Jupyter 経緯 ◦
元々は IPython Notebook ◦ その後、Python だけでなく、Julia , Rにも対応 Julia + Python + R = Jupyter ◦ 現在は、Ruby, Haskell, Scala, node.js 等にも対応 ◦ 7つの言語の Juputer Notebook を作る https://matsubara0507.github.io/posts/2017-04-24-create- jupyter-for-seven-lang-part1.html Project Jupyter が開発元 ( http://jupyter.org ) 2018/04/11 第20回 K-Ruby 2
Jupyter Notebook概説(2)何ができるの? 一言で言うと「Web上でのPython等言語の対 話的実行環境」 ◦ http://techlife.cookpad.com/entry/write-once- share-anywhare ◦ コードと実行結果と説明文(Markdown)を同時に扱
う ◦ コードとグラフを同一画面で扱う ◦ コードの改変、再実行可能 ◦ 全てWeb(ブラウザ)上で ◦ github 等を用いて notebook を共有 データサイエンス界隈で利用者多数 ◦ python + pandas + scipy + matplotlob ◦ 語の分散表現(word2vec)関連では + gensim 2018/04/11 第20回 K-Ruby 3
Jupyter Notebook概説(3)デモ 非公開 ◦ github(gist)に notebookの本体( .ipynb)を push すると、きれいに表示してくれる
◦ GitLab(CE)でも、それなりに表示してくれる 私が構築した GitLab(CE)では、グラフが表示されない ◦ nbviewer というのを利用すると github 等を利 用しなくてもきれいに表示してくれるらしいが 使ったことない 2018/04/11 第20回 K-Ruby 4
Jupyter Notebook Architecture http://jupyter.readthedocs.io/en/latest/architecture/how_jupyter_ipyth on_work.html より 2018/04/11 第20回 K-Ruby
5
Jupyter Notebook概説(5) 導入 Anaconda で、python を含め全て入る ◦ Windows/Mac/Linux ◦
データ分析に必要な python パッケージも入る ◦ パッケージ管理もできる ◦ https://www.anaconda.com/download/ Anaconda を利用しなくても導入はできる が For new users, we highly recommend installing Anaconda. (Jupyter Documentation より) 2018/04/11 第20回 K-Ruby 6
Jupyter Notebook概説(6) 今後 Jupyter Notebook から JupyterLab に進化 ◦
2014年に Jupyter Notebook になる ◦ 2016年から次世代版 Jupyter Notebook として JupyterLab プレ ビュー公開 ◦ 2018/02 ベータ版公開 ◦ 正式版は2018年内か? 操作性向上 csv, json がきれいに表示されるらしい https://news.mynavi.jp/article/20180221-587178/ 2018/04/11 第20回 K-Ruby 7
Jupyterhub Jupyterlab-hub について Jupyter Notebook や JupyterLab は、一人で使用することを想定 ◦
サーバに導入して、複数で利用したい(教育環境等) Jupyterhub Jupyterlab-hub はユーザ認証機能を付けたもの ◦ サーバのローカルユーザ作成されていれば導入はそこそこ難しくない ◦ LDAP等の場合は… 試していないのでわからない 2018/04/11 第20回 K-Ruby 8
Jupyter Notebook で ruby 基本的には iruby という Jupyter Notebook
用 ruby kernel を導入すればよい ◦ http://devopspy.com/linux/ruby-kernel-jupyter- notebook/ ◦ https://qiita.com/kozo2/items/8e0cf0d1f5672ac 2f745 「The Ruby kernel requires ZeroMQ, hence it’s C and Ruby bindings」で、OS標準のパッ ケージとバージョンがあわないとかでさんざん 苦労したような気がするが…忘れた デモ 2018/04/11 第20回 K-Ruby 9
jupyter notebook の ruby でグラフ(1) 数種類の方法がある ◦ nyaplot
動かなかった。ここ数年メンテナンスされていない ◦ rbplotly 動く ◦ gnuplot 動く ◦ daru + numo-gnuplot 動く ◦ daru + daru-plotly 動く daru とは ◦ ruby で DataFrame を扱うもの Python の pandas みたいなもの 2018/04/11 第20回 K-Ruby 10
jupyter notebook の ruby でグラフ(2) rbploty ◦ plotly を
ruby で使うために必要 ◦ plotly データ可視化プラットフォーム (https://plot.ly/) ◦ plotly の作図方法 APIを叩くもの (plotlyのサーバと通信) 頻繁な場合は有料 plotly.js を利用する plotly.js はオープンソース化されていて無料 ◦ rbploty がどちらを使っているかは知らない どちらにも対応しているみたいだが。 2018/04/11 第20回 K-Ruby 11
jupyter notebook の ruby でグラフ(3) 2018/04/11 第20回 K-Ruby 12 require
'rbplotly' trace1 = { x: ['a',2,3,4,5,6], y: [100,200,300,400,500,600] } trace2 = { x: ['a',2,3,4,5,6], y: [600,500,400,300,200,100] } traces = [trace1, trace2] pl = Plotly::Plot.new(data: traces) pl.show これくらいのコードで、以下のグラフが描ける
jupyter notebook の ruby でグラフ(2) daru + daru-plotly を業務で使用
◦ 「eduroam利用回数」 ログから eduroam(無線LAN)のアクセス解析 面倒だった点 ◦ 2つの値と1つの値で値域が大きく異なる 2軸のグラフにしたい ◦ これを実装したいためplotly のドキュメントをよ みまくる https://plot.ly/python/ あたりの Python 用APIドキュ メントを見ながら Python での dict を ruby の Hash だと考えていろいろやった。 2018/04/11 第20回 K-Ruby 13