Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
Oracle	Advanced	Analytics
Oracle	R	Enterpriseのセットアップ
~ データベースで大量データ分析をするために ~
日本オラクル株式会社
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		| 2
Safe Harbor Statement
以下の事項は、弊社の一般的な製品の方向性に関する概要を説明するものです。また、
情報提供を唯一の目的とするものであり、いかなる契約にも組み込むことはできません。
以下の事項は、マテリアルやコード、機能を提供することをコミットメント(確約)するもの
ではないため、購買決定を行う際の判断材料になさらないで下さい。
オラクル製品に関して記載されている機能の開発、リリースおよび時期については、弊
社の裁量により決定されます。
Oracleは、米国オラクル・コーポレーション及びその子会社、関連会社の米国及びその他の国における登録商標または商標です。
他社名又は製品名は、それぞれ各社の商標である場合があります。
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
このドキュメントの対象読者
対象
• Oracle	R	Enterprise(ORE)の環境を構築する人
• ORE環境をメンテナンスする人
前提スキル
• Linuxの場合、Linuxの普通の管理操作 (yumなど)
• Oracle	DBの基本的な管理
• Rをさわったことがあると望ましい(知らなくても大概大丈夫です)
3
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
Agenda
Oracle	R	Enterprise概要
Oracle	R	Enterpriseのアーキテクチャ
Oracle	R	Enterpriseのインストール手順
まとめ
4
素材のプチッチ
http://putiya.com/
イラストわんパグ
http://www.wanpug.com/
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
Oracle	Advanced	Analytics
製品概観
5
Oracle	Advanced	Analytics	
Oracle	Data	Mining Oracle	R	Enterprise
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
Big	Data	Management	System	
6
SOURCES
DATA	RESERVOIR DATA	WAREHOUSE
Oracle	Database
Oracle	Industry
Models
Oracle	Advanced	Analytics
Oracle	Spatial	&	Graph
Big	Data	Appliance
Apache	
Flume
Oracle
GoldenGate
Oracle	Event	
Processing
Cloudera	Hadoop
Oracle	Big	Data	SQL
Oracle	NoSQL
Oracle	R	Distribution
Oracle	Big	Data	
Spatial	and	Graph
Oracle	Database
In-Memory,	Multi-tenant
Oracle	Industry	Models
Oracle	Advanced	
Analytics
Oracle	Spatial	and	Graph
Exadata
Oracle
GoldenGate
Oracle	Event
Processing
Oracle	Data
Integrator
Oracle	Big	Data
Connectors	
Oracle	Data
Integrator
B
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
Oracle	Advanced	Analytics
製品概要
7
ODM/ORE 共通のメリット
• In-Database Analyticsの実現
– データ移動コスト(時間)をカット
– パワフルなデータベースサーバ内で処理
• 堅牢なDBセキュリティによるデータ保護
⽤途
– ⼤量データ,全量データに対する分析
– ⽣データでのリアルタイムな分析
他オプションや製品との連
携で更に⾼度な分析が可能
・Big Data Appliance
・Big Data SQL
・Big Data Connecters
・Spatial and Graph
etc..
ビッグデータ時代の
エンタープライズな
分析基盤を提供
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
Oracle	Advanced	Analytics	- Oracle	R	Enterprise
Oracle	R	Enterprise	製品概要
8
特⻑
• Rでの分析処理をデータベースへオフロード
– データ移動コスト(時間)をカット
– パワフルなデータベースサーバ内で処理
• エンタープライズなRユーザのための機能
– R関数の並列実⾏のためのインターフェイスを⽤意
– Rオブジェクト、モデルをDBに保存、Rからデータベースの操作も可能
– Oracle Data Mining機能をRから呼び出して利⽤が可能
– ⼤規模分析のため並列処理実装されたR関数(オリジナルパッケージ)
デスクトップ利⽤のRの限
界を超え、⼤規模なデータ
セットでの利⽤を可能に
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
補足:	Oracle	R	Distribution
Oracle	R	Distribution
9
• Oracle は Rのディストリビューターです
– Oracle は Rのディストリビューションを提供しています
• Oracle R Distribution(ORD)はRに対して改善や拡張を⾏った
ものになります
• ORDは無償でご利⽤頂けます
※ディストリビューションとはOSSのソフトウェアなどをパッケージングし利⽤しやすい形態で提供/配布しているものに
なります。Linuxの場合、Red Hat Linux, Debian, Ubuntu, SUSEなどがあります。
Oracle	R	Distribution
http://www.oracle.com/technetwork/database/database-technologies/r/r-distribution/downloads/index.html
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
Agenda
Oracle	R	Enterprise概要
Oracle	R	Enterpriseのアーキテクチャ
Oracle	R	Enterpriseのインストール手順
Oracle	R	Enterpriseの使い方
まとめ
10
素材のプチッチ
http://putiya.com/
イラストわんパグ
http://www.wanpug.com/
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		| 11
R言語を透過的にOracle	Database内で実行します。
Oracle	R	Enterprise アーキテクチャ
R⾔語の処理を透過的にOracle Database内の処理に変換することで、⼤規模な分析を実現します。
またDB内処理に変換できない部分もDBサーバ上でRプロセスを実⾏します。
R	EngineR	EngineR	Engine Other	R
packages
Rの処理をDB内の処理に変換・オフロードします。
Oracle	R	Enterprise	packages
R	Engine
Oracle	R	Enterprise	packages
SQL R
結果 結果
DBサーバ内で外部プロセスとしてRを実⾏することも可能です
Other	R
packages
Rクライアント
• RスクリプトをOracle Databaseで実
⾏するようにスクリプトを発⾏します。
• グラフの描画や処理フローの制御は、
通常のRの機能を利⽤し、クライアン
ト側で実⾏します。
Oracle	Database内部での実行
• Rの関数をSQLに変換して実⾏します。
• Oracle Databaseの並列実⾏の仕組みを活⽤し、
⼤量のデータに対応します。
• Oracle Databaseの持つ統計関数、データマイ
ニング機能を内部的に活⽤します。
Oracle	DatabaseサーバでのR実行
• データベースが複数のRのプロセスをデー
タベースサーバ上に外部プロセスとして起
動しますので、追加機器が不要です。
• SQLやPL/SQLからRのスクリプトを呼び
出し可能です。
分析者
DB
Oracle	DB	サーバ
外部
プロセス
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
Oracle	R	Enterprise	アーキテクチャ
全体感:コンポーネント
12
Server	SideClient	Side
OS
Oracle	R		
Distribution
Open	R
(/w	shared	
lib,lapack..)※
Oracle		R			
Enterprise	Client			 Oracle
DB	
Client
OS
Oracle		R			
Enterprise	
supporting	
Packages		
Oracle	R		
Distribution
Open	R
(/w	shared	
lib,lapack..)※
Oracle		R			
Enterprise	Server
Oracle		R			
Enterprise	
supporting	
Packages		
Oracle	
DB
/w	
AA
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
Oracle	R	Enterprise	アーキテクチャ
全体感:コンポーネント:OS
13
Server	SideClient	Side
OS
Oracle	R		
Distribution
Open	R
(/w	shared	
lib,lapack..)※
Oracle		R			
Enterprise	Client			 Oracle
DB	
Client
OS
Oracle		R			
Enterprise	
supporting	
Packages		
Oracle	R		
Distribution
Open	R
(/w	shared	
lib,lapack..)※
Oracle		R			
Enterprise	Server
Oracle		R			
Enterprise	
supporting	
Packages		
Oracle	
DB
/w	
AA
OSについてはマニュアルのシステム要件に記載がございます。ORE 1.5の
場合、どのOSに関しても 64 bit版であることが必須となります。詳しくは
下記をご覧ください。Oracle Enterprise Linuxの場合にはyumのレポジト
リがあり、セットアップが少し効率的です。
https://docs.oracle.com/cd/E67822_01/OREAD/intro.htm#OREAD120
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
Oracle	R	Enterprise	アーキテクチャ
全体感:コンポーネント:Rの動作環境
14
Server	SideClient	Side
OS
Oracle	R		
Distribution
Open	R
(/w	shared	
lib,lapack..)※
Oracle		R			
Enterprise	Client			 Oracle
DB	
Client
OS
Oracle		R			
Enterprise	
supporting	
Packages		
Oracle	R		
Distribution
Open	R
(/w	shared	
lib,lapack..)※
Oracle		R			
Enterprise	Server
Oracle		R			
Enterprise	
supporting	
Packages		
Oracle	
DB
/w	
AA
Rの動作環境及び基本機能を提供する部分です。
Oracle R Distributionをご利⽤頂くとスムースですが、Open R を利⽤す
ることも可能です。Open R を利⽤する際には ソースからのbuildが必要と
なるケースがあります。
※マニュアルに記載がありますが、linpackの利⽤やshlibの利⽤などを有効にして
buildする必要があります
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
Oracle	R	Enterprise	アーキテクチャ
全体感:コンポーネント:Oracle	R	Enterprise	Client
15
Server	SideClient	Side
OS
Oracle	R		
Distribution
Open	R
(/w	shared	
lib,lapack..)※
Oracle		R			
Enterprise	Client			 Oracle
DB	
Client
OS
Oracle		R			
Enterprise	
supporting	
Packages		
Oracle	R		
Distribution
Open	R
(/w	shared	
lib,lapack..)※
Oracle		R			
Enterprise	Server
Oracle		R			
Enterprise	
supporting	
Packages		
Oracle	
DB
/w	
AA
Oracle R Enterprise Clientには OREの基本パッケージやR関数の
SQL変換wraperとなるパッケージ、⼀部RパッケージのOracle実装版、
ORE独⾃機能、Oracle Data Mining機能の呼び出しなどのRパッケー
ジが含まれます。クライアントサーバ間でバージョンが同⼀である必
要があります
含まれるパッケージ(⼀部抜粋)
- ORE (トップレベルパッケージ)
- OREbase (Rのbase相当)
- OREcommon(OREの共通低レベル機能/DB接続や操作など)
- OREdm(Oracle Data Mining⽤のアルゴリズム利⽤)
- OREeda(探索型データ解析⽤パッケージ)
- OREgraphics(Rのgraphics相当)
など
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
Oracle	R	Enterprise	アーキテクチャ
全体感:コンポーネント:Oracle	R	Enterprise	Supporting	Packages
16
Server	SideClient	Side
OS
Oracle	R		
Distribution
Open	R
(/w	shared	
lib,lapack..)※
Oracle		R			
Enterprise	Client			 Oracle
DB	
Client
OS
Oracle		R			
Enterprise	
supporting	
Packages		
Oracle	R		
Distribution
Open	R
(/w	shared	
lib,lapack..)※
Oracle		R			
Enterprise	Server
Oracle		R			
Enterprise	
supporting	
Packages		
Oracle	
DB
/w	
AAOracle R Enterprise Supporting Packageには、Oracle Database 通信⽤のインターフェ
イス定義やOCIインターフェイス、R関数のOracle実装などのパッケージが含まれます。これ
はServer, Clientともに共通になります。
含まれるパッケージ(⼀部抜粋)
- DBI(データベース通信インターフェイス),ROracle(OCIインターフェイス),Cairo(グラ
フィックスのレンダリング),png(png画像の読み込み、書き込み⽤)など
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
Oracle	R	Enterprise	アーキテクチャ
全体感:コンポーネント:Oracle	Database	Client
17
Server	SideClient	Side
OS
Oracle	R		
Distribution
Open	R
(/w	shared	
lib,lapack..)※
Oracle		R			
Enterprise	Client			 Oracle
DB	
Client
OS
Oracle		R			
Enterprise	
supporting	
Packages		
Oracle	R		
Distribution
Open	R
(/w	shared	
lib,lapack..)※
Oracle		R			
Enterprise	Server
Oracle		R			
Enterprise	
supporting	
Packages		
Oracle	
DB
/w	
AA
Oracle Database Client はOracle Database
のクライアントライブラリを含み、Rからのデー
タベース接続(OCI)⽤のNativeライブラリを提供
します。(実際にはDynamic Linkerでリンクされ
利⽤されます)
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
Oracle	R	Enterprise	アーキテクチャ
全体感:コンポーネント:Oracle	Database	Client
18
Server	SideClient	Side
OS
Oracle	R		
Distribution
Open	R
(/w	shared	
lib,lapack..)※
Oracle		R			
Enterprise	Client			 Oracle
DB	
Client
OS
Oracle		R			
Enterprise	
supporting	
Packages		
Oracle	R		
Distribution
Open	R
(/w	shared	
lib,lapack..)※
Oracle		R			
Enterprise	Server
Oracle		R			
Enterprise	
supporting	
Packages		
Oracle	
DB
/w	
ORE	
Server
Oracle R Enterprise Server は Oracle R
Enterprise⽤のRパッケージとOracleデータ
ベース内のスキーマ(RQSYS)やプロシージャ、
操作権限などのメタデータ群で構成されます。
これらを⽤いてRオブジェクトをデータベースに格納
したり、埋め込みRによる実⾏などを実現しています。
Rパッケージとしては、ORE Clientに
OREserverパッケージが加わっています。
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
Agenda
Oracle	R	Enterprise概要
Oracle	R	Enterpriseのアーキテクチャ
Oracle	R	Enterpriseのインストール手順
まとめ
19
素材のプチッチ
http://putiya.com/
イラストわんパグ
http://www.wanpug.com/
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
OREのインストール全貌
• クライアントマシン上のRからDBに接続し利⽤する場合、サーバと
クライアント両⽅にRのインストールが必要になります
– ⼤抵上記の構成になるかと思います
• RはOracle R Distributionを利⽤頂いてもよいですし、OSSの Rを
ソースからビルドして頂く⽅法もあります
• サーバ、クライアントで作業に少し違いがあります
20
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
システム要件
ORE	1.5の場合
Operating System Hardware Description
Linux x86-64 Intel and AMD
•64-bit Oracle Linux Releases 6 and 7
•64-bit Red Hat Enterprise Linux Releases 6 and 7
Oracle Linux may be running on Oracle Exadata Database Machine.
Oracle Solaris
on x86-64 (64-Bit)
Oracle Solaris
on SPARC-64 (64-Bit)
Intel and SPARC
•64-bit Oracle Solaris 10 update 10 through Oracle Solaris 11 for
both SPARC and x86-64 (Intel) platforms
•Oracle SPARC SuperCluster
•Oracle Solaris Studio (formerly Sun Studio) 12u3 or later
Oracle Solaris may be running on Oracle Exadata Database
Machine.
IBM AIX
on POWER Systems (64-Bit)
IBM 64-bit IBM AIX 5.3 or higher
Microsoft Windows x64 (64-Bit) Intel
64-bit Microsoft Windows
See Section 1.4.1, "Verifying 64-Bit Architecture on Microsoft
Windows".
21
出典:
http://docs.oracle.com/cd/E67822_01/OREAD/intro.htm#OREAD120
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
ORE インストール手順
ORE Server
[DB Binary Install済み]
[インスタンス作成済み]
• Rインストール
– ORD or Open R ( ⾃⼒make)
• OREインストール
– serverスクリプト
22
ORE Client
• Oracle DB Client Install
• Rインストール
– ORD or Open R ( ⾃⼒make)
• OREインストール
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
インストール手順全貌
23
サーバ
構築の流れ
クライアント
構築の流れ
Oracle DB
Install
Oracle
インスタンス
作成
Oracle R
Distribution
Open R
build
server script
Oracle
DB Client
Oracle R
Distribution
Open R
build
ORE Client
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
インストール手順全貌
24
サーバ
構築の流れ
クライアント
構築の流れ
Oracle DB
Install
Oracle
インスタンス
作成
Oracle R
Distribution
Open R
build
server script
Oracle
DB Client
Oracle R
Distribution
Open R
build
ORE Client
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
インストール手順全貌
25
サーバ
構築の流れ
クライアント
構築の流れ
Oracle DB
Install
Oracle
インスタンス
作成
Oracle R
Distribution
Open R
build
server script
Oracle
DB Client
Oracle R
Distribution
Open R
build
ORE Client
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
Oracle	DB	Install/	インスタンス作成
注意点
• Oracle DB インストール
– Advanced Analytics(AA)を外したりしないで⼊れてあげてください
– Oracle DB Enterprise Edition のdefaultでインストールされます
– Oracle DB Standard Editionではご利⽤になれません
• Oracleインスタンス作成
– こちらもAAオプションを外さないでインスタンスを作成してください
– ORACLE_HOME,ORACLE_SID,LD_LIBRARY_PATHなどの環境変数の設定
を忘れないようにしてください
26
DBのインストール、インスタンスの作成に関してはここでは割愛させて頂きます。
別途マニュアルなどをご参照ください
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
インストール手順全貌
27
サーバ
構築の流れ
クライアント
構築の流れ
Oracle DB
Install
Oracle
インスタンス
作成
Oracle R
Distribution
Open R
build
server script
Oracle
DB Client
Oracle R
Distribution
Open R
build
ORE Client
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
Rのインストール
概要
Rのインストールに関しては2通りの⽅法があります
Oracle R Distribution(ORD) [楽]
• Oracle が DistributionしているオープンソースのRになります
• ORDのバージョンに合わせた形でのご利⽤となります
オープンソース版 R のbuild [やや⾯倒]
• CRANでダウンロードできるRを⼀部フラグを⽴ててbuildします
• サポートされる範囲で最新のRをご利⽤頂けます
• ⼿順に関してはサーバ、クライアントで同じです
※上記(ORDとOpen Source版R)を両⽅⼊れる必要はありません
28
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
Rのインストール
ORDのメリット
OREではORDの利⽤が推奨されます
• ORDのメリット
– 簡単
– サポートの提供
– 数学関数⾼速化ライブラリの統合
• Intel Math Kernel Library(MKL) (for Win/Linux)
• Sun Performance Libraryの利⽤(for Oracle Solaris)
• ORDの弱点
– Rのバージョン追従性(CRANと⽐較)
29
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
R,	OREのサーバクライアント間のバージョンについて
サーバ環境とクライアント環境
基本的にバージョンを揃える指針での運⽤をお薦めします
• Rのバージョン
– サーバ⽤のRと揃えておいた⽅がよいかと思います
• 埋め込みRの実⾏時にはクライアントのRからサーバ側のRにスクリプトを実⾏させ、結果
を取得する動きとなります。そのため3rd PartyのRパッケージなどでもバージョン差異な
どによる問題が発⽣する可能性があります
• 埋め込みRの実⾏やその他関数の動作確認などの⼿間を減らせるかと思います
• OREのバージョン
– OREのバージョンは同⼀であることが必須要件となります
30
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
ご参考:ORE	1.5	matrix
Oracle	R	Enterprise	Server	Support	Matrix
Oracle R Enterprise
Open source R
or Oracle R Distribution
Oracle Database (see Note)
1.5 3.2.x 11.2.0.4, 12.1.0.1, 12.1.0.2
1.4.1 3.0.1, 3.1.1 11.2.0.3, 11.2.0.4, 12.1.0.1
1.4 3.0.1, 3.1.1 11.2.0.3, 11.2.0.4, 12.1.0.1
1.3.1 2.15.1, 2.15.2, 2.15.3 11.2.0.3, 11.2.0.4, 12.1.0.1
1.3 2.15.1 11.2.0.3, 11.2.0.4, 12.1.0.1
1.2 2.15.1 11.2.0.3, 11.2.0.4, 12.1.0.1
1.1 2.13.2 11.2.0.3, 11.2.0.4, 12.1.0.1
1.0 2.13.2 11.2.0.3, 11.2.0.4, 12.1.0.1
31
R	Enterprise	Installation	and	Administration	Guide	- Oracle	R	Enterprise	System	Requirements
https://docs.oracle.com/cd/E67822_01/OREAD/intro.htm#OREAD335
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
インストール手順全貌
32
サーバ
構築の流れ
クライアント
構築の流れ
Oracle DB
Install
Oracle
インスタンス
作成
Oracle R
Distribution
Open R
build
server script
Oracle
DB Client
Oracle R
Distribution
Open R
build
ORE Client
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
OSによって作業が異なります
• ここでは以下について記載します
– Oracle Enterprise Linux(OEL)
– Windows
– RedHat Enterprise Linux (RHEL)
• その他のOSの場合は下記マニュアルをご確認ください
Oracle	R	Distribution(ORD)	のインストール
全体感
33
R	Enterprise	Installation	and	Administration	Guide
3.	Installing	R	for	Oracle	R	Enterprise
http://docs.oracle.com/cd/E67822_01/OREAD/install_r.htm
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
yumレポジトリにORDが⼊っています
• Oracleのyum repositoryのaddonsに⼊っています
– OEL7の場合 [ol7_addons], OEL6の場合 [ol6_addons]
– yumレポジトリの設定ファイル(/etc/yum.repo.d内のファイル)内でaddons
のエントリをenable(enabled=1)にすることでパッケージが検索されます
• (OEL7) /etc/yum.repos.d/public-yum-ol7.repo
• (OEL6) /etc/yum.repos.d/public-yum-ol6.repo
• enableにしたらyumでインストールできます
Oracle	R	Distribution(ORD)	のインストール
Oracle	Enterprise	Linux	(OEL)の場合
34
yum install R
yum install R-core
yum install R-devel
※環境によっては、
latest,
optional_latest
のレポジトリもenableにしてお
くと必要な依存関係パッケージ
を⾃動追加してくれるかもしれ
ません
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
ご参考:Oracle	R	Distribution	のインストール
OEL	RPMパッケージ
• OELはRPMパッケージでのインストールも可能です
• ORD 3.2 の場合
– OEL 6
– OEL 7
35
http://public-yum.oracle.com/repo/OracleLinux/OL6/addons/x86_64/getPackage/R-3.2.0-2.el6.x86_64.rpm
http://public-yum.oracle.com/repo/OracleLinux/OL6/addons/x86_64/getPackage/R-core-3.2.0-2.el6.x86_64.rpm
http://public-yum.oracle.com/repo/OracleLinux/OL6/addons/x86_64/getPackage/R-devel-3.2.0-2.el6.x86_64.rpm
http://public-yum.oracle.com/repo/OracleLinux/OL6/addons/x86_64/getPackage/libRmath-3.2.0-2.el6.x86_64.rpm
http://public-yum.oracle.com/repo/OracleLinux/OL6/addons/x86_64/getPackage/libRmath-devel-3.2.0-2.el6.x86_64.rpm
http://public-yum.oracle.com/repo/OracleLinux/OL6/addons/x86_64/getPackage/libRmath-static-3.2.0-2.el6.x86_64.rpm
http://public-yum.oracle.com/repo/OracleLinux/OL7/addons/x86_64/getPackage/R-3.2.0-2.el7.x86_64.rpm
http://public-yum.oracle.com/repo/OracleLinux/OL7/addons/x86_64/getPackage/R-core-3.2.0-2.el7.x86_64.rpm
http://public-yum.oracle.com/repo/OracleLinux/OL7/addons/x86_64/getPackage/R-devel-3.2.0-2.el7.x86_64.rpm
http://public-yum.oracle.com/repo/OracleLinux/OL7/addons/x86_64/getPackage/libRmath-3.2.0-2.el7.x86_64.rpm
http://public-yum.oracle.com/repo/OracleLinux/OL7/addons/x86_64/getPackage/libRmath-devel-3.2.0-2.el7.x86_64.rpm
http://public-yum.oracle.com/repo/OracleLinux/OL7/addons/x86_64/getPackage/libRmath-static-3.2.0-2.el7.x86_64.rpm
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
Oracle	R	Distribution(ORD)	のインストール
Windows	の場合
• ORDをダウンロードします
– 下記のサイトからWindowsのものをダウンロードします
※OREのシステム要件(前述)を満たす必要があります
• zipを解凍して以下を実⾏します
• インストールWizardに従ってインストールします
– ⾔語、インストール先、などデフォルトのままで⼤丈夫です
36
https://oss.oracle.com/ORD/
ORD-Rversion-win.exe		
(ORD	3.2の場合 ORD-3.2-win.exe)
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
ご参考:ORD	3.2	for	windows	インストール画面
基本的に[次へ]を押してくだけです
37
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
Oracle	R	Distribution	のインストール
Red	Hat	Enterprise	Linux	の場合(1/2)
rpmbuildでソースからパッケージをbuildする必要があります
• rpmbuildのインストール (インストール済みの場合は不要です)
• ソース rpmパッケージのダウンロード
– 以下のサイトからダウンロードできます
• rpmbuild準備
38
yum install rpm-build
RHEL	6		http://public-yum.oracle.com/repo/OracleLinux/OL6/addons/x86_64/index_src.html
RHEL	7		http://public-yum.oracle.com/repo/OracleLinux/OL7/addons/x86_64/index_src.html
mkdir -p rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
Oracle	R	Distribution	のインストール
Red	Hat	Enterprise	Linux	の場合(1/2)
• ダウンロードした src.rpmファイルを SRPMS に移動
• rpmbuildの実⾏
• rpm -i でパッケージを追加します
– 出来たパッケージは rpmbuild/RPMS/x86_64/ に安置されています
39
mv R-3.2.0-2.el7.src.rpm rpmbuild/SRPMS/
rpmbuild --ebuild rpmbuild/SRPMS/R-3.2.0-2.el7.src.rpm
※OSのパッケージのインストール状
況によっては texlive, lapack,
libtiff などの必要なパッケージのイ
ンストールが要求される場合があり
ますので、適宜対応して下さい。
※場合によっては LANG=C もお試
しくださいませ
rpm -i rpmbuild/RPMS/x86_64/R-3.2.0-2.el7.x86_64.rpm
rpm -i rpmbuild/RPMS/x86_64/R-core-3.2.0-2.el7.x86_64.rpm
rpm -i rpmbuild/RPMS/x86_64/libRmath-3.2.0-2.el7.x86_64.rpm
rpm -i rpmbuild/RPMS/x86_64/libRmath-devel-3.2.0-2.el7.x86_64.rpm
rpm -i rpmbuild/RPMS/x86_64/libRmath-static-3.2.0-2.el7.x86_64.rpm
rpm -i rpmbuild/RPMS/x86_64/R-debuginfo-3.2.0-2.el7.x86_64.rpm
rpm -i rpmbuild/RPMS/x86_64/R-devel-3.2.0-2.el7.x86_64.rpm
※versionによって差異
がある場合があります
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
• ORDをダウンロードします
※OREのシステム要件(前述)を満たす必要があります
• インストールを実施します
– 上記サイトのINSTALLに詳しい記載へのリンクがあります
• マニュアルは以下になります
ご参考:Oracle	R	Distribution	のインストール
その他の場合
40
R	Enterprise	Installation	and	Administration	Guide
3.	Installing	R	for	Oracle	R	Enterprise
http://docs.oracle.com/cd/E67822_01/OREAD/install_r.htm
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
インストール手順全貌
41
サーバ
構築の流れ
クライアント
構築の流れ
Oracle DB
Install
Oracle
インスタンス
作成
Oracle R
Distribution
Open R
build
server script
Oracle
DB Client
Oracle R
Distribution
Open R
build
ORE Client
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
オープンソース版Rのインストール
Linux (	OEL,	RHELなど)
• CRANからRのソースコードをダウンロードします
• ダウンロードしたファイルを解凍します
• 解凍してできたディレクトリ内で以下を実⾏します(linux/OEL)
42
https://cran.r-project.org/
こちらの記載はOREの構築に必要なR
のconfigureオプションを有効化すること
だけを目的としています.
オープンソースのRのビルド手法を保証
するものではありません
./configure --with-lapack --with-ICU=no --enable-R-shlib --prefix=/usr/local/R/323
make
make install
※環境によっては configureの際にパッケージが不⾜してエラーがでることがあります
yumなどで適宜追加してください (gfortran, libXxx-devel など)
例
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
インストール手順全貌
43
サーバ
構築の流れ
クライアント
構築の流れ
Oracle DB
Install
Oracle
インスタンス
作成
Oracle R
Distribution
Open R
build
server script
Oracle
DB Client
Oracle R
Distribution
Open R
build
ORE Client
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
ORE	サーバのセットアップ
環境変数の確認と設定
• 環境変数を確認、設定します
• その他
– インストールの実⾏ユーザはOS認証可能なDBAグループである必要があります
44
環境変数 設定値 コメント
PATH 環境依存 対象のRが実⾏可能な状態にしておきます。
※yumでインストールした場合、PATHは⾃動的に通っています
※Rを別途インストールし利⽤する場合にはPATH設定が必要です。
※実⾏されるRは右記で確認できます
ORACLE_SID 環境依存 対象のDBインスタンスのSID(OS認証⽤)
ORACLE_HOME 環境依存 対象のDBインスタンスのORACLE_HOME(OS認証⽤)
LD_LIBRARY_PATH $ORACLE_HOME/libを含む 対象DBバイナリのライブラリを含むパスを設定します
R RHOME
R --version
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
ORE	サーバのセットアップ
データベースの準備
• データベースの準備をします
– (必要に応じて) 表領域を作成します
– (必要に応じて)OREを使うDBユーザを作成します
※ORE利⽤ユーザや表領域が既に準備されている場合には上記の作業は不要です
※接続ユーザは未作成の場合、serverスクリプトで作成をすることもできますが、表領域は事前に準備して
おく必要があります
45
sqlplus "/as sysdba" << !!
CREATE TABLESPACE oretbs DATAFILE '/oradata/oretbs01.dbf' SIZE 1024m ;
CREATE USER oreuser IDENTIFIED BY oreuser DEFAULT TABLESPACE oretbs
TEMPORARY TABLESPACE temp;
GRANT connect,resource TO oreuser ;
ALTER USER oreuser QUOTA UNLIMITED ON oretbs ;
!!
例
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
ORE	サーバのセットアップ
OREバイナリのダウンロード
• 以下から該当アーキテクチャのOREをダウンロードします
– Server(必須), Supporting(任意) をダウンロードします
• 展開します
– 必要な場合 Supportingも同じディレクトリに展開します
46
http://www.oracle.com/technetwork/database/database-technologies/r/r-enterprise/downloads/index.html
$ mkdir oreserver
$ mv ore-server-linux-x86-64-1.5.zip oreserver/
$ mv ore-supporting-linux-x86-64-1.5.zip oreserver/
$ cd oreserver
$ unzip ore-supporting-linux-x86-64-1.5.zip > /dev/null
$ unzip ore-supporting-linux-x86-64-1.5.zip > /dev/null
例
$ ls
ore-server-linux-x86-64-1.5.zip server supporting
ore-supporting-linux-x86-64-1.5.zip server.sh tmpcdb.sql
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
ORE	サーバのセットアップ
serverスクリプトの実行
• 同梱されているserverスクリプトを実⾏します
– defaultでは対話型のインストールになります
47
$ ./server.sh
Checking platform .................. Pass
Checking R ......................... Pass
Checking R libraries ............... Pass
Checking ORACLE_HOME ............... Pass
Checking ORACLE_SID ................ Pass
Checking sqlplus ................... Pass
Checking ORACLE instance ........... Pass
Checking CDB/PDB ................... Pass
Checking ORE ....................... Pass
Choosing RQSYS tablespaces
PERMANENT tablespace to use for RQSYS [list]:USERS
例
TEMPORARY tablespace to use for RQSYS [list]: TEMP
RQSYSユーザ⽤の表領域を
指定します
※RQSYSユーザは OREのDB側の管理
ユーザで、R呼び出し関連の関数やRオ
ブジェクトなどが実際に配置されるス
キーマになります
RQSYSユーザ⽤の⼀時表領域を
指定します
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
ORE	サーバのセットアップ
serverスクリプトの実行
つづき
48
Choosing RQSYS password
Password to use for RQSYS:
例
TEMPORARY tablespace to use for OREUSER [list]:TEMP
Choosing ORE user
ORE user to use [list]: oreuser
Choosing OREUSER tablespaces
PERMANENT tablespace to use for OREUSER [list]: USERS
Choosing OREUSER password
Password to use for OREUSER:
RQSYSユーザのパスワードを⼊⼒します
※⼊⼒⽂字は表⽰されないです。ありがちな⼆度⼊⼒には
なっていないのですが、分からなくなった場合にはsysdbaか
らalter userでなんとかなります。
OREを実際に接続して利⽤するユーザを指定
します
※作成済みであれば後の表領域などの選択肢はでてきません。
⼊⼒⽂字は表⽰されないです。
利⽤するユーザのデフォルト表領域と⼀時表
領域、パスワードを⼊⼒します
※作成済みであればこの質問はでてきません。
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
ORE	サーバのセットアップ
serverスクリプトの実行
• ⼊⼒した内容と環境変数やRの場所を確認します
49
Current configuration
R Version ........................ R version 3.2.3 (2015-12-10)
R_HOME ........................... /usr/local/R/323/lib64/R
R_LIBS_USER ...................... /app/oracle/product/db/12.1.0.2/R/library
ORACLE_HOME ...................... /app/oracle/product/db/12.1.0.2
ORACLE_SID ....................... ora12c
Existing R Version ............... None
Existing R_HOME .................. None
Existing ORE data ................ None
Existing ORE code ................ None
Existing ORE libraries ........... None
RQSYS PERMANENT tablespace ....... USERS
RQSYS TEMPORARY tablespace ....... TEMP
ORE user type .................... New
ORE user name .................... OREUSER
ORE user PERMANENT tablespace .... USERS
ORE user TEMPORARY tablespace .... TEMP
Grant RQADMIN role ............... No
Operation ........................ Install/Upgrade/Setup
Proceed? [yes]
例
※ユーザが新規作成の場合、ここがNewになります
作成済み、既存ユーザの場合、Existと表⽰されます
※OKであれば returnキーでインストールが開始されます
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
ORE	サーバのセットアップ
serverスクリプトの実行
• エラーなく完了すればインストールは完了です
50
Removing R libraries ............... Pass
Installing R libraries ............. Pass
Installing ORE libraries ........... Pass
Installing RQSYS data .............. Pass
Configuring ORE .................... Pass
Installing RQSYS code .............. Pass
Installing ORE packages ............ Pass
Creating ORE script ................ Pass
Installing migration scripts ....... Pass
Installing supporting packages ..... Pass
Creating ORE user .................. Pass
Granting ORE privileges ............ Pass
Done
例
$ ls
ore-server-linux-x86-64-1.5.zip server supporting
ore-supporting-linux-x86-64-1.5.zip server.sh tmpcdb.sql
※展開する際に記載した server.shの場所にsupportingパッ
ケージを展開していればこの時にsupporting パッケージもイ
ンストールされます
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
ORE	サーバのセットアップ
補足:Serverスクリプトがやっていること
• サーバ⽤インストールスクリプト (serverスクリプト)では、概ね以
下の作業をしています
– RQSYSユーザの作成、スキーマオブジェクトの作成
51
余力ができたらまとめてみる予定
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
インストール手順全貌
52
サーバ
構築の流れ
クライアント
構築の流れ
Oracle DB
Install
Oracle
インスタンス
作成
Oracle R
Distribution
Open R
build
server script
Oracle
DB Client
Oracle R
Distribution
Open R
build
ORE Client
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
ORE	サーバの確認
確認(OREコマンド)
• うまくできていれば ORE コマンドが実⾏可能になります
53
$ ORE
R version 3.2.3 (2015-12-10) -- "Wooden Christmas-Tree"
Copyright (C) 2015 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R は、⾃由なソフトウェアであり、「完全に無保証」です。
⼀定の条件に従えば、⾃由にこれを再配布することができます。
配布条件の詳細に関しては、'license()' あるいは 'licence()' と⼊⼒してください。
R は多くの貢献者による共同プロジェクトです。
詳しくは 'contributors()' と⼊⼒してください。
また、R や R のパッケージを出版物で引⽤する際の形式については
'citation()' と⼊⼒してください。
'demo()' と⼊⼒すればデモをみることができます。
'help()' とすればオンラインヘルプが出ます。
'help.start()' で HTML ブラウザによるヘルプがみられます。
'q()' と⼊⼒すれば R を終了します。
>
例
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
ORE	サーバの確認
確認(ORE	パッケージのロード)
• OREパッケージがロードできます
54
> library(ORE)
要求されたパッケージ OREbase をロード中です
要求されたパッケージ OREcommon をロード中です
次のパッケージを付け加えます: ‘OREbase’
以下のオブジェクトは ʻpackage:base’ からマスクされています:
cbind, data.frame, eval, interaction, order, paste, pmax, pmin,
rbind, table
要求されたパッケージ OREembed をロード中です
要求されたパッケージ OREstats をロード中です
要求されたパッケージ MASS をロード中です
要求されたパッケージ OREgraphics をロード中です
要求されたパッケージ OREeda をロード中です
要求されたパッケージ OREmodels をロード中です
要求されたパッケージ OREdm をロード中です
要求されたパッケージ lattice をロード中です
要求されたパッケージ OREpredict をロード中です
要求されたパッケージ ORExml をロード中です
>
例
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
インストール手順全貌
55
サーバ
構築の流れ
クライアント
構築の流れ
Oracle DB
Install
Oracle
インスタンス
作成
Oracle R
Distribution
Open R
build
server script
Oracle
DB Client
Oracle R
Distribution
Open R
build
ORE Client
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
インストール手順全貌
56
サーバ
構築の流れ
クライアント
構築の流れ
Oracle DB
Install
Oracle
インスタンス
作成
Oracle R
Distribution
Open R
build
server script
Oracle
DB Client
Oracle R
Distribution
Open R
build
ORE Client
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
インストール手順全貌
57
サーバ
構築の流れ
クライアント
構築の流れ
Oracle DB
Install
Oracle
インスタンス
作成
Oracle R
Distribution
Open R
build
server script
Oracle
DB Client
Oracle R
Distribution
Open R
build
ORE Client
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
Oracle DB	クライアント
メディアの準備
OREクライアントにはOracle DB のクライアントが必要です
• 以下のいずれかを準備します
– Oracle DB Client ( Oracle DB メディアに同梱 )
• DBサーバ上で直接Rクライアントを実⾏する場合にはインストール済みのものを利⽤できます
• Instant Clientに⽐べるとサイズが少し⼤きいです
– Oracle DB Instant Client ( OTNなどからダウンロード⼊⼿/無償)
• 以下から対象のアーキテクチャ、OSを選んでクリックしします
• ダウンロードページでInstant Client Package - Basic (か Basic Lite) と SDK をダウ
ンロードします
58
Oracle	Instant	Client:
http://www.oracle.com/technetwork/database/features/instant-client/index.html
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
Oracle DB	クライアント
ご参考:Oracle	Instant	Client	(Windows版)
• Windowsの場合、右記の2つ
をダウンロードします
59
※Linux, zip版, RPM版も基本的に同様の2つ
をダウンロードします
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
Oracle DB	クライアント
Oracle	Instant	Client	のインストール
• Oracle Instant Clientは以下の⼿順でインストールできます
• basicとsdkのアーカイブを同じインストールフォルダにコピーします
• ダウンロードしたbasicを解凍します
• 同じディレクトリでダウンロードしたsdkを上書き展開します
• 環境変数を設定します
60
Windows
OCI_LIB64環境変数
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
Oracle DB	クライアント
ご参考:Oracle	Instant	Client	(Windows	版)環境設定 - Windows	7	の例
• Windowsメニュー のコンピュータを右クリックしプロパティを左クリック
61
• システムの詳細設定を左クリック
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
Oracle DB	クライアント
ご参考:Oracle	Instant	Client	(Windows	版)環境設定 - Windows	7	の例
• 詳細設定タブの環境変数をクリック
62
システム環境変数の
• OCI_LIB64 を インストールディレクトリ
(instantclient_<version> )に設定
• Path環境変数 に同じインストールディレクトリを追加
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
インストール手順全貌
63
サーバ
構築の流れ
クライアント
構築の流れ
Oracle DB
Install
Oracle
インスタンス
作成
Oracle R
Distribution
Open R
build
server script
Oracle
DB Client
Oracle R
Distribution
Open R
build
ORE Client
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
Rのインストール
概要
Rのインストールに関しては2通りの⽅法があります
Oracle R Distribution(ORD) [楽]
• Oracle が DistributionしているオープンソースのRになります
• ORDのバージョンに合わせた形でのご利⽤となります
オープンソース版 R のbuild [やや⾯倒]
• CRANでダウンロードできるRを⼀部フラグを⽴ててbuildします
• サポートされる範囲で最新のRをご利⽤頂けます
• ⼿順に関してはサーバ、クライアントで同じです
※上記(ORDとOpen Source版R)を両⽅⼊れる必要はありません
64
再掲
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
Rのインストール
ORDのメリット
OREではORDの利⽤が推奨されます
• ORDのメリット
– 簡単
– サポートの提供
– 数学関数⾼速化ライブラリの統合
• Intel Math Kernel Library(MKL)との統合を簡素化 (Win/Linux)
• Sun Performance Libraryの利⽤(Oracle Solaris)
• ORDの弱点
– Rのバージョン追従性(CRANと⽐較)
65
再掲
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
R,	OREのサーバクライアント間のバージョンについて
サーバ環境とクライアント環境
基本的にバージョンを揃える指針での運⽤をお薦めします
• Rのバージョン
– サーバ⽤のRと揃えておいた⽅がよいかと思います
• 埋め込みRの実⾏時にはクライアントのRからサーバ側のRにスクリプトを実⾏させ、結果
を取得する動きとなります。そのため3rd PartyのRパッケージなどでもバージョン差異な
どによる問題が発⽣する可能性があります
• 埋め込みRの実⾏やその他関数の動作確認などの⼿間を減らせるかと思います
• OREのバージョン
– OREのバージョンは同⼀であることが必須要件となります
66
再掲
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
ご参考:ORE	1.5	matrix
Oracle	R	Enterprise	Server	Support	Matrix
Oracle R Enterprise Open source R or Oracle R Distribution Oracle Database (see Note)
1.5 3.2.x 11.2.0.4, 12.1.0.1, 12.1.0.2
1.4.1 3.0.1, 3.1.1 11.2.0.3, 11.2.0.4, 12.1.0.1
1.4 3.0.1, 3.1.1 11.2.0.3, 11.2.0.4, 12.1.0.1
1.3.1 2.15.1, 2.15.2, 2.15.3 11.2.0.3, 11.2.0.4, 12.1.0.1
1.3 2.15.1 11.2.0.3, 11.2.0.4, 12.1.0.1
1.2 2.15.1 11.2.0.3, 11.2.0.4, 12.1.0.1
1.1 2.13.2 11.2.0.3, 11.2.0.4, 12.1.0.1
1.0 2.13.2 11.2.0.3, 11.2.0.4, 12.1.0.1
67
R	Enterprise	Installation	and	Administration	Guide	- Oracle	R	Enterprise	System	Requirements
https://docs.oracle.com/cd/E67822_01/OREAD/intro.htm#OREAD335
再掲
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
インストール手順全貌
68
サーバ
構築の流れ
クライアント
構築の流れ
Oracle DB
Install
Oracle
インスタンス
作成
Oracle R
Distribution
Open R
build
server script
Oracle
DB Client
Oracle R
Distribution
Open R
build
ORE Client
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
OSによって作業が異なります
• ここでは以下について記載します
– Oracle Enterprise Linux(OEL)
– Windows
– RedHat Enterprise Linux (RHEL)
• その他のOSの場合は下記マニュアルをご確認ください
Oracle	R	Distribution(ORD)	のインストール
全体感
69
再掲
R	Enterprise	Installation	and	Administration	Guide
3.	Installing	R	for	Oracle	R	Enterprise
http://docs.oracle.com/cd/E67822_01/OREAD/install_r.htm
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
yumレポジトリにORDが⼊っています
• Oracleのyum repositoryのaddonsに⼊っています
– OEL7の場合 [ol7_addons], OEL6の場合 [ol6_addons]
– yumレポジトリの設定ファイル(/etc/yum.repo.d内のファイル)内でaddons
のエントリをenable(enabled=1)にすることでパッケージが検索されます
• (OEL7) /etc/yum.repos.d/public-yum-ol7.repo
• (OEL6) /etc/yum.repos.d/public-yum-ol6.repo
• enableにしたら以下でインストールできます
Oracle	R	Distribution(ORD)	のインストール
Oracle	Enterprise	Linux	(OEL)の場合
70
yum install R
yum install R-core
yum install R-devel
再掲
※環境差異がありますが、latest,
optional_latest もenableにしてお
くと必要な依存関係パッケージを
⾃動追加してくれるかもしれませ
ん
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
ご参考:Oracle	R	Distribution	のインストール
OEL	RPMパッケージ
• OELはRPMパッケージでのインストールも可能です
• ORD 3.2 の場合
– OEL 6
– OEL 7
71
http://public-yum.oracle.com/repo/OracleLinux/OL6/addons/x86_64/getPackage/R-3.2.0-2.el6.x86_64.rpm
http://public-yum.oracle.com/repo/OracleLinux/OL6/addons/x86_64/getPackage/R-core-3.2.0-2.el6.x86_64.rpm
http://public-yum.oracle.com/repo/OracleLinux/OL6/addons/x86_64/getPackage/R-devel-3.2.0-2.el6.x86_64.rpm
http://public-yum.oracle.com/repo/OracleLinux/OL6/addons/x86_64/getPackage/libRmath-3.2.0-2.el6.x86_64.rpm
http://public-yum.oracle.com/repo/OracleLinux/OL6/addons/x86_64/getPackage/libRmath-devel-3.2.0-2.el6.x86_64.rpm
http://public-yum.oracle.com/repo/OracleLinux/OL6/addons/x86_64/getPackage/libRmath-static-3.2.0-2.el6.x86_64.rpm
http://public-yum.oracle.com/repo/OracleLinux/OL7/addons/x86_64/getPackage/R-3.2.0-2.el7.x86_64.rpm
http://public-yum.oracle.com/repo/OracleLinux/OL7/addons/x86_64/getPackage/R-core-3.2.0-2.el7.x86_64.rpm
http://public-yum.oracle.com/repo/OracleLinux/OL7/addons/x86_64/getPackage/R-devel-3.2.0-2.el7.x86_64.rpm
http://public-yum.oracle.com/repo/OracleLinux/OL7/addons/x86_64/getPackage/libRmath-3.2.0-2.el7.x86_64.rpm
http://public-yum.oracle.com/repo/OracleLinux/OL7/addons/x86_64/getPackage/libRmath-devel-3.2.0-2.el7.x86_64.rpm
http://public-yum.oracle.com/repo/OracleLinux/OL7/addons/x86_64/getPackage/libRmath-static-3.2.0-2.el7.x86_64.rpm
再掲
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
Oracle	R	Distribution(ORD)	のインストール
Windows	の場合
• ORDをダウンロードします
– 下記のサイトからWindowsのものをダウンロードします
※OREのシステム要件(前述)を満たす必要があります
• zipを解凍して以下を実⾏します
• インストールWizardに従ってインストールします
– ⾔語、インストール先、などデフォルトのままで⼤丈夫です
72
https://oss.oracle.com/ORD/
ORD-Rversion-win.exe		
(ORD	3.2の場合 ORD-3.2-win.exe)
再掲
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
ご参考:ORD	3.2	for	windows	インストール画面
基本的に[次へ]を押してくだけです
73
再掲
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
Oracle	R	Distribution	のインストール
Red	Hat	Enterprise	Linux	の場合(1/2)
rpmbuildでソースからパッケージをbuildする必要があります
• rpmbuildのインストール (インストール済みの場合は不要です)
• ソース rpmパッケージのダウンロード
– 以下のサイトからダウンロードできます
• rpmbuild準備
74
再掲
yum install rpm-build
RHEL	6		http://public-yum.oracle.com/repo/OracleLinux/OL6/addons/x86_64/index_src.html
RHEL	7		http://public-yum.oracle.com/repo/OracleLinux/OL7/addons/x86_64/index_src.html
mkdir -p rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
Oracle	R	Distribution	のインストール
Red	Hat	Enterprise	Linux	の場合(1/2)
• ダウンロードした src.rpmファイルを SRPMS に移動
• rpmbuildの実⾏
• rpm -i でパッケージを追加します
– 出来たパッケージは rpmbuild/RPMS/x86_64/ に安置されています
75
再掲
mv R-3.2.0-2.el7.src.rpm rpmbuild/SRPMS/
rpmbuild --ebuild rpmbuild/SRPMS/R-3.2.0-2.el7.src.rpm
※OSのパッケージのインストール状
況によっては texlive, lapack,
libtiff などの必要なパッケージのイ
ンストールが要求される場合があり
ますので、適宜対応して下さい。
※場合によっては LANG=C もお試
しくださいませ
rpm -i rpmbuild/RPMS/x86_64/R-3.2.0-2.el7.x86_64.rpm
rpm -i rpmbuild/RPMS/x86_64/R-core-3.2.0-2.el7.x86_64.rpm
rpm -i rpmbuild/RPMS/x86_64/libRmath-3.2.0-2.el7.x86_64.rpm
rpm -i rpmbuild/RPMS/x86_64/libRmath-devel-3.2.0-2.el7.x86_64.rpm
rpm -i rpmbuild/RPMS/x86_64/libRmath-static-3.2.0-2.el7.x86_64.rpm
rpm -i rpmbuild/RPMS/x86_64/R-debuginfo-3.2.0-2.el7.x86_64.rpm
rpm -i rpmbuild/RPMS/x86_64/R-devel-3.2.0-2.el7.x86_64.rpm
※versionによって差異
がある場合があります
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
• ORDをダウンロードします
※OREのシステム要件(前述)を満たす必要があります
• インストールを実施します
– 上記サイトのINSTALLに詳しい記載へのリンクがあります
• マニュアルは以下になります
ご参考:Oracle	R	Distribution	のインストール
その他の場合
76
再掲
R	Enterprise	Installation	and	Administration	Guide
3.	Installing	R	for	Oracle	R	Enterprise
http://docs.oracle.com/cd/E67822_01/OREAD/install_r.htm
https://oss.oracle.com/ORD/
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
• Intel MKLはIntelの数学演算⾼速化のライブラリになります
• ORDではMKLを動的リンクし利⽤することができます
※MKLはサポート無しの無償コミュニティライセンスがあります。
※サポートが必要な場合は別途ご購⼊ください
– Linuxの場合、LD_LIBRARY_PATHにMKLのライブラリを追加するだけです
– Windowsの場合 libOrdBlasLoader.dllおよびmkl_rt.dllの場所をPATHシステム環境に追加
– DBサーバ(Linux/Windows)ではMKLがORACLE_HOME/lib以下に同梱されています
• Sys.BlasLapack()関数で有効/無効が確認できます(ORD)
ご参考:Intel	Math	Kernel	Library	(MKL)の統合
ORDのMKL統合
77
R> Sys.BlasLapack()
$vendor
[1] "Intel Math Kernel Library (Intel MKL)"
$nthreads
[1] -1
R> Sys.BlasLapack()
$vendor
[1] "R internal BLAS and LAPACK"
$nthreads
[1] 1
有効 無効
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
インストール手順全貌
78
サーバ
構築の流れ
クライアント
構築の流れ
Oracle DB
Install
Oracle
インスタンス
作成
Oracle R
Distribution
Open R
build
server script
Oracle
DB Client
Oracle R
Distribution
Open R
build
ORE Client
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
オープンソース版Rのインストール
Linux (	OEL,	RHELなど)
• CRANからRのソースコードをダウンロードします
• ダウンロードしたファイルを解凍します
• 解凍してできたディレクトリ内で以下を実⾏します(linux/OEL)
79
https://cran.r-project.org/
こちらの記載はOREの構築に必要なR
のconfigureオプションを有効化すること
だけを目的としています.
オープンソースのRのビルド手法を保証
するものではありません
./configure --with-lapack --with-ICU=no --enable-R-shlib --prefix=/usr/local/R/323
make
make install
※環境によっては configureの際にパッケージが不⾜してエラーがでることがあります
yumなどで適宜追加してください (gfortran, libXxx-devel など)
例
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
インストール手順全貌
80
サーバ
構築の流れ
クライアント
構築の流れ
Oracle DB
Install
Oracle
インスタンス
作成
Oracle R
Distribution
Open R
build
server script
Oracle
DB Client
Oracle R
Distribution
Open R
build
ORE Client
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
基本的な作業はRのパッケージをインストールするだけです
• 対象パッケージをダウンロードします
• ダウンロードしたファイルを展開します
• Rパッケージとしてインストールを⾏います
ORE	Client	のインストール
概要
81
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
• 以下から対象パッケージをダウンロードします
– Client は必須になります
– Supporting は任意になります
• ダウンロードしたzipファイルを展開するとまたアーカイブが沢⼭で
きます。これがRのパッケージになります。
– windows版は zip のパッケージ群
– Linuxの場合にはtar.gzのパッケージ群
ORE	Client	のインストール
ダウンロードと展開
82
http://www.oracle.com/technetwork/database/database-technologies/r/r-enterprise/downloads/index.html
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
• Rパッケージたちをインストールします
– 残念ながら現時点ではスクリプトなどはついていません。
– R CMD INSTALL コマンドでインストールしていくことになります
• RStudioがある場合には RStudioの[Tools]から[Install Packages] でファイル指定で
もインストールできます
• ORE 1.5に関しては次⾴以降にコピペ⽤スクリプトも⽤意しました
ORE	Client	のインストール
Rパッケージのインストール
83
$ R CMD INSTALL <アーカイブ名>
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
ご参考:ORE	Client	1.5パッケージ(コピペ用)
ORE	Client	(Windows)
• Client
• Supporting
84
R CMD INSTALL OREbase_1.5.zip
R CMD INSTALL OREcommon_1.5.zip
R CMD INSTALL OREstats_1.5.zip
R CMD INSTALL OREgraphcs_1.5.zip
R CMD INSTALL OREeda_1.5.zip
R CMD INSTALL OREembed_1.5.zip
R CMD INSTALL ORExml_1.5.zip
R CMD INSTALL OREdm_1.5.zip
R CMD INSTALL OREmodels_1.5.zip
R CMD INSTALL OREpredict_1.5.zip
R CMD INSTALL ORE_1.5.zip
R CMD INSTALL ROracle_1.2-1.zip
R CMD INSTALL arules_1.1-9.zip
R CMD INSTALL Cairo_1.5-8.zip
R CMD INSTALL DBI_0.3.1.zip
R CMD INSTALL png_0.1-7.zip
R CMD INSTALL randomForest_4.6-10.zip
R CMD INSTALL statmod_1.4.21.zip
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
ご参考:ORE	Client	1.5パッケージ(コピペ用)
ORE	Client	(Linux)
• Client
• Supporting
85
R CMD INSTALL OREbase_1.5_R_x86_64-unknown-linux-gnu.tar.gz
R CMD INSTALL OREcommon_1.5_R_x86_64-unknown-linux-gnu.tar.gz
R CMD INSTALL OREdm_1.5_R_x86_64-unknown-linux-gnu.tar.gz
R CMD INSTALL OREeda_1.5_R_x86_64-unknown-linux-gnu.tar.gz
R CMD INSTALL OREembed_1.5_R_x86_64-unknown-linux-gnu.tar.gz
R CMD INSTALL OREgraphics_1.5_R_x86_64-unknown-linux-gnu.tar.gz
R CMD INSTALL OREmodels_1.5_R_x86_64-unknown-linux-gnu.tar.gz
R CMD INSTALL OREpredict_1.5_R_x86_64-unknown-linux-gnu.tar.gz
R CMD INSTALL OREstats_1.5_R_x86_64-unknown-linux-gnu.tar.gz
R CMD INSTALL ORExml_1.5_R_x86_64-unknown-linux-gnu.tar.gz
R CMD INSTALL ORE_1.5_R_x86_64-unknown-linux-gnu.tar.gz
R CMD INSTALL Cairo_1.5-8_R_x86_64-unknown-linux-gnu.tar.gz
R CMD INSTALL DBI_0.3.1_R_x86_64-unknown-linux-gnu.tar.gz
R CMD INSTALL ROracle_1.2-1_R_x86_64-unknown-linux-gnu.tar.gz
R CMD INSTALL arules_1.1-9_R_x86_64-unknown-linux-gnu.tar.gz
R CMD INSTALL png_0.1-7_R_x86_64-unknown-linux-gnu.tar.gz
R CMD INSTALL randomForest_4.6-10_R_x86_64-unknown-linux-gnu.tar.gz
R CMD INSTALL statmod_1.4.21_R_x86_64-unknown-linux-gnu.tar.gz
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
ご参考:ORE	Client		- Clientパッケージの中身
86
Package Name Description
ORE The top-level package for Oracle R Enterprise.
OREbase Corresponds to the open source R base package.
OREcommon Contains common low-level functionality for Oracle R Enterprise
OREdm Exposes Oracle Data Mining algorithms through R.
OREeda Contains functions for exploratory data analysis.
OREembed Supports embedded R
OREgraphics Corresponds to the open source R graphics package.
OREmodels Contains functions for advanced analytical modeling.
OREpredict Enables scoring data in Oracle Database using R models.
OREstats Corresponds to the open source R stats package.
ORExml Supports XML translation between R and Oracle Database.
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
ご参考:ORE	Client		- Supporting	パッケージの中身
Package	Name Description
arules
Provides	the	infrastructure	for	representing,	manipulating,	 and	analyzing	transactional	data	and	
patterns	(frequent	 itemsets and	association	rules).
Cairo Supports	 graphic	rendering	on	Oracle	R	Enterprise	server.
DBI A	database	interface	definition	 for	communication	between	R	and	Oracle	Database.
png Supports	 the	reading	and	writing	of	PNG	images	for	Oracle	R	Enterprise	objects.
randomForest Provides	classification	and	regression	based	on	a	forest	of	trees	using	random	inputs.
ROracle Oracle	Database	interface	for	R-based	OCI.
statmod
Provides	statistical	modeling	functions,	 including	growth	curve	comparisons,	 limiting	dilution	
analysis,	mixed	linear	models,	heteroscedastic regression,	Tweedie family	generalized	linear	models,	
the	inverse-Gaussian	distribution	 and	Gauss	quadrature.
87
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
インストール手順全貌
88
サーバ
構築の流れ
クライアント
構築の流れ
Oracle DB
Install
Oracle
インスタンス
作成
Oracle R
Distribution
Open R
build
server script
Oracle
DB Client
Oracle R
Distribution
Open R
build
ORE Client
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
ORE	クライアントの確認
確認(Rコマンド)
• ore関連の関数が実⾏可能になります(RStudio起動でも可)
89
> R
Oracle Distribution of R version 3.2.0 (2012-06-22) -- "Full of Ingredients"
Copyright (C) 2012 The R Foundation for Statistical Computing
Platform: x86_64-w64-mingw32/x64 (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
You are using Oracle's distribution of R. Please contact
Oracle Support for any problems you encounter with this
distribution.
例
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
OREクライアントの確認
確認(ORE	パッケージのロードと接続)
• OREパッケージがロードできます
• oreの基本関数で接続してみます
– OREサーバの環境に合わせてuser,sid,host,password,portなどは変えてください
もし接続できない場合は、何か設定が漏れたりしている可能性があります
90
> library(ORE)
Loading required package: OREembed
Loading required package: OREstats
Loading required package: MASS
Loading required package: OREgraphics
Loading required package: OREeda
Loading required package: OREmodels
Loading required package: OREdm
Loading required package: lattice
Loading required package: OREpredict
Loading required package: ORExml
例
> ore.connect(user="oreuser",sid="ora12c", host="shiva",password="oreuser",port=1521,all=TRUE)
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
Agenda
Oracle	R	Enterprise概要
Oracle	R	Enterpriseのアーキテクチャ
Oracle	R	Enterpriseのインストール手順
まとめ
91
素材のプチッチ
http://putiya.com/
イラストわんパグ
http://www.wanpug.com/
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
まとめ
まとめ
• OREのインストール・セットアップについて記載しました
• OREはサーバ・クライアント構成になります
– 構築作業はサーバ側、クライアント側で少し違う作業になります
• Rに関しては、ORDとOSS Rが選択可能です
– OSS Rの場合、少し⼿順が複雑になります
– ORDの場合、数学関数⾼速化ライブラリのリンクも楽です
• OREサーバはserverスクリプトによって簡単に構築できます
– デフォルトでは対話型での構築になります
92
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		| 93
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
Appendix:
OREの管理について
Oracle	Data	Mining	との連携
Oracle	R	Advanced	Analytics	for	Hadoop
94
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
Oracle	R	Enterprise	アーキテクチャ
全体感:コンポーネント
95
Server	SideClient	Side
OS
Oracle	R		
Distribution
Open	R
(/w	shared	
lib,lapack..)※
Oracle		R			
Enterprise	Client			 Oracle
DB	
Client
OS
Oracle		R			
Enterprise	
supporting	
Packages		
Oracle	R		
Distribution
Open	R
(/w	shared	
lib,lapack..)※
Oracle		R			
Enterprise	Server
Oracle		R			
Enterprise	
supporting	
Packages		
Oracle	
DB
/w	
AA
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
OREの管理について
構築後にある様々なこと
• Rの管理
– Rのアップグレード等のバージョン管理
– Rパッケージの管理(OS関連含む)
• OREの管理
– アップグレード等のバージョン管理
– 埋め込みRが利⽤するメモリの制御
• ORE DBの管理
– データ容量 (quotaなど)
– OREユーザの管理
96
※CRANのバージョンと導⼊済みRのバージョ
ンの差異への対処
※Rパッケージによって必要とされるOSパッ
ケージと他のアプリケーションとの兼ね合い
※OREのバージョンアップは serverスクリプ
トで実施
※埋め込みRで利⽤されるメモリ量などはパ
ラメータ設定で制限を
※OREユーザは表の作成、データのロード、
スクリプトの保持など⾃由にオブジェクトの
作成が可能
※重い処理を流してしまうことも有りえる
※リソースマネージャtとの連携も検討
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
• 埋め込み型実⾏の際に起動される外部プロシージャの設定情報は以
下のsys.rq_config 表から確認できます
• 埋め込み型実⾏の際に利⽤されるメモリー量などの制御ができます
– sys.rqconfigsetを使います
補足:埋め込み型実行
埋め込み型実行の設定
97
SQL> SELECT * FROM sys.rq_config;
キーワード デフォルト値 説明
MIN_VSIZE 32M 最⼩のRベクター・ヒープ・メモリー
MAX_VSIZE 4G 最⼤のRベクター・ヒープ・メモリー
MIN_NSIZE 1M Rコンス・セルの最⼩値
MAX_NSIZE 20M Rコンス・セルの最⼤値
SQL> EXEC sys.rqconfigset('MIN_VSIZE', '20M');
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
Appendix:
OREの管理について
Oracle	Data	Mining	との連携
Oracle	R	Advanced	Analytics	for	Hadoop
98
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
機能 アルゴリズム 応⽤範囲
分類
Logistic Regression (GLM)
Decision Trees
Naïve Bayes
Support Vector Machines (SVM)
伝統的な統計テクニック
幅広い⽤途に利⽤可能
回帰
Linear Regression (GLM)
Support Vector Machine (SVM)
伝統的な統計テクニック
幅広い⽤途に利⽤可能
異常検出
(⾃動検知)
One Class SVM 不正検知や異常値の検出
属性重要度
Minimum Description Length (MDL)
Principal Components Analysis (PCA)
属性の絞り込み、ノイズの低減
相関ルール Apriori バスケット分析/ NBO(Next Best Offer)分析
クラスタリング
Hierarchical k-Means
Hierarchical O-Cluster
Expectation-Maximization Clustering (EM)
製品のグルーピング/ テキストマイニング
遺伝⼦-タンパク質分析
特徴抽出
Nonnegative Matrix Factorization (NMF)
Singular Value Decomposition (SVD)
テキスト分析 / 因⼦分析
Oracle	Advanced	Analytics
In-Database	Data	Mining	アルゴリズム
A1 A2 A3 A4 A5 A6 A7
F1 F2 F3 F4
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
ORE	独自関数
ORE	1.5
• モデリング
• predict
packages 関数
OREmodels ore.glm
ore.lm
ore.neural
ore.stepwise
ore.randomForest
packages 関数
OREmodels ore.predict
Class	of	Model Description	of	Model
glm Generalized	linear	model
kmeans k-Means	clustering	model
lm Linear	regression	model
matrix
A	matrix	with	no	more	than	1000	rows,	for	use	in	an	hclust	
hierarchical	clustering	model
multinom Multinomial	log-linear	model
nnet Neural	network	model
ore.model An	Oracle	R	Enterprise	model	from	the	OREModels package
prcomp Principal	components	analysis	on	a	matrix
princomp Principal	components	analysis	on	a	numeric	matrix
rpart Recursive	partitioning	and	regression	tree	model
• ore.predict対応モデル
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
OREから呼び出せるDataMining関数
ORE	1.5
101
package ORE Function Oracle	Data	Mining	Algorithm Oracle	Data	Mining	Function
OREdm ore.odmAI Minimum	Description	Length
Attribute	Importance	for	Classification	
or	Regression
ore.odmAssocRules Apriori Association	Rules
ore.odmDT Decision	Tree Classification
ore.odmGLM Generalized	Linear	Models Classification	and	Regression
ore.odmKMeans k-Means Clustering
ore.odmNB Naive	Bayes Classification
ore.odmNMF Non-Negative	Matrix	Factorization Feature	Extraction
ore.odmOC Orthogonal	Partitioning	Cluster	(O-Cluster) Clustering
ore.odmSVM Support	Vector	Machines Classification	and	Regression
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
OREdmパッケージの利用例
Support	Vector	Machine	アルゴリズムの例
x <- seq(0.1, 5, by = 0.02)
y <- log(x) + rnorm(x, sd = 0.2)
dat <-ore.push(data.frame(x=x, y=y))
# Regression
svm.mod <- ore.odmSVM(y~x,dat,"regression",
kernel.function="linear")
summary(svm.mod)
coef(svm.mod)
svm.res <-
predict(svm.mod,dat,supplemental.cols="x")
head(svm.res,6)
m <- mtcars
m$gear <- as.factor(m$gear)
m$cyl <- as.factor(m$cyl)
m$vs <- as.factor(m$vs)
m$ID <- 1:nrow(m)
MTCARS <- ore.push(m)
# Classification
svm.mod <- ore.odmSVM(gear ~ .-ID, MTCARS,"classification")
summary(svm.mod)
coef(svm.mod)
svm.res <- predict (svm.mod, MTCARS,"gear")
with(svm.res, table(gear,PREDICTION)) # generate confusion matrix
# Anomaly Detection
svm.mod <- ore.odmSVM(~ .-ID, MTCARS,"anomaly.detection")
summary(svm.mod)
svm.res <- predict (svm.mod, MTCARS, "ID")
head(svm.res)
table(svm.res$PREDICTION)
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
Appendix:
OREの管理について
Oracle	Data	Mining	との連携
Oracle	R	Advanced	Analytics	for	Hadoop
103
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
Oracle	R	Advanced	Analytics	for	Hadoop
• RとHadoopを活用した分析のためのソフトウェア
• Oracle R Advanced Analytics for Hadoopで実現する機能
1. HDFS上のデータへのR言語からのアクセス
2. Hiveを利用したデータ処理をRから透過的に利用可能
3. RからOracle提供の関数を利用し、データマイニングを分散並列処理(MapReduce、
Sparkの開発不要)
• 回帰分析、クラスタリング、主因子分析、相関分析、協調フィルタリング・・・
• MapReduceやSparkの処理を書かずともHadoopの並列分散処理の性能を享受できる
4. MapReduceをR言語で記述
5. Oracle DatabaseとHadoopの間のデータの移動をRから指示
104
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
対応アルゴリズム
• MapReduceに変換されて実行
– 共分散および相関行列計算 (orch.cov,	
orch.cor)
– 主因子分析 (orch.princomp,	orch.predict)
– K-means	クラスタリング (orch.kmeans,	
orch.predict)
– 線形回帰 (orch.lm,	orch.predict)
– 一般化線型モデル (orch.glm)
– 低ランク行列の因子分解(Low	Rank	Matrix	
Factorization)を利用した行列補完ー 協調フィ
ルタリングでの利用(orch.lmf)
– 非負行列因子分解 ー 特徴抽出で利用
(orch.nmf)
• Spark上の処理に変換されて実行
– ニューラル・ネットワーク (orch.neural)
– 一般化線型モデル (orch.glm2)
105
今後、Spark上のアルゴリズムを拡充予定
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
orch.neural Performance
• Number	of	obs 155671
Number	of	columns 46	columns
# hidden Elapsed time Elapsed time
neurons (sec) nnet (sec) orch.neural
10 934.176 44.181
20 1861.812 44.969
30 2634.434 35.196
40 3674.379 39.217
50 4400.551 49.527
• Hardware	spec: Single	BDA	node
MemTotal: 48GB
CPUs: 24	(3058MHz	each)
結果
• nnet
– hidden	neuronの数にしたがって線型に実行時間
が延びる
• orch.neural
– 1.5GB以下のデータでは、インメモリのマルチスレッ
ド実装を自動的に呼び出す
– 大量データに関しては、 MapReduceを利用
0
2000
4000
6000
10 20 30 40 50
Seconds
Number	of	Hidden	 Layer	Nodes
nnet
orch.neural
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
Sparkによる実装を利用するとさらに高速
©2013	Oracle	– All	Rights	Reserved
MapReduceによる実装に較べてSparkによる
実装を利用する100倍のオーダーで高速
https://blogs.oracle.com/R/entry/oracle_r_advanced_analytics_for
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
Architecture
Client	Host	(e.g.,	laptop)
R	engine
orhc
Hadoop	Cluster
Software
Java	VM
Server	Machine	(e.g.,	Big	Data	Appliance)
R	engine
orhc-drv package Java	VM
DBMS	Machine	(e.g.,	Exadata)
R	engine
ORE
libraries
Oracle	Database
ORE	packages
Hadoop	Cluster
TaskTracker
…
TaskTracker
JobTracker
MapReduce
nodes
HDFS	nodes
Datanode
Datanode
…
Namenode
ORE	packages
ORE	client	packagesorhc
HadoopとOracle	Databaseの間のデータの移動を
Rから指示
→	計算量の必要な処理をHadoop側にオフロード
可能
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
既知の問題
• DBにゴミがたまります
• ore.disconnect()をすると消え
るかも。
– ただ、溜まってしまっているものはRから
は消せないかも。
– drop tableで直接なら消せます....
• DM$は、、モデルの残骸
dbms_data_mining.drop_model(ʼモデ
ル名')
– モデル名は user_mining_models
ビューで確認
SQL> select * from tab ;
TNAME TABTYPE CLUSTERID
------------------------------ ------- ----------
DM$PAORE$27_572 TABLE
DM$PAORE$27_623 TABLE
.....
DM$PMORE$39_44 TABLE
DM$PMORE$45_252 TABLE
HOGE TABLE
HOGE01 TABLE
ORE$20_23 TABLE
ORE$20_25 TABLE
...........
ORE$39_39 VIEW
.........
ORE$50_697_V VIEW
ORE$50_700 TABLE
.............
ORE$5_318 TABLE
ORE$5_331 TABLE
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
ore.randomForest
ランダムフォレスト
• ORE 1.5から Oracleの実装のランダムフォレストがあります
– ランダムフォレストは決定⽊を弱学習器に利⽤したアンサンブル学習器です
– オプションの ore.parallelによって並列実⾏されます
• 簡易検証結果(58列/約25000件)
– ⼀回実⾏しただけなので結構誤差あります
110
ore.parallel 時間(s)
randomForest (	Client上のRオブジェクト) N/A 95.20	
randomForest (	ore.pull で取得) N/A 107.16	
ore.randomForest (DB表) 1 104.12
ore.randomForest (DB表) 4 53.76	
ore.randomForest (DB表) 16 40.86
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
Start	with	a	Business	Problem	Statement
Clearly	Define	Problem
“If	I	had	an	hour	to	solve	a	problem	I'd	
spend	55	minutes	thinking	about	the	
problem	and	5	minutes	thinking	about	
solutions.”
― Albert	Einstein
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
Be	Specific	in	Problem	Statement
Poorly	Defined Better Data	Mining	Technique
Predict	employees	that	leave •Based	on	past	employees	that	voluntarily left:
• Create	New	Attribute	EmplTurnover à O/1
Predict	customers	that	churn •Based	on	past	customers	that	have	churned:
• Create	New	Attribute	Churn à YES/NO
Target	“best”	customers	 •Recency,	Frequency	Monetary	(RFM)	Analysis
•Specific	Dollar	Amount	over	Time	Window:		
• Who	has	spent	$500+	in	most	recent	18	months
How	can	I	make more	$$? •What	helps	me	sell	soft	drinks	&	coffee?
Which	customers	are	likely	to	buy? •How much	is	each	customer	likely	to	spend?
Who	are	my	“best	customers”? •What	descriptive	“rules”	describe	“best	
customers”?
How	can	I	combat	fraud? •Which	transactions are	the	most	anomalous?		
• Then	roll-up	to	physician,	claimant,	employee,	etc.
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		| 113
Copyright	©	2015 Oracle	and/or	its	affiliates.	All	rights	reserved.		|
s
114
マーカー
115

Oracle R Enterprise のセットアップ