Skip to content

Commit 703fb90

Browse files
committed
Merge branch 'feature/add_user_guide' into dev
2 parents c933fa7 + c42241d commit 703fb90

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+1016
-546
lines changed

Readme.rst

Lines changed: 44 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.. -*- mode: rst -*-
22
3-
|Python3|_ |PyPi|_ |Docs|_
3+
|Python3|_ |PyPi|_ |Docs|_ |License|
44

55
.. |Python3| image:: https://img.shields.io/badge/python-3-blue.svg
66
.. _Python3: https://badge.fury.io/py/scikit-uplift
@@ -11,6 +11,9 @@
1111
.. |Docs| image:: https://readthedocs.org/projects/scikit-uplift/badge/?version=latest
1212
.. _Docs: https://scikit-uplift.readthedocs.io/en/latest/
1313

14+
.. |Docs| image:: https://img.shields.io/badge/license-MIT-green
15+
.. _Docs: https://github.com/maks-sh/scikit-uplift/blob/master/LICENSE
16+
1417
.. |Open In Colab1| image:: https://colab.research.google.com/assets/colab-badge.svg
1518
.. _Open In Colab1: https://colab.research.google.com/github/maks-sh/scikit-uplift/blob/master/notebooks/RetailHero_EN.ipynb
1619

@@ -24,8 +27,6 @@
2427
.. _Open In Colab4: https://colab.research.google.com/github/maks-sh/scikit-uplift/blob/master/notebooks/pipeline_usage_RU.ipynb
2528

2629
.. _scikit-uplift.readthedocs.io: https://scikit-uplift.readthedocs.io/en/latest/
27-
.. _Part 1: https://habr.com/ru/company/ru_mts/blog/485980/
28-
.. _Part 2: https://habr.com/ru/company/ru_mts/blog/485976/
2930

3031
.. image:: https://raw.githubusercontent.com/maks-sh/scikit-uplift/dev/docs/_static/sklift-github-logo.png
3132
:align: center
@@ -39,15 +40,17 @@ scikit-uplift
3940

4041
Uplift prediction aims to estimate the causal impact of a treatment at the individual level.
4142

42-
More about uplift modelling problem read in russian on habr.com: `Part 1`_ and `Part 2`_.
43+
Read more about uplift modeling problem in `User Guide <https://scikit-uplift.readthedocs.io/en/latest/user_guide/index.html>`__,
44+
also articles in russian on habr.com: `Part 1 <https://habr.com/ru/company/ru_mts/blog/485980/>`__
45+
and `Part 2 <https://habr.com/ru/company/ru_mts/blog/485976/>`__.
4346

4447
**Features**:
4548

4649
* Comfortable and intuitive style of modelling like scikit-learn;
4750

4851
* Applying any estimator adheres to scikit-learn conventions;
4952

50-
* All approaches can be used in sklearn.pipeline (see example (`EN <https://nbviewer.jupyter.org/github/maks-sh/scikit-uplift/blob/master/notebooks/pipeline_usage_EN.ipynb>`__ |Open In Colab3|_, `RU <https://nbviewer.jupyter.org/github/maks-sh/scikit-uplift/blob/master/notebooks/pipeline_usage_RU.ipynb>`__ |Open In Colab4|_))
53+
* All approaches can be used in sklearn.pipeline (see example (`EN <https://nbviewer.jupyter.org/github/maks-sh/scikit-uplift/blob/master/notebooks/pipeline_usage_EN.ipynb>`__ |Open In Colab3|_, `RU <https://nbviewer.jupyter.org/github/maks-sh/scikit-uplift/blob/master/notebooks/pipeline_usage_RU.ipynb>`__ |Open In Colab4|_));
5154

5255
* Almost all implemented approaches solve both the problem of classification and regression;
5356

