More Related Content Similar to Oracle R Advanced Analytics for Hadoop利用方法 (20) More from オラクルエンジニア通信 (20) Oracle R Advanced Analytics for Hadoop利用方法1. Copyright © 2016 Oracle and/or its affiliates. All rights reserved. |
R言語を使ってビッグデータ分析
Oracle R Advanced Analytics for Hadoop
利用概要
2016/03/30
日本オラクル株式会社
クラウド・テクノロジー事業統括
2. Copyright © 2016 Oracle and/or its affiliates. All rights reserved. |
• 以下の事項は、弊社の一般的な製品の方向性に関する概要を説明す
るものです。また、情報提供を唯一の目的とするものであり、いか
なる契約にも組み込むことはできません。以下の事項は、マテリア
ルやコード、機能を提供することをコミットメント(確約)するも
のではないため、購買決定を行う際の判断材料になさらないで下さ
い。オラクル製品に関して記載されている機能の開発、リリースお
よび時期については、弊社の裁量により決定されます。
2
OracleとJavaは、Oracle Corporation 及びその子会社、関連会社の米国及びその他の国における登録商標です。
文中の社名、商品名等は各社の商標または登録商標である場合があります。
3. Copyright © 2016 Oracle and/or its affiliates. All rights reserved. |
本手順書の内容
本手順書は、Oracle Big Data Connectorsの機能の1つである、
Oracle R Advanced Analytics for Hadoopをご紹介し、
オラクルが学習環境として無償提供する仮想イメージ
Oracle Big Data Liteでの利用方法について解説しております。
3
4. Copyright © 2016 Oracle and/or its affiliates. All rights reserved. |
アジェンダ
1
2
Oracle R Advanced Analytics for Hadoop概要
Oracle Big Data Liteのセットアップ
Oracle R Advanced Analytics for Hadoop利用例
4
3
5. Copyright © 2016 Oracle and/or its affiliates. All rights reserved. |
Oracle R Advanced Analytics for Hadoop
概要
5
6. Copyright © 2016 Oracle and/or its affiliates. All rights reserved. |
Oracle’s Big Data Advanced Analytics Solutions
SQLのみならず、機械学習、R言語をHadoopとOracleDB上で
6
Oracle Database Server
with Advanced Analytics Option
R
Hadoop Cluster
Big Data
SQL
Oracle R Enterprise
(ORE)
R Client
SQL Developer
SQLアプリケーション
SQL Client
Oracle ExadataBig Data Appliance
SQL
R
Oracle R Advanced
Analytics for Hadoop
R Client
センサーデータ、
ログデータ、etc
マスターデータ、
トランザクションデータ、etc
7. Copyright © 2016 Oracle and/or its affiliates. All rights reserved. |
すべてのフェーズをRのインターフェースで
Oracle R Advanced Analytics for Hadoopのコンセプト → 利用者への負担小
① データの探索 ②データの収集・
加工
③モデルの作成④モデルの評価
R R
R R
7
8. Copyright © 2016 Oracle and/or its affiliates. All rights reserved. |
Oracle R Advanced Analytics for Hadoop
Hive, 並列分散処理、MapReduce:Hadoopのデータ分析全てのフェーズをRで
• RとHadoopを活用した分析のためのソフトウェア
• Oracle R Advanced Analytics for Hadoop(ORAAH)で実現する機能
1. HDFS上のデータへのR言語からのアクセス
2. Hiveを利用したデータ処理をRから透過的に利用可能
3. RからOracle提供の関数を利用し、データマイニングを分散並列処理(MapReduce、
Sparkの開発不要)
• 回帰分析、クラスタリング、主因子分析、相関分析、協調フィルタリング・・・
• MapReduceやSparkの処理を書かずともHadoopの並列分散処理の性能を享受できる
4. MapReduceをR言語で記述
5. Oracle DatabaseとHadoopの間のデータの移動をRから指示
8
9. Copyright © 2016 Oracle and/or its affiliates. All rights reserved. |
Hadoop Cluster
with Oracle R Advanced Analytics for Hadoop
Oracle R Advanced Analytics for Hadoop
Hive, 並列分散処理、MapReduce:Hadoopのデータ分析全てのフェーズをRで
R Client
HQL , Data Prep, Joins and View creation
HQL
R
1.HDFS上のデータへの
R言語からのアクセス
2.Hiveを利用したデータ加工を
Rから利用可能
3.独自関数をRで利用し、データ
分析を並列分散処理
(MapReduce,Spark開発不要)
MLP Neural Nets*, GLM*, LM, PCA,
k-Means, NMF, LMF (*Spark base)
4.MapReduceをRで記述
Open-source R packages via Map-Reduce
5.Oracle DBとHadoop間
のデータの移動をRから指示
9
10. Copyright © 2016 Oracle and/or its affiliates. All rights reserved. |
アーキテクチャ
10
Client Host (e.g., laptop)
R engine
orch
Hadoop Cluster
Software
Java VM
Server Machine (e.g., Big Data Appliance)
R engine
orch-drv package Java VM
ORE packages
Hadoop Cluster
TaskTracker
…
TaskTracker
JobTracker
MapReduce
nodes
HDFS nodes
Datanode
Datanode
…
Namenode
ORE client packagesorch
11. Copyright © 2016 Oracle and/or its affiliates. All rights reserved. |
Oracle Big Data Connectors
R分析やRDBMSとのデータ連携など、Hadoop上のデータのさらなる活用を実現
R Analytics
Oracle R Advanced
Analyticson
Hadoop
Oracle Data
Integrator
Knowledge Modules
XML/XQuery
Oracle XQuery on
Hadoop
XQueryR Client
Data Load
Oracle Loader for
Hadoop
Data Access
Oracle SQL
Connector for
HDFS
•HDFSからOracle Databaseへ高速にデータをロード
•Oracle DatabaseからHDFSへ外部表としてSQLでアクセス
•HadoopからOracle Databaseへのロード処理をGUIで作成実行
•XMLファイルの加工・分析に有効なXQueryをMap/ReduceのJobに変換、実行
•HDFS 上のデータに対する R 言語処理を実現
11
Many versions
10g Release 2
11g Release 2
12c
On any OS platform
12. Copyright © 2016 Oracle and/or its affiliates. All rights reserved. |
Oracle Big Data Liteのセットアップ
12
13. Copyright © 2016 Oracle and/or its affiliates. All rights reserved. |
Oracle Big Data Liteについて
• Oracle Big Data Lite概要
Oracleが提供しているBig Dataプラットフォームの機能確
認、教育目的でご利用いただくための仮想イメージです。
Oracle VM VirtualBox上でご利用いただくことができます。
<<Oracle Big Data Lite 4.4.0で提供するソフトウェア一覧>>
13
• Oracle Enterprise Linux 6.7
• Oracle Database 12c Release 1 Enterprise Edition
(12.1.0.2)
※含まれるDBオプション
Oracle Big Data SQL, Oracle Multitenant, Oracle Advanced
Analytics, Oracle OLAP, Oracle Partitioning, Oracle Spatial
and Graph など
• Cloudera Distribution including Apache Hadoop
(CDH5.5.1)
• Cloudera Manager (5.5.1)
• Oracle Big Data Spatial and Graph 1.1.2
• Oracle Big Data Discovery 1.1.1
• Oracle Big Data Connectors 4.4
• Oracle NoSQL Database Enterprise Edition 12cR1 (3.5.2)
• Oracle JDeveloper 12c (12.1.3)
• Oracle SQL Developer and Data Modeler 4.1.3 with Oracle
REST Data Services 3.0.3
• Oracle Data Integrator 12cR1 (12.2.1)
• Oracle GoldenGate 12cR2 (12.2.0.1)
• Oracle R Distribution 3.2.0
• Oracle Perfect Balance 2.6.0
14. Copyright © 2016 Oracle and/or its affiliates. All rights reserved. |
Oracle VM VirtualBoxのセットアップ
• Oracle VM VirtualBoxインストールファイルのダウンロード
– http://www.oracle.com/technetwork/server-
storage/virtualbox/downloads/index.html
• 上記のリンクから、次のソフトウェアのダウンロード/インストールをお願い致します。
– Oracle VM VirtualBox
– Oracle VM VirtualBox Extension Pack
以下のリンクの手順書、P15-18も参考に
http://www.oracle.com/technetwork/jp/database/enterprise-
edition/documentation/sionvbox-db12101onol6u4-2080482-ja.pdf
14
15. Copyright © 2016 Oracle and/or its affiliates. All rights reserved. |
Oracle Big Data Liteセットアップ方法
• 仮想イメージのダウンロード
– http://www.oracle.com/technetwork/database/bigdata-appliance/oracle-bigdatalite-
2104726.html
• ダウンロード後の手順
1. 「Download Oracle Big Data Lite Virtual Machine」の「Accept License Agreement」をクリック
2. 「BigDataLite440.7z.00*」を全てダウンロード
3. 「BigDataLite440.7z.001」のみを7-zipで解凍
⇒BigDataLite440.ovaというファイルが出来上がります
4. 事前にインストールした「Oracle VM VirtualBox」を起動
5. 「ファイル>>仮想アプライアンスのインポート」より、③で作成されたBigDataLite421.ovaというファイルを指定
6. インポートした仮想マシンを指定し、起動
7. 起動後、user名/passwordは、oracle/welcome1でログイン
15
16. Copyright © 2016 Oracle and/or its affiliates. All rights reserved. |
Oracle R Advanced Analytics for Hadoop
利用例
16
17. Copyright © 2016 Oracle and/or its affiliates. All rights reserved. |
ORAAH利用時の初期設定
• Terminal上で「R」コマンドを入力します
• Oracle R Advanced Analytics for Hadoop(ORAAH)に含まれるパッケージをロード
し、Hadoop上のファイルへアクセスできるようにします
• Sparkへ接続します
17
> library(ORCH)
> spark.connect("yarn-client", dfs.namenode="bigdatalite.localdmain")
18. Copyright © 2016 Oracle and/or its affiliates. All rights reserved. |
ORAAH特有コマンド
• Hadoop上でRをご利用いただくため、以下のAPIをご用意しております
18
接頭辞 用途 コマンド例
hadoop MapReduceとつなぎ合わせるコマンド hadoop.exec / hadoop.run
hdfs HDFS上ファイルとつなぎ合わせるコマンド hdfs.attach / hdfs.cd / hdfs.cp / hdfs.describe /
hdfs.download / hdfs.exists / hdfs.get / hdfs.head /
hdfs.id / hdfs.ls / hdfs.mkdir / hdfs.mv / hdfs.parts /
hdfs.pull / hdfs.push / hdfs.put / hdfs.pwd / hdfs.rm /
hdfs.rmdir / hdfs.root / hdfs.sample / hdfs.setroot /
hdfs.size / hdfs.tail / hdfs.upload
orch 透過的にMapReduceやSparkを介したアクセスが
行われる
orch.connect / orch.connected / orch.dbcon /
orch.dbg.lasterr / orch.dbg.off / orch.dbg.on /
orch.dbg.output / orch.dbinfo / orch.disconnect /
orch.dryrun / orch.evaluate / orch.export / orch.export.fit
/ orch.keyval / orch.keyvals / orch.lm / orch.lmf /
orch.neural / orch.nmf / orch.nmf.NMFalgo / orch.pack /
orch.reconnect / orch.temp.path / orch.unpack /
orch.version
ore Hive上のデータとつなぎ合わせるコマンド ore.create / ore.drop / ore.get / ore.pull / ore.push /
ore.recode
19. Copyright © 2016 Oracle and/or its affiliates. All rights reserved. |
Rを使用した分析例①
Oracle提供のパッケージを使った分析例
• HDFS上のファイルを、Rに認識させます
• 代入したファイルの列数/行数を確認します
19
> x <- hdfs.attach("/user/oracle/")
該当ファイルを含むHDFS上のディレクトリ
> hdfs.dim(x)
20. Copyright © 2016 Oracle and/or its affiliates. All rights reserved. |
Rを使用した分析例①
Oracle提供のパッケージを使った分析例
• 一般化線形モデルを利用する為の定義
• 一般化線形モデル分析
20
> form_oraah_glm2 <- CANCELLED ~ DISTANCE + ORIGIN + DEST
> m_spark_glm <- orch.glm2(formula=form_oraah_glm2, x)
一般化線形モデルの式 目的変数 説明変数
hdfs.attachコマンドで読み込んだデータ事前に定義した式
21. Copyright © 2016 Oracle and/or its affiliates. All rights reserved. |
Rを使用した分析例②
一般的なRのコマンドを利用した分析
• HDFS上のデータをR上にコピー
• データの相関関数を確認
• 線形単回帰分析
21
> car_temp <- hdfs.get("/user/oracle/cars_dfs")
> cor(car_temp$speed ,car_temp$dist)
> car.lm <- lm(dist ~ speed, data=car_temp)
該当ファイルを含むHDFS上のディレクトリ
Car_tempデータに存在する列
22. Copyright © 2016 Oracle and/or its affiliates. All rights reserved. |
Rを使用した分析例②
一般的なRのコマンドを利用した分析
• 線形単回帰分析
• 分析結果のサマリを確認
22
> car.lm <- lm(dist ~ speed, data=car_temp)
> summary(car.lm)
一般化線形モデルの式 目的変数 説明変数 R上にコピーしたデータ変数
<表示例>
Residuals:
Min 1Q Median 3Q Max
-29.069 -9.525 -2.272 9.215 43.201
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -17.5791 6.7584 -2.601 0.0123 *
speed 3.9324 0.4155 9.464 1.49e-12 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 15.38 on 48 degrees of freedom
Multiple R-squared: 0.6511, Adjusted R-squared: 0.6438
F-statistic: 89.57 on 1 and 48 DF, p-value: 1.49e-12
一般化線形モデルの式
23. Copyright © 2016 Oracle and/or its affiliates. All rights reserved. |
Rを使用した分析例②
一般的なRのコマンドを利用した分析
• 分析結果をグラフ化
23
> plot(car_temp)
> abline(car.lm, lwd=1, col="blue")
一般化線形モデルの式
24. Copyright © 2016 Oracle and/or its affiliates. All rights reserved. |
Appendix:参考資料
24
25. Copyright © 2016 Oracle and/or its affiliates. All rights reserved. |
R関連技術情報
• 製品技術情報ページ
各種技術情報、マニュアル、ホワイトペーパー、試使用ライセンス
– Oracle R Advanced Analytics for Hadoop
– Oracle R Technologies
• Oracle R Distribution
• Oracle R Enterprise
• Roracle
• Slide Share
– Oracle R Enterprise の使い方
– オラクルで実現するクラウド・マシン・ラーニング (Oracle DBA &Developers Day2016資料)
• Oracle R関連ブログ(英語)
25
26. Copyright © 2016 Oracle and/or its affiliates. All rights reserved. |
技術情報
• その他各製品技術情報ページ
– Oracle Exadata
– Oracle Big Data Appliance
– Oracle Big Data Connectors
– Oracle Advanced Analytics
– Oracle Big Data Discovery
– Oracle NoSQL Database
– Oracle Spatial &Graph
– Oracle Big Data Spatial & Graph
– Oracle Data Integration
26
27. Copyright © 2016 Oracle and/or its affiliates. All rights reserved. |
技術情報(主にHadoop関連)
• Slides Share
– Hadoopソリューション
• OracleのHadoopソリューションご紹介
• Oracle Big Data Cloud Serciveのご紹介
• 顧客事例から学んだ、 エンタープライズでの “マジな”Hadoop導入の勘所
(Hadoop Conference Japan 2016講演資料)
• 成功事例に学べ! ビッグデータ活用のための最新ベストプラクティス(Oracle Cloud Days Tokyo 2016資
料)
• クラウドを使ってビッグデータ活用を実現 (Oracle Cloud Days Tokyo 2016資料)
• ビッグデータ/IoTの最新事例とHadoop活用の勘所(Cloudera World Tokyo 2016資料)
– HadoopとDB連携ソリューション
• OracleとHadoop連携の勘所 (Oracle DBA &Developers Day2016資料)
–
27
28. Copyright © 2016 Oracle and/or its affiliates. All rights reserved. | 28
ご質問・ご相談等ございましたら、ぜひお問い合わせを
0120-155-096
(平日9:00-12:00 / 13:00-18:00)
http://www.oracle.com/jp/direct/index.html
各種無償支援サービスもございます。
Oracle Direct 検索
Oracle Direct
あなたにいちばん近いオラクル
Editor's Notes This is a Title Slide with Picture slide ideal for including a picture with a brief title, subtitle and presenter information.
To customize this slide with your own picture:
Right-click the slide area and choose Format Background from the pop-up menu. From the Fill menu, click Picture and texture fill. Under Insert from: click File. Locate your new picture and click Insert. ⑤計算量の必要な処理をHadoop側にオフロード可能