Skip to content

Commit 0cf0f99

Browse files
committed
🐜 update main Readme
1 parent e57883b commit 0cf0f99

File tree

1 file changed

+42
-30
lines changed

1 file changed

+42
-30
lines changed

Readme.rst

Lines changed: 42 additions & 30 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

@@ -39,15 +42,15 @@ scikit-uplift
3942

4043
Uplift prediction aims to estimate the causal impact of a treatment at the individual level.
4144

42-
More about uplift modelling problem read in russian on habr.com: `Part 1`_ and `Part 2`_.
45+
More about uplift modelling problem read in `User guide <https://scikit-uplift.readthedocs.io/en/latest/user_guide/index.html>`__, and also in russian on habr.com: `Part 1`_ and `Part 2`_.
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

0 commit comments

Comments
 (0)