@@ -101,57 +104,65 @@ See the **RetailHero tutorial notebook** (`EN <https://nbviewer.jupyter.org/gith
101104
# import any estimator adheres to scikit-learn conventions.
102105
from catboost import CatBoostClassifier
103106
107+
108+
# define models
109+
treatment_model = CatBoostClassifier(iterations=50, thread_count=3,
110+
random_state=42, silent=True)
111+
control_model = CatBoostClassifier(iterations=50, thread_count=3,
112+
random_state=42, silent=True)
113+
104114
# define approach
105-
sm = SoloModel(CatBoostClassifier(verbose=100, random_state=777))
115+
tm = TwoModels(treatment_model, control_model, method='vanilla')
106116
# fit model
107-
sm = sm.fit(X_train, y_train, treat_train, estimator_fit_params={'plot': True})
117+
tm = tm.fit(X_train, y_train, treat_train)
108118
109119
# predict uplift
110-
uplift_sm = sm.predict(X_val)
120+
uplift_preds = tm.predict(X_val)
111121
112122
**Evaluate your uplift model**
113123

114124
.. code-block:: python
115125
116126
# import metrics to evaluate your model
117-
from sklift.metrics import qini_auc_score, uplift_auc_score, uplift_at_k
127+
from sklift.metrics import (
128+
uplift_at_k, uplift_auc_score, qini_auc_score, weighted_average_uplift
129+
)
130+
118131
119132
# Uplift@30%
120-
sm_uplift_at_k = uplift_at_k(y_true=y_val, uplift=uplift_sm, treatment=treat_val, k=0.3)
133+
tm_uplift_at_k = uplift_at_k(y_true=y_val, uplift=uplift_preds, treatment=treat_val,
134+
strategy='overall', k=0.3)
135+
121136
# Area Under Qini Curve
122-
sm_qini_auc_score = qini_auc_score(y_true=y_val, uplift=uplift_sm, treatment=treat_val)
137+
tm_qini_auc = qini_auc_score(y_true=y_val, uplift=uplift_preds, treatment=treat_val)
138+
123139
# Area Under Uplift Curve
124-
sm_uplift_auc_score = uplift_auc_score(y_true=y_val, uplift=uplift_sm, treatment=treat_val)
140+
tm_uplift_auc = uplift_auc_score(y_true=y_val, uplift=uplift_preds, treatment=treat_val)
141+
142+
# Weighted average uplift
143+
tm_wau = weighted_average_uplift(y_true=y_val, uplift=uplift_preds, treatment=treat_val)
125144
126145
**Vizualize the results**
127146

128147
.. code-block:: python
129148
130149
# import vizualisation tools
131-
from sklift.viz import plot_uplift_preds, plot_uplift_qini_curves
132-
133-
# get conditional predictions (probabilities) of performing a target action
134-
# with interaction for each object
135-
sm_trmnt_preds = sm.trmnt_preds_
136-
# get conditional predictions (probabilities) of performing a target action
137-
# without interaction for each object
138-
sm_ctrl_preds = sm.ctrl_preds_
139-
140-
# draw probability distributions and their difference (uplift)
141-
plot_uplift_preds(trmnt_preds=sm_trmnt_preds, ctrl_preds=sm_ctrl_preds);
142-
# draw Uplift and Qini curves
143-
plot_uplift_qini_curves(y_true=y_val, uplift=uplift_sm, treatment=treat_val);
144-
145-
.. image:: https://raw.githubusercontent.com/maks-sh/scikit-uplift/master/docs/_static/images/readme_img1.png
146-
:align: center
147-
:alt: Probabilities Histogram, Uplift anf Qini curves
150+
from sklift.viz import plot_qini_curve
148151
152+
plot_qini_curve(y_true=y_val, uplift=uplift_preds, treatment=treat_val)
149153
154+
.. image:: _static/images/quick_start_qini.png
155+
:width: 514px
156+
:height: 400px
157+
:alt: Example of model's qini curve, perfect qini curve and random qini curve
150158

151159
Development
152160
-----------
153161

154-
We welcome new contributors of all experience levels. Please see our `Contributing Guide <https://scikit-uplift.readthedocs.io/en/latest/contributing.html>`_ for more details.
162+
We welcome new contributors of all experience levels.
163+
164+
- Please see our `Contributing Guide <https://scikit-uplift.readthedocs.io/en/latest/contributing.html>`_ for more details.
165+
- By participating in this project, you agree to abide by its `Code of Conduct <https://github.com/maks-sh/scikit-uplift/blob/master/.github/CODE_OF_CONDUCT.md>`__.
155166

156167
Contributing
157168
~~~~~~~~~~~~~~~
@@ -195,6 +206,7 @@ Important links
195206
- Official source code repo: https://github.com/maks-sh/scikit-uplift/
196207
- Issue tracker: https://github.com/maks-sh/scikit-uplift/issues
197208
- Documentation: https://scikit-uplift.readthedocs.io/en/latest/
209+
- User Guide: https://scikit-uplift.readthedocs.io/en/latest/user_guide/index.html
198210
- Contributing guide: https://scikit-uplift.readthedocs.io/en/latest/contributing.html
199211
- Release History: https://scikit-uplift.readthedocs.io/en/latest/changelog.html
200212

@@ -239,10 +251,10 @@ Papers and materials
239251
Uplift Modeling with Multiple Treatments and General Response Types. 10.1137/1.9781611974973.66.
240252

241253
10. Nicholas J Radcliffe. 2007.
242-
Using control groups to target on predicted lift: Building and assessing uplift model. Direct Marketing Analytics Journal, (3):14–21, 2007.
254+
Using control groups to target on predicted lift: Building and assessing uplift model. Direct Marketing Analytics Journal, (3):14–21, 2007.
243255

244256
11. Devriendt, F., Guns, T., & Verbeke, W. 2020.
245-
Learning to rank for uplift modeling. ArXiv, abs/2002.05897.
257+
Learning to rank for uplift modeling. ArXiv, abs/2002.05897.
246258

247259
===============
248260

docs/_static/css/custom.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
.wy-side-nav-search, .wy-nav-top {
22
background: #0062a2;
3+
}
4+
5+
.wy-breadcrumbs {
6+
font-size: 12px;
37
}
149 KB
Loading
150 KB
Loading
118 KB
Loading
660 KB
Loading
42.9 KB
Loading
164 KB
Loading
2.9 MB
Loading

docs/api/index.rst

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
.. meta::
22
:description lang=en:
3-
scikit-uplift (sklift) api reference for modeling uplift and evaluate the causal effect of a treatment in python
3+
scikit-uplift (sklift) api reference for modeling uplift and evaluate the causal effect of a treatment
4+
in scikit-learn style in python
45

5-
*************
6-
API Reference
7-
*************
6+
************
7+
API sklift
8+
************
89

910
This is the modules reference of scikit-uplift.
1011

1112
.. toctree::
1213
:maxdepth: 3
1314

14-
./models
15-
./metrics
16-
./viz
15+
./models/index
16+
./metrics/index
17+
./viz/index

0 commit comments

Comments
 (0)