ヘッダーをスキップ
Oracle® Textアプリケーション開発者ガイド
12cリリース1 (12.1)
B71317-04
  目次へ移動
目次
索引へ移動
索引

前
次
 

SVMベース管理型分類の例

次の例ではSVMベース分類を使用します。基本的には意思決定ツリーの例と同じ手順を使用しています。ただし、次の違いがあります。

SVMベース管理型分類を作成するには、次の手順を実行します。

  1. トレーニング・ドキュメント表の作成および移入

    create table doc (id number primary key, text varchar2(2000));
    insert into doc values(1,'1 2 3 4 5 6');
    insert into doc values(2,'3 4 7 8 9 0');
    insert into doc values(3,'a b c d e f');
    insert into doc values(4,'g h i j k l m n o p q r');
    insert into doc values(5,'g h i j k s t u v w x y z');
    
  2. カテゴリ表の作成および移入

    create table testcategory (
            doc_id number, 
            cat_id number, 
            cat_name varchar2(100)
             );
    insert into testcategory values (1,1,'number');
    insert into testcategory values (2,1,'number');
    insert into testcategory values (3,2,'letter');
    insert into testcategory values (4,2,'letter');
    insert into testcategory values (5,2,'letter');
    
  3. ドキュメント表のCONTEXT索引の作成

    この場合、移入せずに索引を作成します。

    create index docx on doc(text) indextype is ctxsys.context 
           parameters('nopopulate');
    
  4. SVM_CLASSIFIERの設定

    これは、CTX.CLS_TRAINでも可能です。

    exec ctx_ddl.create_preference('my_classifier','SVM_CLASSIFIER'); 
    exec ctx_ddl.set_attribute('my_classifier','MAX_FEATURES','100');
    
  5. 結果(ルール)表の作成

    create table restab (
      cat_id number,
      type number(3) not null,
      rule blob
     );
    
  6. トレーニングの実行

    exec ctx_cls.train('docx', 'id','testcategory','doc_id','cat_id',
         'restab','my_classifier');
    
  7. ルール表のCTXRULE索引の作成

    exec ctx_ddl.create_preference('my_filter','NULL_FILTER');
    create index restabx on restab (rule) 
           indextype is ctxsys.ctxrule 
           parameters ('filter my_filter classifier my_classifier');
    

ここで、2つの未知のドキュメントを分類できます。

select cat_id, match_score(1) from restab 
       where matches(rule, '4 5 6',1)>50;

select cat_id, match_score(1) from restab 
       where matches(rule, 'f h j',1)>50;

drop table doc;
drop table testcategory;
drop table restab;
exec ctx_ddl.drop_preference('my_classifier');
exec ctx_ddl.drop_preference('my_filter');