Open4
VS CodeでJupyterLabのノートブック拡張子を編集するための準備
インストール
- Cドライブ直下に使用するPythonバージョンのフォルダを作成する.(例
C:\Python311
) - Download Python | Python.org から開発環境をインストールする.
- インストーラーを起動して,custom installから使用するPythonバージョンのフォルダにPython環境をインストールする.
- 2つのシステム環境変数を設定する(
C:\Python311
とC:\Python311\Scripts
). - VS Code のExtention で
Python
とJupyter
,Jupyter Notebook Renderers
の拡張機能をインストールする - Terminalで
python -m ensurepip --default-pip
を入力して、pip
を有効にする。 - Terminalで
python.exe -m pip install --upgrade pip
を入力して、pipを更新する。
2024/3/27 手順の粒度を動作毎まで細かくした.
ファイル作成
-
ファイル名.ipynb
でファイルを作成する - Python環境を設定する。
- 右上の
Python/Mu(省略)
をクリック -
Select Another Kernel
をクリック -
Python Environment
をクリック - インストールしたPythonのバージョンを選択する
PyMCを使用する
Miniconda環境をインストールする
- Cドライブ直下に使用するMinicondaのフォルダを作成する.(例C:\miniconda3)
- Miniconda — Anaconda documentationをダウンロードする
- Install for -- の画面で
All Users
を選択する. - ダウンロードするフォルダ(
C:\miniconda3
)を選択する. - システム環境変数の
PATH
にC:\miniconda3\Scripts
を追加する. - VS CodeのTerminalで
conda
を実行する. -
Command Palette
でTerminal: Select Default Shell
を選び,Command Prompt
を選択する.
仮想環境を構築する
- Terminalで
conda create -c conda-forge -n pymc_env "pymc>=5" python=3.11
を実行して仮想環境を作成する. -
conda activate pymc_env
を実行して仮想環境に移る. - 必要なライブラリをインストールする
-
conda install -c conda-forge ipykernel
: VS Code -
conda install -c conda-forge nutpie
: サンプラー -
conda install -c conda-forge seaborn
: グラフ -
pip install japanize-matplotlib
: 日本語フォント -
conda install -c conda-forge polars
: DataFrame -
conda install -c conda-forge scikit-Learn
: 機械学習モデル -
conda install -c conda-forge watermark
: 使用ライブラリ表示 -
conda install -c conda-forge prettytable
: 視認性の高いprint -
conda install -c conda-forge optuna
: ハイパーパラメータ最適化-
SQLite Viewer
のVS Code拡張機能をインストールする
-
必要に応じて下記ライブラリをインストールする.
- 機械学習
-
conda install -c conda-forge lightgbm
: 高性能推定器 -
conda install -c conda-forge darts
: 時系列分析パッケージ -
conda install -c conda-forge xgboost
: 高性能推定器
-
- 深層学習
-
pip install torch
: PyTorch -
conda install -c conda-forge jax
:TensorFlow関連
-
- optunaの可視化
-
conda install -c conda-forge plotly
: optunaの結果可視化 -
conda install -c conda-forge nbformat
: optunaの結果可視化
-
- MCMC関係
-
conda install numpyro
: サンプラー -
conda install -c conda-forge bambi
: statsmodelsのようなformula
-
- 古典統計
conda install -c conda-forge statsmodels
conda install -c conda-forge fastcluster
-
conda install -c conda-forge patsy
:formula
の読み取り
-
.RData
ファイルの読込みconda install -c conda-forge rdata
- 祝日
-
conda install -c conda-forge holidays
: 祝日 -
pip install jpholiday
: 日本の祝日
-
- Excel操作
conda install -c conda-forge openpyxl
- JITコンパイラ
conda install -c conda-forge numba
- グラフ
-
conda install -c conda-forge hvplot
-
conda install -c conda-forge jupyter_bokeh
: 等高線 -
conda install -c conda-forge cartopy geoviews pyproj
: 地図への等高線オーバーラップ
-
-
conda install -c conda-forge yellowbrick
-
conda install -c conda-forge pooch
: サンプルデータ
-
-
conda install -c conda-forge ipywidgets
: インタラクティブなグラフ
-
- 欠測値可視化
conda install -c conda-forge missingno
Jupyter NotebookのPython環境を指定する
.ipynb
ファイルの右上の環境設定をクリックしてCommand Palette
のSelect Another Kernel
から仮想環境を指定する.
参考
個人的データサイエンス環境
- 仮想環境の作成:
conda create -n ds_env
- 仮想環境へ移動:
conda activate ds_env
- ライブラリのインストール:
conda install -c conda-forge ipykernel
conda install -c conda-forge numpy
conda install -c conda-forge pandas
conda install -c conda-forge polars
conda install -c conda-forge matplotlib
pip install japanize-matplotlib
conda install -c conda-forge seaborn
conda install -c conda-forge plotly
conda install -c conda-forge scikit-Learn
conda install -c conda-forge scipy
conda install -c conda-forge statsmodels
-
conda install -c conda-forge rdata
:.RData
ファイルを読み込む -
conda install -c conda-forge watermark
: 使用したライブラリ一覧を表示する. conda install -c conda-forge pyarrow
便利なcommand
- 環境一覧:
conda info -e
- 移行:
conda activate [仮想環境名]
- 離脱:
conda deactivate