ä»åã¯ãOSSã®Optunaã®å®è¡çµæãå¯è¦åãããOptuna DashboardããããGoogle Colaboratoryãã§ä½¿ãæ¹æ³ã説æãã¾ãã
ä»åã®ä½¿ãæ¹ã¯ãGoogle Colaboratoryã§Optuna Dashboardãèµ·åï¼ãµã¼ããèµ·åï¼ãããã©ã¦ã¶ããOptuna Dashboardã使ããã¨ãããã®ã§ãã
æå
ã«Linuxãããã°ãã³ãã³ãã©ã¤ã³ããOptuna Dashboardãèµ·åãã¦ããã©ã¦ã¶ã§ã¢ã¯ã»ã¹ããã¨æ®éã«ä½¿ãã¾ããããã§ã¯ãæå
ã«Linuxãç¡ããGoogle Colaboratoryã§Optunaãå®è¡ãã¦ããç¶æ³ã§ãOptuna Dashboardã使ããã¨ãæ³å®ãã¦ãã¾ãã
ãã®å
容ãåèã«ãªãã°å¹¸ãã§ãã
ãOptunaã
åèæç®
åèãµã¤ã
âOptunaã®å
¬å¼ãµã¤ã
www.preferred.jp
âOptuna Dashboardã®ããã¥ã¡ã³ãï¼ããã¥ã¢ã«ï¼
optuna-dashboard.readthedocs.io
ã¯ããã«
Optunaã®è¨äºä¸è¦§ã§ããè¯ãã£ããåèã«ãã¦ãã ããã
Optunaã®è¨äºä¸è¦§
ããã§ã¯ãã¹ã¿ãã£ãä¿åããã¹ãã¬ã¼ã¸ãå¿
è¦ã«ãªãã¾ãã
以ä¸ã§ã¯ãsqlite:///optuna.db
ã¨ãã¦ããã®ã§ãé©å®èªã¿æ¿ãã¦ãã ããã
ãch2-rfãã®å¦ç¿ãè¨é²ãããoptuna.dbãã以ä¸ãããã¦ã³ãã¼ãé ãã¾ãã
https://github.com/dk0893/optuna-book/raw/master/chapter2/optuna.db
Google Colaboratoryã§ãOptuna Dashboardãèµ·åããæ¹æ³
Google Colaboratoryã§ãOptuna Dashboardã使ç¨ããæ¹æ³ã«ã¤ãã¦èª¬æãã¾ãã
以ä¸ã§ã2ã¤ã®æ¹æ³ãç´¹ä»ãã¦ãã¾ãããã¾ããå
¬å¼ãµã¤ãã®æ¹æ³ã§è©¦ãã¾ãã
ããããã¾ããããªãã£ãå ´åã¯ãStack overflowã§åçããã¦ããå
容ã試ãã¨ããã¨æãã¾ãã
å
¬å¼ãµã¤ãã®æ¹æ³ã§ãOptuna Dashboardãèµ·åãã
Optuna Dashboardã®å
¬å¼ãµã¤ãï¼ããã¥ã¢ã«ï¼ã«ãGoogle Colaboratoryã¨ããé
ç®ãããã¾ãã
ããã«æ¸ããã¦ããã½ã¼ã¹ã³ã¼ãã¯ä»¥ä¸ã®éãã§ãããã1ã¤ã®Google Colaboratoryã®ã»ã«ã§å®è¡ãã¾ãã
å
¬å¼ã®ã½ã¼ã¹ã³ã¼ãã«ã¯ã¹ã¿ãã£ãå®è¡ããã³ã¼ããå«ã¾ãã¦ãã¾ãããããã§ã¯ãOptuna Dashboardãèµ·åããé¨åã ãã«ãã¦ãã¾ãã
ãã¼ãçªå·ã®æå®ã¨ããã¼ã¿ãã¼ã¹ãã¡ã¤ã«ã®æå®ããå¿
è¦ã«å¿ãã¦å¤æ´ãã¾ãã
import optuna
import threading
from google.colab import output
from optuna_dashboard import run_server
port = 8081
storage = optuna.storages.RDBStorage("sqlite:///optuna.db")
thread = threading.Thread(target=run_server, args=(storage,), kwargs={"port": port})
thread.start()
output.serve_kernel_port_as_window(port, path='/dashboard/')
å®è¡çµæ
https://localhost:8081/dashboard/
Bottle v0.12.25 server starting up (using WSGIRefServer())...
Listening on http://localhost:8081/
Hit Ctrl-C to quit.
https://localhost:8081/dashboard/
ããªã³ã¯ã«ãªã£ã¦ããã®ã§ããããã¯ãªãã¯ããã¨ããã©ã¦ã¶ã®å¥ã®ã¦ã£ã³ãã¦ã§ãOptuna Dashboardãèµ·åãã¾ãã
Stack overflowã«æ¸ããã¦ããæ¹æ³ã§ãOptuna Dashboardãèµ·åãã
Stack overflowã®è¨äºï¼https://stackoverflow.com/questions/76033104/launching-optuna-dashboard-in-google-colaboratoryï¼ã«ãOptuna Dashboardã®éçºè
ã®æ¹ããGoogle Colaboratoryã§Optuna Dashboardã使ãæ¹æ³ãåçãã¦ãã¾ããã
ããã«è¨è¼ããã¦ããã½ã¼ã¹ã³ã¼ãã¯ä»¥ä¸ã®éãã§ãããã1ã¤ã®Google Colaboratoryã®ã»ã«ã§å®è¡ãã¾ãã
å
¬å¼ãµã¤ãã®æ¹æ³ã¨åæ§ã«ããã¼ãçªå·ã®æå®ã¨ããã¼ã¿ãã¼ã¹ãã¡ã¤ã«ã®æå®ã¯ãå¿
è¦ã«å¿ãã¦å¤æ´ãã¾ãã
import optuna
import time
import threading
from optuna_dashboard import wsgi
from wsgiref.simple_server import make_server
port = 8081
storage = optuna.storages.RDBStorage("sqlite:///optuna.db")
app = wsgi(storage)
httpd = make_server("localhost", port, app)
thread = threading.Thread(target=httpd.serve_forever)
thread.start()
time.sleep(3)
from google.colab import output
output.serve_kernel_port_as_window(port, path='/dashboard/')
å®è¡çµæ
https://localhost:8081/dashboard/
ä¸è¨ã¯ãªã³ã¯ã«ãªã£ã¦ããã®ã§ããããã¯ãªãã¯ããã¨ããã©ã¦ã¶ã®å¥ã®ã¦ã£ã³ãã¦ã§ãOptuna Dashboardãèµ·åãã¾ãã
Optuna Dashboardã®ä½¿ãæ¹
éå»ã®è¨äºã§æé©åããã¹ã¿ãã£ã®ãch2-rfããéãã¦ã¿ã¾ãã
historyç»é¢
ä¸çªä¸ã®Historyã¯ã200åã®ãã©ã¤ã¢ã«ã®è©ä¾¡çµæï¼åé¡ç²¾åº¦ï¼ãããããããã赤ç·ã¯ç²¾åº¦ã®æé«å¤ãçµãã ãã®ã¨ãªã£ã¦ãã¾ããæ©ã段éã§ãã»ã¼æé«ç¹ã«éãã¦ãããã¨ãåããã¾ãã
次ã®å·¦å´ã®Hyperparameter Importanceã¯ãã©ã®ãã¤ãã¼ãã©ã¡ã¼ã¿ãéè¦ã ã£ãããå¯è¦åããã¦ãã¾ããmax_depth
ããããmin_samples_split
ã®æ¹ããåé¡ç²¾åº¦ã«ã¯éè¦ãªãã¤ãã¼ãã©ã¡ã¼ã¿ã ã£ãã¨ãããã¨ã«ãªãã¾ãã
ãã®å³å´ã®Timelineã¯ããã©ã¤ã¢ã«ã®å¦çæéãå¯è¦åããã¦ãããã©ã®ãã©ã¤ã¢ã«ããå¦çæéã¨ãã¦ã¯å¤§ããå¤ããããªãã£ããã¨ãåããã¾ãã
æå¾ã«ãå·¦ä¸ã®Best Trialã¯ã92åç®ã®æé«ç²¾åº¦ã表示ããã¦ãã¾ãã
Analyticsã®ç»é¢
ç¶ãã¦ãAnalyticsã®ç»é¢ã§ãã
Hyperparameter Relationships
Hyperparameter Relationshipsã¨æ¸ããã¦ãã°ã©ãã§ã¯ã横軸ã«é¸æãããã¤ãã¼ãã©ã¡ã¼ã¿ã縦軸ã«è©ä¾¡å¤ã®æ£å¸å³ã§ããParameterã®ã¨ããã§ããã¤ãã¼ãã©ã¡ã¼ã¿ãå¤æ´ãããã¨ãã§ãã¾ãã
ãã®å³ã§ã¯ããmax_depthããé¸æããã¦ãã¦ããµã³ãã«ãããå¤ãå¤åãã¦ããè©ä¾¡å¤ã¯ä¾åãã¦ããªããã¨ãåããã¾ããå
ã»ã©ã®éè¦åº¦ãå°ããã£ãçç±ã§ããã
ä¸æ¹ã§ã以ä¸ã¯ããmin_samples_splitããé¸æããã¨ãã®å³ã«ãªãã¾ãã
ãmin_samples_splitããå°ããå¤ã«ãªãã»ã©ãè©ä¾¡å¤ãé«ããªã£ã¦ãããã¨ãåããã¾ãããã®ãã¤ãã¼ãã©ã¡ã¼ã¿ã«ãã£ã¦è©ä¾¡å¤ãå·¦å³ããã¦ããã®ã§ãéè¦åº¦ãé«ãã¨å¤å®ãããã¨ãããã¨ã«ãªãã¾ãã
Parallel Coordinate
ä¸ã®å³ã®Parallel Coordinateã¯ã並è¡åº§æ¨ã®ããããã§ãé«æ¬¡å
ãã¼ã¿ã2次å
ã§è¡¨ç¾ããå¯è¦åæ¹æ³ã§ãã
横軸ã¯ãå·¦ãããObjective 0ãããmax_depthãããmin_samples_splitãã¨ãªã£ã¦ãã¾ãããObjective 0ãã¯è©ä¾¡å¤ã§ãã0ãä»ãã¦ããçç±ã¯ãä»åã¯è©ä¾¡å¤ã1ã¤ããããã¾ããããå¤ç®çæé©åã§ã¯è©ä¾¡å¤ãè¤æ°åå¨ããããããèå¥ããçªå·ã«ãªãã¾ãã
è¦æ¹ã¨ãã¦ã¯ãè©ä¾¡å¤ãé«ãã»ã©ãæ¿ãéè²ã§ç¤ºããã¦ãã¾ãããObjective 0ããé«ãã¨ãã®ãã©ã¡ã¼ã¿ã¯ãåãã©ã¡ã¼ã¿ã«ããã¦ãã©ã®ãããã®å¤ãããã®ãã確èªãããã¨ãåºæ¥ã¾ããä¾ãã°ããObjective 0ããé«ãã¨ããããå³ã«é²ãã¨ããmax_depthãã®å¤§ããªå¤ã®ã¨ããã«ã¤ãªãã£ã¦ãã¾ãããmax_depthããé«ãå¤ã®æ¹ããè©ä¾¡å¤ãé«ããªã£ã¦ããã¨ãããã¨ãåããã¾ããä¸æ¹ãããã«å³ã«é²ãã¨ããmin_samples_splitãã¯å°ããªå¤ã«ã¤ãªãã£ã¦ãã¾ãããmin_samples_splitãã¯å°ããå¤ã®æ¹ããè©ä¾¡å¤ãé«ããªããã¨ãåããã¾ãã
Contour
ä¸ã®å³ã®Contourã¯çé«ç·å³ã§ãã
çé«ç·å³ã§ã¯ãé¸æãã2ã¤ã®ãã©ã¡ã¼ã¿ã«ã¤ãã¦ãè©ä¾¡å¤ã®é«ãã®å½¢ç¶ãåããã¾ãããã®å ´åã¯ããmin_samples_splitããä½ãå¤ã»ã©ãè©ä¾¡å¤ãé«ããªããã¨ãåãããä¸æ¹ã§ããmax_depthãã¯ãé«ãå¤ã®æ¹ãè©ä¾¡å¤ã¯é«ãã§ãããä½ãå¤ã¨ãããã¾ã§å·®ã¯ãªãã¨ãããã¨ãåããã¾ãã
Rank
ä¸ã®å³ã¯Rankã§ãã
ã©ãããç®çã®ã°ã©ããã¯åããã¾ããããå³ãè²¼ã£ã¦ããã¾ããçé«ç·å³ã¨ä¼¼ã¦ã¾ããã
Empirical Distribution of the Objective Valueï¼EDFï¼
ä¸ã®å³ã¯EDFã§ãã
å
¨ç¶ç¥ããªãã®ã§ããã横軸ãè©ä¾¡å¤ã縦軸ãèç©ç¢ºçã¨ãªã£ã¦ãã¾ããå³ã®æ¹ã§æ¥æ¿ã«ä¸ãã£ã¦ããã®ã¯ããã©ã¤ã¢ã«ã®å¤ãããé«ãè©ä¾¡å¤ãåºãã¦ãããã¨ã示ãã¦ããã®ã ã¨æãã¾ãã
Trials (List) ã®ç»é¢
ç¶ãã¦ãTrials (List) ã®ç»é¢ã§ãã
åãã©ã¤ã¢ã«ã®è©³ç´°ãªçµæã確èªã§ãã¾ãã
ç»é¢ä¸é¨ã¯ãMarkdownããHTMLã§ãã¼ãï¼ã¡ã¢ï¼ãè¨å
¥ã§ããããã§ããããã®ã¨ãã¯ããªããã¨ã©ã¼ãåºã¦æ¸ãã¾ããã§ããã
Trials (Table) ã®ç»é¢
ç¶ãã¦ãTrials (Table) ã®ç»é¢ã§ãã
åãã©ã¤ã¢ã«ã®çµæãä¸è¦§ã«ãªã£ã¦ãã¾ããå³ç«¯ã®åã®ãªã³ã¯ãã¼ã¯ãã¯ãªãã¯ããã¨ãTrials (List) ã«ã¸ã£ã³ããã¾ããã
Optuna Dashboardã§ããã¼ã¿ãã¼ã¹ãå¤æ´ã§ããã¨æ¸ãã¦ãã£ãã¨æãã®ã§ãããå¤æ´ããæ¹æ³ãåããã¾ããã§ããã
5çªç®ã¯ãã¼ãã®ç»é¢ã§ãèªç±ã«ã¡ã¢ã§ããããã§ããã
ä»åã¯ä»¥ä¸ã§ãï¼