LoginSignup
1
0

More than 5 years have passed since last update.

Database for AI - Grakn.aiことはじめ part 2 .1 - Oracle Virtual Boxで学ぶGrakn Academy

Posted at

はじめに

Database for AI - Grakn.aiことはじめ part 2 - AzureにGrakn.aiをインストールしてグラフを愛でるではがっつり「Windowsでは動かない」と書いてしまったが、VMDKフォーマットで提供されているVMイメージが存在した。これでVMDKでフォーマットをサポートしているプラットフォームではWindowsであってもGraknを使うことができる。

今回はOracleのVirtual Boxを使って試してみる。

**注意

このイメージはGrakn Academyと呼ばれるセルフチュートリアルシリーズ用に用意されており、その為チュートリアル用のスキーマやルール、データ等全て入った形で提供されている。プロダクション用とではなくあくまで触ってみるという目的での使用出来る。Dockerイメージ(こちらもベータ)はここからで取得可能。

Oracle Virtual Boxにおけるセットアップ

Oracle Virtual Box

はWindows上でも動かす事の出来るLinux仮想エンジンで、ここから入手が可能。特に悩む要素は無いのでインストールについては割愛する。

Grakn Academy VM image

Grakn AcademyはGrakn Labs力作のチュートリアルシリーズで、このシリーズ専用にデータまで入ったVMイメージを元に進める形式となっている。内容としてはまだ少ないが、主要機能を一通り、かつ効率よく学ぶことが出来るのでお勧めしたい。(といいつつ私も先程終了)

Grakn Academy様のVMイメージはここから入手出来る。

イメージのロード

Grakn Academyのサイトで提供されているパッケージはVMDKファイルとOVFファイルがセットになっている。ダウンロードし展開後、Virrtual Boxのファイル>仮想アプライアンスのインポートからGRAKN.ovfを選択し実行。
loading.PNG
インポート後、イメージが仮想マシンとして登録される。

Graknの起動

イメージにはgraknというユーザー(パスワードも同じ)にて環境が構築されており、/home/grakn配下に全て入っている。特に機能制約が設けられている訳ではないので、VMが動いている限りは変更を加えたり、通常パッケージにもサンプルをインポートする事も可能。ログイン後、graknフォルダに移動後に

./grakn server start

で起動させることが出来る。

ただ、(問題がある訳では無いんだが)いつものGRAKN.AIアスキーアートが何故か表示されない。理由は不明。
server_start.PNG

Grakn Academry VMパッケージ

シナリオ

Imagine you are company that gathers information about financial products issued by oil companies. You have your knowledge graph stored with GRAKN and you have employees who browse the internet for interesting articles and add them to the knowledge base.

In 2016, a referendum in Italy has been held about the renovation of concessions on oil platforms within 18 kilometers from the coast. Had the referendum succeeded, this would have potentially affected the companies owning those platforms, and, indirectly, the financial products issued by those companies. So your employees start adding articles related to the referendum into the knowledge base.

ざっくり纏めると

石油プラットフォーム及びこれら設備の海岸からの距離と、法令に関する資料と、これらプラットフォーム関連の金融商品の関連性を調べる。

うーん、まぁいいか…

エンティティ定義

VMの中に入っていたエンティティ定義は以下の通り:

define

bond sub entity
  has name
  has risk
  plays issued
  plays affected;

article sub entity
  has subject
  has uri
  has title
  plays information;

company sub entity
  has name
  plays issuer
  plays owner
  plays located;

oil-platform sub entity
  has distance-from-coast
  has platform-id
  plays owned
  plays located
  plays affected;

country sub entity
  has name
  plays location
  plays located;

region sub entity
  has name
  plays location;

データ件数

Visualizerを立ち上げて実行した各エンティティならびにリレーション事のレコード件数は以下の通り:

match $x isa entity; aggregate count;
>> 311
match $x isa company; aggregate count;
>> 12
match $x isa oil-platform; aggregate count;
>> 100
match $x isa country; aggregate count;
>> 144
match $x isa region; aggregate count;
>> 8
match $x isa bond; aggregate count;
>> 45
match $x isa article; aggregate count;
>> 2

match $x isa owns; aggregate count;
>> 98
match $x isa issues; aggregate count;
>> 45
match $x isa located-in; aggregate count;
>> 242

おわりに

Grakn Academyをやってみると、データまで投入された形で環境まで提供されているので非常に分かりやすい。自分で追加データ投入してさらに試したり、また通常パッケージのサンプルも同じように読み込めるので、ぱっと触ってみるにはAzureよりは随分気楽にスタートできる。おすすめ。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0