Skip to main content

No project description provided

Project description

uplift_kit

This package currently implements the UpliftRandomForest algorithm, and may implement more machine learning algorithm designed for uplift modeling.

Motivation: I tried the UpliftRandomForestModel implemented in calsalml, and it generally outperforms other algorithms like t-learner/x-learner. But unfortunately, causalml's implementation in python is slow and memory-consuming, which makes the training procedure rather painful.

So I implement the UpliftRandomForest algorithm in Rust and provide a python API. In my test, it is 10x~20x faster than causalml' implementation and consumes much less memory.

Usage

Make sure Rust stable version is installed on your device. If not, follow the installation guide to get stable Rust.

Currently uplift_kit hasn't been published on Pypi, you can try it in a pipenv environment. And we use maturin to build python package for Rust program.

# you may install pipenv and maturin first
pip install pipenv
pip install maturin
# activate virtualenv in current dir
pipenv shell
# compile
maturin develop --release

Basic usage example:

import uplift_kit

model = uplift_kit.UpliftRandomForestModel(
    n_estimators=10,
    max_features=10,
    max_depth=10,
    min_sample_leaf=100,
    eval_func="KL",
    max_bins=10,
    balance=True,
    regularization=True,
    alpha=0.9,
)

model.fit(
    data_file="train.parquet",
    treatment_col="is_treated",
    outcome_col="outcome",
    n_threads=8,
)

res = model.predict(data_file="test.parquet", n_threads=8)
print(res[:10])

Currently we can only use parquet files for train and predict, values in treatment_col must be [0,1,2...], where 0 represents control sample, [1,2...k] indicates k types of treatment. outcome_col indicates the outcome of treatments/control, must be 0/1 (binary outcome).

The predict method returns the uplift value of each treatment as a List[List[float]]. res[i][k] represents the uplift value for item i with treatment k.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

uplift_kit-0.1.0.tar.gz (26.9 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

uplift_kit-0.1.0-cp37-abi3-win_amd64.whl (8.6 MB view details)

Uploaded CPython 3.7+Windows x86-64

uplift_kit-0.1.0-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (8.5 MB view details)

Uploaded CPython 3.7+manylinux: glibc 2.17+ x86-64

File details

Details for the file uplift_kit-0.1.0.tar.gz.

File metadata

  • Download URL: uplift_kit-0.1.0.tar.gz
  • Upload date:
  • Size: 26.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/0.14.12

File hashes

Hashes for uplift_kit-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c3ca765195920cd364772c820d7ff825cd672d17a03db83533fa0219cd81a9a4
MD5 9b3dbd5ddef15521a772fa76cc23301e
BLAKE2b-256 a6869db48bf4ce8b451b587c245cd708e98f4845d8c065a166596e4a2419fb9c

See more details on using hashes here.

File details

Details for the file uplift_kit-0.1.0-cp37-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for uplift_kit-0.1.0-cp37-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 ed9190ffbb7b50213f9f873d6162f7e1e12cec8a5c46b650e9ec213cf1f7f266
MD5 3aecd24f3194f61ae381f512b7e39741
BLAKE2b-256 a0b76ac63d952176042a0e386455bf918498e2f5cd9e584b3fbc7a35fd0f57f1

See more details on using hashes here.

File details

Details for the file uplift_kit-0.1.0-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for uplift_kit-0.1.0-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 28b13854f6580000e6995d3679ecdd1d09ffa31d2e607c5915214ee3dbf62dd4
MD5 3f04695d240fbc1f0c5bfcb2507e7d2a
BLAKE2b-256 1bcbeeb2fecaf776ca9a20f9f8c613273b51a223143f4fd9877565e17b104a00

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page