0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Select AI の精度を上げる⭕

0
Last updated at Posted at 2026-03-09

はじめに

メタデータの充実で Select AI の精度が上がることを確認します。

データの用意

データは kaggle の Netflix Movies and TV Shows を使用します。
下記の要領でロードし、あえてメタデータが乏しい状態にします。

  • テーブル名: TESTTAB
  • カラム名: COL01 ~ COL12
  • TYPE列 (COL02) のデータ: Movie→1, TV Show→2 に置換
SQL> select * from testtab fetch first 5 rows only;

COL01    COL02    COL03                  COL04               COL05                                                                                                                                                  COL06            COL07           COL08 COL09    COL10      COL11                                               COL12                                                  
________ ________ ______________________ ___________________ ______________________________________________________________________________________________________________________________________________________ ________________ ____________ ________ ________ __________ ___________________________________________________ __________________________________________________________________________________________________________________________________________________________
s8240    1        The Case for Christ    Jon Gunn            Mike Vogel, Erika Christensen, Faye Dunaway, Robert Forster, Frankie Faison, Mike Pniewski                                                             United States    21-NOV-17        2017 TV-PG    113 min    Dramas, Faith & Spirituality                        Bothered by his wife's unyielding belief in Christianity, an investigative reporter sets out to use verifiable facts to poke holes in her faith.
s8241    1        The Cell               Tarek Al Eryan      Ahmed Ezz, Mohamed Mamdouh, Samer al Masri, Amina Khalil, Ahmed Safwat, Ahmed Salah Hosny, Aïcha Ben Ahmed, Rania Elkhatib, Riham Abdel Ghafour        Egypt            13-JUN-19        2017 TV-MA    126 min    Action & Adventure, Dramas, International Movies    A special operations officer vows to get revenge against the terrorist who killed his friend in a brutal attack.
s8242    1        The CEO                Kunle Afolayan      Wale Ojo, Jimmy Jean-Louis, Hilda Dokubo, Nico Panagio, Aurélie Eliam, Peter King Nzioki Mwania, Fatym Layachi, Kemi Lala Akindoju, Angélique Kidjo    Nigeria          01-SEP-19        2016 TV-14    109 min    Dramas, International Movies, Thrillers             A group of executives heads to a telecommunications retreat to pick the firm's new CEO until they find themselves in a contest to win  and stay alive.
s8243    1        The Charnel House      Craig Moss          Callum Blue, Nadine Velazquez, Makenzie Moss, Erik LaRay Harvey, Danielle Lauder, Andy Favreau, Kate Linder, Neil Thackaberry, Alden Tab               United States    04-FEB-17        2016 R        93 min     Horror Movies, Thrillers                            After an architect transforms a slaughterhouse into trendy lofts, its new inhabitants discover that the structure is haunted by its evil past.
s8245    1        The Chord              Magdy Al-Hawwary    Mostafa Shaban, Ghada Adel, Arwa Gouda, Ahmed Salah Al-Saadany, Ashraf Zaki, Sawsan Badr, Fatma Nasser, Said Saleh, Ali Hassanein, Majed Abdulazim     Egypt            20-JUN-19        2010 TV-MA    101 min    Dramas, International Movies, Music & Musicals      A detective investigates the murder of a young musician, whose philandering lifestyle leaves a long list of suspects and a lot of questions.

SQL>

Select AI での問い合わせ (メタデータ充実前)

テーブル名やカラム名から意味を排している状態のため、
Select AI で問い合わせを行っても期待した問い合わせになりません。

SQL> select ai NETFLIXで配信されている作品の数;

   number_of_works
__________________
                 0

SQL> select ai showsql NETFLIXで配信されている作品の数;

RESPONSE
____________________________________________
SELECT COUNT(*) AS "NumberOfWorks"
FROM "TESTUSER2"."TESTTAB" t
WHERE UPPER(t."COL01") = UPPER('NETFLIX')

SQL> select ai NETFLIXで配信されている作品のうち、映画の数;

   MOVIE_COUNT
______________
             0

SQL> select ai showsql NETFLIXで配信されている作品のうち、映画の数;

RESPONSE
____________________________________________
SELECT COUNT(*) AS movie_count
FROM "TESTUSER2"."TESTTAB" t
WHERE UPPER(t."COL03") = UPPER('NETFLIX')
AND UPPER(t."COL02") = UPPER('映画')

