【SPSS】ModelerのPythonにパッケージをインストールする方法 ~Mac編~

【SPSS】ModelerのPythonにパッケージをインストールする方法 ~Mac編~

IBM SPSS Modelerでは、Pythonが一緒にインストールされ(Ver.18.1以降)、Modeler上でPythonを使えます。
マニュアルによると、そのPythonにパッケージ*が追加できるとのこと。

そこで、Modelerのpythonnにパッケージをインストールする方法を試行錯誤しましたので、備忘録を残します。

Windows編はこちら

実行環境

  • IBM SPSS Modeler Client 18.3
  • Python 3.8.6 ※Modeler同梱
  • Mac OS Big Sur 11.6.1

手順

コマンドプロンプトでModelerのpython3をフルパス指定し、pipでインストール
<コマンド例>

"/Applications/IBM/SPSS/Modeler/18.3/IBM SPSS Modeler.app/Contents/python/bin/python3" -m pip install パッケージ名

以上

おまけ:インストール済みのパッケージを確認するには、同様にフルパス指定してpip listで確認
<コマンド例>

"/Applications/IBM/SPSS/Modeler/18.3/IBM SPSS Modeler.app/Contents/python/bin/python3" -m pip list

<実行結果>
こちらはデフォルトの状態
pandasやmatplotlib、sklearnなど、よく使われるものがあらかじめインストールされています。

Package          Version
---------------- ---------
certifi          2020.12.5
chardet          3.0.4
cycler           0.10.0
Cython           0.29.21
deap             1.3.1
hdbscan          0.8.26
idna             2.10
imbalanced-learn 0.7.0
imblearn         0.0
joblib           0.17.0
kiwisolver       1.3.1
matplotlib       3.3.3
nose             1.3.7
numpy            1.19.4
pandas           1.1.4
Pillow           8.0.1
pip              20.3.1
ply              3.11
Pyomo            5.7.1
pyparsing        2.4.7
python-dateutil  2.8.1
pytz             2020.4
PyUtilib         6.0.0
requests         2.25.0
scikit-learn     0.23.2
scipy            1.5.4
setuptools       49.2.1
six              1.15.0
sklearn          0.0
stopit           1.1.2
threadpoolctl    2.1.0
TPOT             0.11.5
tqdm             4.54.1
update-checker   0.18.0
urllib3          1.26.2
xgboost          0.82


Modeler用にわざわざPythonをインストールしなくて済みますので、おススメです。

※参考
https://packaging.python.org/en/latest/tutorials/installing-packages/
https://docs.python.org/ja/3/installing/index.html
https://www.ibm.com/docs/ja/spss-modeler/18.3.0?topic=spark-scripting-python