【kaggle】pystanを始めたい

kaggleではpystanができない?

何も考えずに入れようとする。

import pystan

結果だめ

 No module named 'pystan'
import stan

だめ。

バージョン指定で入れようとする

! pip install pystan==3.0.0

結果だめ。

昔のバージョンで入れようとする

! pip install pystan==2.19.1.1

結果だめ。

! python3 -m pip install pystan==3.3.0
import nest_asyncio
nest_asyncio.apply()

import stan

schools_code = """

"""

schools_data = {"J": 8,
                "y": [28,  8, -3,  7, -1,  1, 18, 12],
                "sigma": [15, 10, 16, 11,  9, 11, 10, 18]}

posterior = stan.build(schools_code, data=schools_data)
fit = posterior.sample(num_chains=4, num_samples=1000)
eta = fit["eta"]  # array with shape (8, 4000)
df = fit.to_frame()  # pandas `DataFrame, requires pandas

warningがたくさん出た上で

ValueError: The JSON document has an improper structure: missing or superfluous commas, braces, missing keys, etc.

のエラーで終了。

pystan-jypyter+pre pystanでトライ

! pip install pystan-jupyter==0.2b1
! pip install --pre pystan

結果、同じくエラー

ValueError: The JSON document has an improper structure: missing or superfluous commas, braces, missing keys, etc.

他の人がやった過去のnotebook見るとできているようで、どうやら現在のバージョンとの違いによるものと推察。

どうしたものかね。。

参考にしました

WindowsマシンでPyStan3.2.0を使う

JupyterNotebookでPystanをインストールしてもうまくいかなかったら - えい夫のお気軽データサイエンス

Frustrating problems with Pystan (anaconda Python) - PyStan - The Stan Forums

Google ColaboratoryでPyStanをいじくる - 雑記 in hibernation

PyStan の実行例【 Eight Schools】

Pip install error ModuleNotFoundError: No module named 'pystan' · Issue #401 · facebook/prophet · GitHub

【Python】ベイズ統計を実践できるPyStanのインストール | ジコログ