Select AI での問い合わせ (メタデータ充実後)

テーブル名・カラム名は変更せず、それぞれにコメントを追加する貌でメタデータを充実させます。

↓古いですが参考

SQL> comment on table testtab is 'Listings of movies and tv shows on Netflix';

Comment created.

SQL> comment on column testtab.col01 is 'Unique ID for every Movie / Tv Show';

Comment created.

SQL> comment on column testtab.col02 is 'Identifier - A Movie (1) or TV Show (2)';

Comment created.

SQL> comment on column testtab.col03 is 'Title of the Movie / Tv Show';

Comment created.

SQL> comment on column testtab.col04 is 'Director of the Movie';

Comment created.

SQL> comment on column testtab.col05 is 'Actors involved in the movie / show';

Comment created.

SQL> comment on column testtab.col06 is 'Country where the movie / show was produced';

Comment created.

SQL> comment on column testtab.col07 is 'Date it was added on Netflix';

Comment created.

SQL> comment on column testtab.col08 is 'Actual Release year of the move / show';

Comment created.

SQL> comment on column testtab.col09 is 'TV Rating of the movie / show';

Comment created.

SQL> comment on column testtab.col10 is 'Total Duration - in minutes or number of seasons';

Comment created.

SQL> comment on column testtab.col11 is 'Genere';

Comment created.

SQL> comment on column testtab.col12 is 'The summary description';

Comment created.

SQL> select * from user_tab_comments where table_name='TESTTAB';

TABLE_NAME    TABLE_TYPE    COMMENTS                                         ORIGIN_CON_ID
_____________ _____________ _____________________________________________ ________________
TESTTAB       TABLE         Listings of movies and tv shows on Netflix                 109

SQL> select * from user_col_comments where table_name='TESTTAB';

TABLE_NAME    COLUMN_NAME    COMMENTS                                               ORIGIN_CON_ID
_____________ ______________ ___________________________________________________ ________________
TESTTAB       COL01          Unique ID for every Movie / Tv Show                              109
TESTTAB       COL02          Identifier - A Movie (1) or TV Show (2)                          109
TESTTAB       COL03          Title of the Movie / Tv Show                                     109
TESTTAB       COL04          Director of the Movie                                            109
TESTTAB       COL05          Actors involved in the movie / show                              109
TESTTAB       COL06          Country where the movie / show was produced                      109
TESTTAB       COL07          Date it was added on Netflix                                     109
TESTTAB       COL08          Actual Release year of the move / show                           109
TESTTAB       COL09          TV Rating of the movie / show                                    109
TESTTAB       COL10          Total Duration - in minutes or number of seasons                 109
TESTTAB       COL11          Genere                                                           109
TESTTAB       COL12          The summary description                                          109

12 rows selected.

SQL>

改めて Select AI で問い合わせを行うと、期待した問い合わせになりました。
AIプロファイル作成時 (DBMS_CLOUD_AI.CREATE_PROFILE)、"comments":"true"を指定していないとコメントは読み込まれませんので注意しましょう。

SQL> select ai NETFLIXで配信されている作品の数は;

   Number_of_Works
__________________
              8806

SQL> select ai showsql NETFLIXで配信されている作品の数は;

RESPONSE
_______________________________________
SELECT COUNT(*) AS "Number_of_Works"
FROM "TESTUSER2"."TESTTAB"

SQL> select ai NETFLIXで配信されている作品のうち、映画の数は;

   MOVIE_COUNT
______________
          6129

SQL> select ai showsql NETFLIXで配信されている作品のうち、映画の数は;

RESPONSE
______________________________________
SELECT COUNT(*) AS "Movie_Count"
FROM "TESTUSER2"."TESTTAB" T
WHERE UPPER(T."COL02") = UPPER('1')

SQL>

26ai で追加された annotation をメタデータとして読み込ませることも可能です。("annotations":"true")

また、annotation は VS Code の拡張機能である Oracle SQL Developer for VS Code から GUI で管理することが可能です。(AIエンリッチメント)

AI がデータを利活用する際は、人間が利活用する際と同様、メタデータをできるだけ充実させましょう:bar_chart:

0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?