rabbit-slide-kou-data-science-rb 2017.5.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.rabbit +1 -0
- data/README.rd +38 -0
- data/Rakefile +17 -0
- data/config.yaml +24 -0
- data/pdf/data-science-rb-ruby-with-apache-arrow-joins-data-processing-languages.pdf +0 -0
- data/ruby-with-apache-arrow-joins-data-processing-languages.rab +444 -0
- data/sample/filter-groonga.rb +15 -0
- data/sample/read-feather.rb +10 -0
- data/sample/read-groonga.py +7 -0
- data/sample/read-pandas.rb +11 -0
- data/sample/read-parquet.rb +10 -0
- data/sample/read-tensor.rb +15 -0
- data/sample/write-feather.R +5 -0
- data/sample/write-pandas.py +14 -0
- data/sample/write-parquet.py +10 -0
- data/sample/write-tensor.py +10 -0
- metadata +90 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 6adc80216160df3aa2fcc4e681adb8adef33c9ff
|
4
|
+
data.tar.gz: 1c8032d96c9c619f40bf1789a937408da47bb597
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 677dc10e63a5bf2384757c4f679b4843fb82577c44fc2b6270df8e21b43f76a80fa8e6ca3e3c1eaf305ff0d69160cf1358701dac8e745e1f24d7dc09f32b9ff6
|
7
|
+
data.tar.gz: 431d971ef33ec8e19e5ffcb730d1fc6404e4cb1f8e09cd1cbea5d8dd0d1db09a3c0c7beef1dec1a6bf82258609bdfe46703b7d2a77f4f4036f41acd0eda63549
|
data/.rabbit
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby-with-apache-arrow-joins-data-processing-languages.rab
|
data/README.rd
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
= RubyもApache Arrowでデータ処理言語の仲間入り
|
2
|
+
|
3
|
+
Apache Arrowはデータ分析システム間でのデータ交換を効率化することを目的としたデータフォーマットです。pandasやApache SparkやRなど主要なデータ分析システムはApache Arrowの対応を進めています。近い将来、データ分析システム間でのデータ交換はApache Arrowを使う状態になるでしょう。RubyもApache Arrowに対応することで既存のデータ分析システムとデータ交換できるようになります。これで、Rubyもデータ分析システムの一部でデータ処理をできるようになります!
|
4
|
+
|
5
|
+
== ライセンス
|
6
|
+
|
7
|
+
=== スライド
|
8
|
+
|
9
|
+
CC BY-SA 4.0
|
10
|
+
|
11
|
+
原著作者名は以下の通りです。
|
12
|
+
|
13
|
+
* 須藤功平(またはKouhei Sutou)
|
14
|
+
|
15
|
+
=== プログラム
|
16
|
+
|
17
|
+
CC0(パブリックドメイン)
|
18
|
+
|
19
|
+
== 作者向け
|
20
|
+
|
21
|
+
=== 表示
|
22
|
+
|
23
|
+
rake
|
24
|
+
|
25
|
+
=== 公開
|
26
|
+
|
27
|
+
rake publish
|
28
|
+
|
29
|
+
== 閲覧者向け
|
30
|
+
|
31
|
+
=== インストール
|
32
|
+
|
33
|
+
gem install rabbit-slide-kou-data-science-rb
|
34
|
+
|
35
|
+
=== 表示
|
36
|
+
|
37
|
+
rabbit rabbit-slide-kou-data-science-rb.gem
|
38
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require "rabbit/task/slide"
|
2
|
+
|
3
|
+
# Edit ./config.yaml to customize meta data
|
4
|
+
|
5
|
+
spec = nil
|
6
|
+
Rabbit::Task::Slide.new do |task|
|
7
|
+
spec = task.spec
|
8
|
+
spec.files += Dir.glob("sample/**/*.*")
|
9
|
+
# spec.files -= Dir.glob("private/**/*.*")
|
10
|
+
spec.add_runtime_dependency("rabbit-theme-clear-code")
|
11
|
+
end
|
12
|
+
|
13
|
+
desc "Tag #{spec.version}"
|
14
|
+
task :tag do
|
15
|
+
sh("git", "tag", "-a", spec.version.to_s, "-m", "Publish #{spec.version}")
|
16
|
+
sh("git", "push", "--tags")
|
17
|
+
end
|
data/config.yaml
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
---
|
2
|
+
id: data-science-rb
|
3
|
+
base_name: ruby-with-apache-arrow-joins-data-processing-languages
|
4
|
+
tags:
|
5
|
+
- rabbit
|
6
|
+
- ruby
|
7
|
+
- arrow
|
8
|
+
- data
|
9
|
+
presentation_date: 2017-05-19
|
10
|
+
version: 2017.5.19.0
|
11
|
+
licenses:
|
12
|
+
- CC-BY-SA-4.0
|
13
|
+
slideshare_id: datasciencerb
|
14
|
+
speaker_deck_id:
|
15
|
+
ustream_id:
|
16
|
+
vimeo_id:
|
17
|
+
youtube_id:
|
18
|
+
author:
|
19
|
+
markup_language: :rd
|
20
|
+
name: Kouhei Sutou
|
21
|
+
email: kou@clear-code.com
|
22
|
+
rubygems_user: kou
|
23
|
+
slideshare_user:
|
24
|
+
speaker_deck_user:
|
Binary file
|
@@ -0,0 +1,444 @@
|
|
1
|
+
= RubyもApache Arrowで\nデータ処理言語の\n仲間入り
|
2
|
+
|
3
|
+
: author
|
4
|
+
須藤功平
|
5
|
+
: institution
|
6
|
+
クリアコード
|
7
|
+
: content-source
|
8
|
+
DataScience.rbワークショップ
|
9
|
+
: date
|
10
|
+
2017-05-19
|
11
|
+
: allotted-time
|
12
|
+
20m
|
13
|
+
: theme
|
14
|
+
clear-code
|
15
|
+
|
16
|
+
= はじめに
|
17
|
+
|
18
|
+
(('tag:center'))
|
19
|
+
(('tag:large'))
|
20
|
+
私はRubyが好きだ
|
21
|
+
|
22
|
+
(('tag:center'))
|
23
|
+
(('tag:large'))
|
24
|
+
だからデータ分析だって\n
|
25
|
+
Rubyでやりたい
|
26
|
+
|
27
|
+
(('tag:center'))
|
28
|
+
(('note:Rubyよりも向いている言語があるのはわかっているけどさー'))
|
29
|
+
|
30
|
+
= Apache Arrow
|
31
|
+
|
32
|
+
(('tag:center'))
|
33
|
+
データフォーマットの仕様
|
34
|
+
|
35
|
+
(('tag:center'))
|
36
|
+
と
|
37
|
+
|
38
|
+
(('tag:center'))
|
39
|
+
その仕様を処理する実装
|
40
|
+
|
41
|
+
= Arrow:解決したい問題
|
42
|
+
|
43
|
+
* 高いデータ交換コスト
|
44
|
+
* →低くしたい
|
45
|
+
* 重複した最適化実装
|
46
|
+
* →実装を共有したい
|
47
|
+
|
48
|
+
= Arrow:文脈
|
49
|
+
|
50
|
+
ビッグデータの分析
|
51
|
+
|
52
|
+
= ビッグデータの分析
|
53
|
+
|
54
|
+
* いろんなシステムが連携
|
55
|
+
* Java実装のもろもろとPythonとR
|
56
|
+
* システム間でデータ交換が必要
|
57
|
+
* 交換する度にシリアライズ・パース
|
58
|
+
* (('wait'))↑に結構CPUと時間を使われる…
|
59
|
+
* (('wait'))そんなのより分析処理に使いたい!
|
60
|
+
|
61
|
+
= Arrow:解決方針
|
62
|
+
|
63
|
+
コストゼロの\n
|
64
|
+
シリアライズ・\n
|
65
|
+
パース
|
66
|
+
|
67
|
+
= Arrow:コストゼロの実現
|
68
|
+
|
69
|
+
* そのまま使えるフォーマット
|
70
|
+
* 例:int8の配列→int8の値を連続配置
|
71
|
+
* 1バイトずつずらせば高速アクセス可
|
72
|
+
* Arrowのトレードオフ
|
73
|
+
* サイズ圧縮よりシリアライズゼロ
|
74
|
+
* 参考:Parquetはサイズ圧縮優先
|
75
|
+
|
76
|
+
= Arrowがある世界
|
77
|
+
|
78
|
+
* 各システムがサクサク連携
|
79
|
+
* 例:PySparkが高速化
|
80
|
+
* 理由:Py🡘Javaのデータ交換コスト減
|
81
|
+
* Java・Python・R以外も活躍
|
82
|
+
* 例:Ruby・Go・Rust・Juliaとか
|
83
|
+
* 理由:低コストでデータ交換可能
|
84
|
+
|
85
|
+
= ArrowとRuby
|
86
|
+
|
87
|
+
チャンス!
|
88
|
+
|
89
|
+
= ArrowとRubyとデータ分析
|
90
|
+
|
91
|
+
* RubyがArrowに対応
|
92
|
+
* Rubyにデータが回ってくる!
|
93
|
+
* →Rubyにもデータ分析の機会が!\n
|
94
|
+
(('note:(今はできることは少ないだろうけど…)'))
|
95
|
+
* (('wait'))次のステップ
|
96
|
+
* できることを増やしていく!
|
97
|
+
* →Rubyでもいろいろデータ分析!
|
98
|
+
|
99
|
+
= ArrowとRubyの今
|
100
|
+
|
101
|
+
* RubyでArrowを使える!
|
102
|
+
* 私が使えるようにしているから!\n
|
103
|
+
(('note:コミッターにもなった'))
|
104
|
+
* 公式リポジトリーにも入っている\n
|
105
|
+
(('note:厳密に言うと違うんだけど公式サポートだと思ってよい'))
|
106
|
+
* Rubyでデータを読み書きできる
|
107
|
+
* いくらかデータ処理もできる
|
108
|
+
|
109
|
+
= 今できること
|
110
|
+
|
111
|
+
* Python・Rとのデータ交換
|
112
|
+
* データ処理をいくらか
|
113
|
+
* Rubyの各種ライブラリー間での\n
|
114
|
+
データ交換
|
115
|
+
|
116
|
+
= Arrow:Python
|
117
|
+
|
118
|
+
# coderay python
|
119
|
+
# pandasでデータ生成→Arrow形式で書き込み
|
120
|
+
import pyarrow as pa
|
121
|
+
|
122
|
+
df = pd.DataFrame({"a": [1, 2, 3],
|
123
|
+
"b": ["hello", "world", "!"]})
|
124
|
+
record_batch = pa.RecordBatch.from_pandas(df)
|
125
|
+
|
126
|
+
with pa.OSFile("/tmp/pandas.arrow", "wb") as sink:
|
127
|
+
schema = record_batch.schema
|
128
|
+
writer = pa.RecordBatchFileWriter(sink, schema)
|
129
|
+
writer.write_batch(record_batch)
|
130
|
+
writer.close()
|
131
|
+
|
132
|
+
= Arrow:Ruby
|
133
|
+
|
134
|
+
# coderay ruby
|
135
|
+
# RubyでArrow形式のpandasのデータを読み込み
|
136
|
+
require "arrow"
|
137
|
+
|
138
|
+
Input = Arrow::MemoryMappedInputStream
|
139
|
+
Input.open("/tmp/pandas.arrow") do |input|
|
140
|
+
reader = Arrow::RecordBatchFileReader.new(input)
|
141
|
+
reader.each do |record_batch|
|
142
|
+
puts("=" * 40)
|
143
|
+
puts(record_batch)
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
= Feather:R
|
148
|
+
|
149
|
+
# coderay R
|
150
|
+
# Rでデータ生成→Feather形式で書き込み
|
151
|
+
library("feather")
|
152
|
+
|
153
|
+
df = data.frame(a=c(1, 2, 3),
|
154
|
+
b=c(1.1, 2.2, 3.3))
|
155
|
+
write_feather(df, "/tmp/dataframe.feather")
|
156
|
+
|
157
|
+
= Feather:Ruby
|
158
|
+
|
159
|
+
# coderay ruby
|
160
|
+
# RubyでFeather形式のRのデータを読み込み
|
161
|
+
require "arrow"
|
162
|
+
|
163
|
+
Input = Arrow::MemoryMappedInputStream
|
164
|
+
Input.open("/tmp/dataframe.feather") do |input|
|
165
|
+
reader = Arrow::FeatherFileReader.new(input)
|
166
|
+
reader.columns.each do |column|
|
167
|
+
puts("#{column.name}: #{column.to_a.inspect}")
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
= Parquet:Python
|
172
|
+
|
173
|
+
# coderay python
|
174
|
+
# Pythonでデータ生成→Parquet形式で書き込み
|
175
|
+
import pandas as pd
|
176
|
+
import pyarrow as pa
|
177
|
+
import pyarrow.parquet as pq
|
178
|
+
|
179
|
+
df = pd.DataFrame({"a": [1, 2, 3],
|
180
|
+
"b": ["hello", "world", "!"]})
|
181
|
+
table = pa.Table.from_pandas(df)
|
182
|
+
pq.write_table(table, "/tmp/pandas.parquet")
|
183
|
+
|
184
|
+
= Parquet:Ruby
|
185
|
+
|
186
|
+
# coderay ruby
|
187
|
+
# RubyでParquet形式のデータを読み込み
|
188
|
+
require "arrow"
|
189
|
+
require "parquet"
|
190
|
+
|
191
|
+
path = "/tmp/pandas.parquet"
|
192
|
+
reader = Parquet::ArrowFileReader.new(path)
|
193
|
+
table = reader.read_table
|
194
|
+
table.each_column do |column|
|
195
|
+
puts("#{column.name}: #{column.to_a.inspect}")
|
196
|
+
end
|
197
|
+
|
198
|
+
= 対応データ形式まとめ
|
199
|
+
|
200
|
+
* Arrow形式
|
201
|
+
* 各種言語(('note:(これから広く使われているはず)'))
|
202
|
+
* Feather形式
|
203
|
+
* Python・R専用
|
204
|
+
* Parquet形式
|
205
|
+
* 各種言語(('note:(Hadoop界隈ですでに広く使われている)'))
|
206
|
+
|
207
|
+
= データ処理例
|
208
|
+
|
209
|
+
* Groongaでフィルター
|
210
|
+
* Groonga
|
211
|
+
* 全文検索エンジン
|
212
|
+
* カラムストアなので集計処理も得意
|
213
|
+
* Apache Arrow対応
|
214
|
+
* よくできたRubyバインディングあり
|
215
|
+
|
216
|
+
= Groonga:Ruby
|
217
|
+
|
218
|
+
# coderay ruby
|
219
|
+
# 空のテーブルにArrow形式のデータを読み込む
|
220
|
+
logs = Groonga::Array.create(name: "logs")
|
221
|
+
logs.load_arrow("/tmp/pandas.arrow")
|
222
|
+
logs.each {|record| p record.attributes}
|
223
|
+
# フィルター
|
224
|
+
filtered_logs = logs.select do |record|
|
225
|
+
record.b =~ "hello" # "hello"で全文検索
|
226
|
+
end
|
227
|
+
# フィルター結果をArrow形式で書き込み
|
228
|
+
filtered_logs.dump_arrow("/tmp/filtered.arrow",
|
229
|
+
column_names: ["a", "b"])
|
230
|
+
|
231
|
+
= Groonga:Python
|
232
|
+
|
233
|
+
# coderay python
|
234
|
+
# Arrow形式のGroongaでのフィルター結果を読み込む
|
235
|
+
import pyarrow as pa
|
236
|
+
|
237
|
+
with pa.OSFile("/tmp/filtered.arrow") as source:
|
238
|
+
writer = pa.RecordBatchFileReader(source)
|
239
|
+
print(writer.get_record_batch(0).to_pandas())
|
240
|
+
|
241
|
+
= Rubyでデータ処理(現状)
|
242
|
+
|
243
|
+
* 既存のCライブラリーを活用
|
244
|
+
* 速度がでるし機能もある
|
245
|
+
* CライブラリーをArrowに対応
|
246
|
+
* Arrow→Ruby→Cライブラリー\n
|
247
|
+
↑から↓で高速化(('note:(オブジェクト生成は遅い)'))
|
248
|
+
* Arrow→Cライブラリー
|
249
|
+
|
250
|
+
= Rubyでデータ処理(案)
|
251
|
+
|
252
|
+
* Fluentdとか速くなりそう
|
253
|
+
* 途中でメッセージを参照しないなら
|
254
|
+
* MessagePackからArrowに変える
|
255
|
+
* Arrowのまま出力先へ送る
|
256
|
+
* 途中でRubyオブジェクトができない\n
|
257
|
+
(('note:シリアライズ・パースがなくなって速い!'))
|
258
|
+
|
259
|
+
= 多次元配列
|
260
|
+
|
261
|
+
* Arrowではオプション機能
|
262
|
+
* テンソルと呼んでいる\n
|
263
|
+
(('note:(traditional multidimensional array objectと説明)'))
|
264
|
+
* C++実装ではサポート
|
265
|
+
* バインディングでは使える
|
266
|
+
* Python・Ruby…では使える
|
267
|
+
|
268
|
+
= Tensor:Python
|
269
|
+
|
270
|
+
# coderay python
|
271
|
+
# NumPyでデータ生成→書き込み
|
272
|
+
import pyarrow as pa
|
273
|
+
import numpy as np
|
274
|
+
|
275
|
+
ndarray = np.random.randn(10, 6) # 10x6
|
276
|
+
print(ndarray)
|
277
|
+
tensor = pa.Tensor.from_numpy(ndarray)
|
278
|
+
with pa.OSFile("/tmp/tensor.arrow", "wb") as sink:
|
279
|
+
pa.write_tensor(tensor, sink)
|
280
|
+
|
281
|
+
= Tensor:Ruby
|
282
|
+
|
283
|
+
# coderay ruby
|
284
|
+
# Rubyで読み込み
|
285
|
+
require "arrow"
|
286
|
+
|
287
|
+
Input = Arrow::MemoryMappedInputStream
|
288
|
+
Input.open("/tmp/tensor.arrow") do |input|
|
289
|
+
tensor = input.read_tensor(0)
|
290
|
+
p tensor.shape # => [10, 6]
|
291
|
+
end
|
292
|
+
|
293
|
+
= Ruby:GSL
|
294
|
+
|
295
|
+
# coderay ruby
|
296
|
+
# GSLオブジェクトに変換
|
297
|
+
require "arrow"
|
298
|
+
require "arrow-gsl"
|
299
|
+
require "pp"
|
300
|
+
|
301
|
+
Input = Arrow::MemoryMappedInputStream
|
302
|
+
Input.open("/tmp/tensor.arrow") do |input|
|
303
|
+
tensor = input.read_tensor(0)
|
304
|
+
pp tensor.to_gsl
|
305
|
+
# tensor.to_gsl.to_arrow == tensor
|
306
|
+
end
|
307
|
+
|
308
|
+
= Ruby:NMatrix
|
309
|
+
|
310
|
+
# coderay ruby
|
311
|
+
# NMatrixオブジェクトに変換
|
312
|
+
require "arrow"
|
313
|
+
require "arrow-nmatrix"
|
314
|
+
require "pp"
|
315
|
+
|
316
|
+
Input = Arrow::MemoryMappedInputStream
|
317
|
+
Input.open("/tmp/tensor.arrow") do |input|
|
318
|
+
tensor = input.read_tensor(0)
|
319
|
+
pp tensor.to_nmatrix
|
320
|
+
# tensor.to_nmatrix.to_arrow == tensor
|
321
|
+
end
|
322
|
+
|
323
|
+
= Ruby:Numo::NArray
|
324
|
+
|
325
|
+
# coderay ruby
|
326
|
+
# Numo::NArrayオブジェクトに変換
|
327
|
+
require "arrow"
|
328
|
+
require "arrow-numo-narray"
|
329
|
+
require "pp"
|
330
|
+
|
331
|
+
Input = Arrow::MemoryMappedInputStream
|
332
|
+
Input.open("/tmp/tensor.arrow") do |input|
|
333
|
+
tensor = input.read_tensor(0)
|
334
|
+
pp tensor.to_narray
|
335
|
+
# tensor.to_narray.to_arrow == tensor
|
336
|
+
end
|
337
|
+
|
338
|
+
= ここまでのまとめ1
|
339
|
+
|
340
|
+
* Arrowが実現したい世界
|
341
|
+
* データ交換コストが低い世界
|
342
|
+
* 最適化実装を共有している世界
|
343
|
+
|
344
|
+
= ここまでのまとめ2
|
345
|
+
|
346
|
+
* RubyとArrowの今
|
347
|
+
* ArrowはRubyを公式サポート!
|
348
|
+
* Rubyの外の世界とデータ交換可能\n
|
349
|
+
(('note:(Arrow・Feather・Parquetをサポート)'))
|
350
|
+
* Rubyの各種ライブラリーとの\n
|
351
|
+
相互変換が可能\n
|
352
|
+
(('note:(メモリーコピーぐらいのコストで)'))
|
353
|
+
|
354
|
+
= ArrowとRubyとこれから
|
355
|
+
|
356
|
+
* Arrow
|
357
|
+
* データフレーム処理の最適化実装
|
358
|
+
* マルチコア・GPU対応
|
359
|
+
* Ruby
|
360
|
+
* Red Data Toolsプロジェクト
|
361
|
+
|
362
|
+
= Red Data Tools
|
363
|
+
|
364
|
+
* Rubyでデータ処理したいなぁ!\n
|
365
|
+
の実現を目指すプロジェクト
|
366
|
+
* URL:
|
367
|
+
* https://github.io/red-data-tools
|
368
|
+
* https://red-data-tools.github.io
|
369
|
+
* https://gitter.im/red-data-tools
|
370
|
+
|
371
|
+
= 既存プロダクト
|
372
|
+
|
373
|
+
* Red Arrow(('note:(ArrowのRubyバインディング)'))
|
374
|
+
* Red Arrow XXX(('note:(ArrowとXXXの相互変換)'))
|
375
|
+
* Parquet GLib(('note:(ParquetのGLibバインディング)'))
|
376
|
+
* Red Parquet(('note:(ParquetのRubyバインディング)'))
|
377
|
+
* Jekyll Jupyter Notebook plugin(('note:(JekyllでJupyter Notebookを表示)'))
|
378
|
+
|
379
|
+
= ポリシー1
|
380
|
+
|
381
|
+
(('tag:center'))
|
382
|
+
Collaborate\n
|
383
|
+
over Ruby communities
|
384
|
+
|
385
|
+
(('tag:center'))
|
386
|
+
(('note:Ruby以外の人たちとも言語を超えて協力する'))\n
|
387
|
+
(('note:Apache Arrowがやっていることはまさにそう'))\n
|
388
|
+
(('note:もちろんRubyの人たちとも協力する'))
|
389
|
+
|
390
|
+
= ポリシー2
|
391
|
+
|
392
|
+
(('tag:center'))
|
393
|
+
Acting than blaming
|
394
|
+
|
395
|
+
(('tag:center'))
|
396
|
+
(('note:時間は嘆き・非難より手を動かすことに使う'))
|
397
|
+
|
398
|
+
= ポリシー3
|
399
|
+
|
400
|
+
(('tag:center'))
|
401
|
+
Continuous small works than\n
|
402
|
+
a temporary big work
|
403
|
+
|
404
|
+
(('tag:center'))
|
405
|
+
(('note:一時的にガッとやって終わりより'))\n
|
406
|
+
(('note:小さくても継続して活動する'))
|
407
|
+
|
408
|
+
= ポリシー4
|
409
|
+
|
410
|
+
(('tag:center'))
|
411
|
+
The current\n
|
412
|
+
lack of knowledge\n
|
413
|
+
isn't matter
|
414
|
+
|
415
|
+
(('tag:center'))
|
416
|
+
(('note:現時点で数学や統計学などの知識が足りなくても問題ない'))\n
|
417
|
+
(('note:既存の実装を使ったりそこから学んだりできるから'))
|
418
|
+
|
419
|
+
= ポリシー5
|
420
|
+
|
421
|
+
(('tag:center'))
|
422
|
+
Ignore blames from outsiders
|
423
|
+
|
424
|
+
(('tag:center'))
|
425
|
+
(('note:部外者の非難は気にしない'))\n
|
426
|
+
(('note:結果がでるまでグチグチ言われるはず :p'))
|
427
|
+
|
428
|
+
= ポリシー6
|
429
|
+
|
430
|
+
(('tag:center'))
|
431
|
+
Fun!\n
|
432
|
+
Because we use Ruby!
|
433
|
+
|
434
|
+
(('tag:center'))
|
435
|
+
(('note:Rubyを使うんだし楽しくやろう!'))
|
436
|
+
|
437
|
+
= Join us!
|
438
|
+
|
439
|
+
* Rubyでデータ処理したい人!
|
440
|
+
* ポリシーに同意できる人!
|
441
|
+
* URL:
|
442
|
+
* https://github.io/red-data-tools
|
443
|
+
* https://red-data-tools.github.io
|
444
|
+
* https://gitter.im/red-data-tools
|
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "rroonga"
|
4
|
+
|
5
|
+
Groonga::Database.create(path: "/tmp/db")
|
6
|
+
logs = Groonga::Array.create(name: "logs")
|
7
|
+
logs.load_arrow("/tmp/pandas.arrow")
|
8
|
+
logs.each do |record|
|
9
|
+
p record.attributes
|
10
|
+
end
|
11
|
+
filtered_logs = logs.select do |record|
|
12
|
+
record.b =~ "hello"
|
13
|
+
end
|
14
|
+
filtered_logs.dump_arrow("/tmp/filtered.arrow",
|
15
|
+
column_names: ["a", "b"])
|
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "arrow"
|
4
|
+
require "arrow-numo-narray"
|
5
|
+
require "arrow-nmatrix"
|
6
|
+
require "arrow-gsl"
|
7
|
+
|
8
|
+
require "pp"
|
9
|
+
|
10
|
+
Arrow::MemoryMappedInputStream.open("/tmp/tensor.arrow") do |input|
|
11
|
+
tensor = input.read_tensor(0)
|
12
|
+
pp tensor.to_narray
|
13
|
+
pp tensor.to_nmatrix
|
14
|
+
pp tensor.to_gsl
|
15
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env python
|
2
|
+
|
3
|
+
import pandas as pd
|
4
|
+
import pyarrow as pa
|
5
|
+
|
6
|
+
df = pd.DataFrame({"a": [1, 2, 3],
|
7
|
+
"b": ["hello", "world", "!"]})
|
8
|
+
record_batch = pa.RecordBatch.from_pandas(df)
|
9
|
+
|
10
|
+
with pa.OSFile("/tmp/pandas.arrow", "wb") as sink:
|
11
|
+
schema = record_batch.schema
|
12
|
+
writer = pa.RecordBatchFileWriter(sink, schema)
|
13
|
+
writer.write_batch(record_batch)
|
14
|
+
writer.close()
|
metadata
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rabbit-slide-kou-data-science-rb
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 2017.5.19.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Kouhei Sutou
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-05-17 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rabbit
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 2.0.2
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 2.0.2
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rabbit-theme-clear-code
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: Apache Arrowはデータ分析システム間でのデータ交換を効率化することを目的としたデータフォーマットです。pandasやApache
|
42
|
+
SparkやRなど主要なデータ分析システムはApache Arrowの対応を進めています。近い将来、データ分析システム間でのデータ交換はApache Arrowを使う状態になるでしょう。RubyもApache
|
43
|
+
Arrowに対応することで既存のデータ分析システムとデータ交換できるようになります。これで、Rubyもデータ分析システムの一部でデータ処理をできるようになります!
|
44
|
+
email:
|
45
|
+
- kou@clear-code.com
|
46
|
+
executables: []
|
47
|
+
extensions: []
|
48
|
+
extra_rdoc_files: []
|
49
|
+
files:
|
50
|
+
- ".rabbit"
|
51
|
+
- README.rd
|
52
|
+
- Rakefile
|
53
|
+
- config.yaml
|
54
|
+
- pdf/data-science-rb-ruby-with-apache-arrow-joins-data-processing-languages.pdf
|
55
|
+
- ruby-with-apache-arrow-joins-data-processing-languages.rab
|
56
|
+
- sample/filter-groonga.rb
|
57
|
+
- sample/read-feather.rb
|
58
|
+
- sample/read-groonga.py
|
59
|
+
- sample/read-pandas.rb
|
60
|
+
- sample/read-parquet.rb
|
61
|
+
- sample/read-tensor.rb
|
62
|
+
- sample/write-feather.R
|
63
|
+
- sample/write-pandas.py
|
64
|
+
- sample/write-parquet.py
|
65
|
+
- sample/write-tensor.py
|
66
|
+
homepage: http://slide.rabbit-shocker.org/authors/kou/data-science-rb/
|
67
|
+
licenses:
|
68
|
+
- CC-BY-SA-4.0
|
69
|
+
metadata: {}
|
70
|
+
post_install_message:
|
71
|
+
rdoc_options: []
|
72
|
+
require_paths:
|
73
|
+
- lib
|
74
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
75
|
+
requirements:
|
76
|
+
- - ">="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
79
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
84
|
+
requirements: []
|
85
|
+
rubyforge_project:
|
86
|
+
rubygems_version: 2.5.2
|
87
|
+
signing_key:
|
88
|
+
specification_version: 4
|
89
|
+
summary: RubyもApache Arrowでデータ処理言語の仲間入り
|
90
|
+
test_files: []
|