CmdStanPyã®ã¤ã³ã¹ãã¼ã«
MCMCã®ã©ã¤ãã©ãªã¨ãã¦æã¯PyMC3ã使ã£ã¦ãã¾ããããä»æ§ãã³ãã³ãå¤ãã£ãããTensorFlowãã¼ã¹ã«ãªãäºå®ã ã£ãPyMC4ãéçºä¸æ¢ãããã¨ãä½ãã¨æªãå°è±¡ãããã¾ããããããªããã§ãåå¹´åãããããStanã«åãæ¿ãã¾ãããRã®Stanãcolaboratoryä¸ããPyStanã使ã£ã¦ãã¾ãããStanã¯ä½¿ããããã¦ãããªããªãã¦æããªãããã°ãã使ã£ã¦ãã¾ããããæè¿CmdStanPyã¨ããã®ãè¦ã¤ãã¦ãã¤ã³ã¹ãã¼ã«ãããã¨ãã¾ãããCmdStanPyã¨ããã®ã¯ä¸è¨ã®ãã®ã§ãã
www.wenyanet.com
å
¬å¼ããã¥ã¡ã³ãã«æ²¿ã£ã¦ã¤ã³ã¹ãã¼ã«ããã¤ããã§ãããè¦æ¦ãã¾ããã
StanãPythonã§å¼ã³åºããã¨ããã¨ä½ãã¨è¦å´ããå°è±¡ã§ããããããã°ãä½å¹´ãåã«MCMCã®åå¼·ä¼ãããã¾ãããPythonã¦ã¼ã¶ã¯PyStanã使ããã¨é å¼µãã¾ããããçµå±ã¤ã³ã¹ãã¼ã«ã§ãã人ã¯å±
ãªãã£ãæ°ãã»ã»ã»ãPythonã¦ã¼ã¶ã¯è«¦ãã¦reticulateã§Rã®Stanãå¼ã³åºãã¦ãã¾ãããï¼ãã®æã¯ç§ã¯PyMC3ã使ã£ã¦ãã¾ããï¼
ä¾ã«å£ã£ã¦CmdStanPyã®ã¤ã³ã¹ãã¼ã«ããããªãè¡ãã¾ããã§ããããããã試è¡é¯èª¤ããçµæãããããªæ¹æ³ã模索ããã®ã§ãã¡ã¢ãã¦ããã¾ãã
ã¤ã³ã¹ãã¼ã«
ãã¹ã¯ãããã«ã¤ã³ã¹ãã¼ã«
ç§ã®ãã¹ã¯ãããç°å¢ã¯ä¸è¨ã®ã¨ããã§ã
- Windows11
- python 3.7.11
æé ã¨ãã¦ã¯æåã«cmdstanpyãã¤ã³ã¹ãã¼ã«ãã¦ããã次ã«cmdstanãã¤ã³ã¹ãã¼ã«ããããã§ãã
ã¾ãã¯ã¿ã¼ããã«ããconda-forge
ã§CmdStanPyãã¤ã³ã¹ãã¼ã«ãã¾ãããã¨ãããconda-forge
ããã¯ã¤ã³ã¹ãã¼ã«åºæ¥ã¾ãããpip
ããã§ã¯ã¤ã³ã¹ãã¼ã«ã§ãã¾ããã§ãããã³ãã³ãã¯ä¸è¨ã®ã¨ããã§ãã
conda install -c conda-forge cmdstanpy
ãã®æ¬¡ã«ãä¸è¨ã®ããã«Cãªãã·ã§ã³ã使ã£ã¦CmdStanãã¤ã³ã¹ãã¼ã«ãã¾ããã
python -c 'import cmdstanpy; cmdstanpy.install_cmdstan()'
ãããã¯ã
python -m cmdstanpy.install_cmdstan
ããã§ãªãã¨ãè¡ãã¾ããã
試ãããã¨
ãããªãã¤ã³ã¹ãã¼ã«åºæ¥ãããã§ã¯ãªããè²ã
ã¨è©¦è¡é¯èª¤ãã¾ããã
pip
ããcmdstanpyãã¤ã³ã¹ãã¼ã«ããã¨ã次段éã®cmdstanãã¤ã³ã¹ãã¼ã«åºæ¥ã¾ãããåå ä¸æã§ãã
ãªã®ã§ã公式ドキュメントã«æ¸ãã¦ããã
pip install --upgrade cmdstanpy
ã¨ã
pip install --upgrade cmdstanpy[all]
ããã¤ã³ã¹ãã¼ã«ããã¨ã次段éã®cmdstanãã¤ã³ã¹ãã¼ã«ããéã«ãããã¡ã¤ã«ãããã¾ãããã¨ãããããªã¨ã©ã¼ãåºåããã¾ãã
ä¸è¨ãåãã§ãã
install_cmdstan
åããPythonããä¸è¨ãå¼ã³åºãã¦ããã¡ã§ããã
import cmdstanpy cmdstanpy.install_cmdstan()
ãªãé§ç®ãªã®ãã½ã¼ã¹ã³ã¼ããè¦ã¦ã¿ã¾ãããã段ã é¢åã«ãªã£ã¦ãã¦ããã¾ããã
Dockerãå©ç¨ãã¦ã¤ã³ã¹ãã¼ã«ãã
('23/1/5追è¨)
Cmdstanpyãåã¤ã³ã¹ãã¼ã«ããã¨ããããã¼ã«ã«ã®ç°å¢ããã¡ããã¡ãã«ãªã£ã¦ãã¾ãã¾ããã»ã»ã»ãããããã®ã«æéãåãããã®ãå«ãªã®ã§ãDockerä¸ã«ã¤ã³ã¹ãã¼ã«ãã¾ããã¨ãããDockerä¸ã«ã¤ã³ã¹ãã¼ã«ããã®ãä¸çªæ¥½ã ã¨æãã¾ãã
å·»æ«ã®åèï¼ãåç
§ãã¦Dockerfileãä¸è¨ã®ããã«æ¸ãã¦ã¤ã³ã¹ãã¼ã«ãã¾ãããåèå
ã¯ubuntuã®ã¤ã¡ã¼ã¸ã使ã£ã¦ãã¾ãããç§ã¯minicondaã使ãã¾ããã
FROM continuumio/miniconda3 # conda create RUN conda create -n chemodel python==3.9 # install conda package RUN conda install -c conda-forge cmdstanpy=1.0.4 RUN conda install -c conda-forge cmdstan=2.30.0