安装
建议使用conda或pip进行安装。开发者可以按照下面的从源代码安装说明进行操作。如果从源代码构建,建议在conda环境中进行,然后导出环境以确保可重复性。
要使用inference.tf或inference.torch模块下的模型(例如DragonNet或CEVAE),需要额外的tensorflow或torch依赖。有关详细说明,请参见下文。
使用 conda 安装
安装 conda
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
bash Miniconda3-latest-Linux-x86_64.sh -b
source miniconda3/bin/activate
conda init
source ~/.bashrc
从 conda-forge 安装
直接从conda-forge频道使用conda安装。
conda install -c conda-forge causalml
从PyPI安装
pip install causalml
从PyPI安装带有tensorflow的causalml以支持DragonNet
pip install causalml[tf]
pip install -U numpy # this step is necessary to fix [#338](https://github.com/uber/causalml/issues/338)
从PyPI安装带有torch的causalml以使用CEVAE
pip install causalml[torch]
从源代码安装
创建一个干净的 conda 环境。
conda create -n causalml-py38 -y python=3.8
conda activate causalml-py38
conda install -c conda-forge cxx-compiler
conda install python-graphviz
conda install -c conda-forge xorg-libxrender
conda install -c conda-forge libxcrypt
然后:
git clone https://github.com/uber/causalml.git
cd causalml
pip install .
python setup.py build_ext --inplace
使用 tensorflow 为 DragonNet:
pip install .[tf]
使用 torch 进行 CEVAE:
pip install .[torch]
Windows
运行测试
在尝试运行测试之前,请确保已安装pytest。
运行所有测试:
pytest -vs tests/ --cov causalml/
添加 --runtf 和/或 --runtorch 来运行可选的 tensorflow/torch 测试,这些测试默认情况下会被跳过。
你也可以通过make运行测试:
make test