Skip to content

Commit 3b7410a

Browse files
authored
🔨 Fix minor improvements on docs (#153)
* 📗 Fix megafon title overline * 📗 Rename EDA notebooks * 📗 Rename EDA notebooks * 💫 Add EDA in tutorials * 💫 Add link from readme to tutorial page * 💫 Fix warning of toctree for 404 page * 📝 Fix typo in DESCR docstring * 📝 Fix index of docs * 📝 Fix main Readme * 📝 Fix quick start * 👷 Fix 404 page image * 👷 Improve docstrings * 👷 Improve legend name in display * 👷 Fix bug in uplift display * 👷 Update images * 👷 Update quick start Readme * 🔧 Update .gitignore: add pytest.xml * Remove old image * Fix links in changelog * 📦 Build only html * ⬆️ Replace depricated recommonmark with myst
1 parent 8a62ac2 commit 3b7410a

20 files changed

+225
-178
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ coverage.xml
6262
*.cover
6363
.hypothesis/
6464
.pytest_cache/
65+
pytest.xml
6566

6667
# Translations
6768
*.mo

.readthedocs.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ sphinx:
1313
# configuration: mkdocs.yml
1414

1515
# Optionally build your docs in additional formats such as PDF and ePub
16-
formats: all
16+
formats:
17+
- htmlzip
1718

1819
# Optionally set the version of Python and requirements required to build your docs
1920
python:

Readme.rst

Lines changed: 46 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -54,19 +54,22 @@ Articles in russian on habr.com: `Part 1 <https://habr.com/ru/company/ru_mts/blo
5454
`Part 2 <https://habr.com/ru/company/ru_mts/blog/485976/>`__
5555
and `Part 3 <https://habr.com/ru/company/ru_mts/blog/538934/>`__.
5656

57-
**Features**:
57+
Why sklift
58+
-------------
59+
60+
- Сomfortable and intuitive *scikit-learn*-like API;
5861

59-
* Сomfortable and intuitive scikit-learn-like API;
62+
- More uplift metrics than you have ever seen in one place! Include brilliants like *Area Under Uplift Curve* (AUUC) or *Area Under Qini Curve* (Qini coefficient) with ideal cases;
6063

61-
* Applying any estimator compatible with scikit-learn (e.g. Xgboost, LightGBM, Catboost, etc.);
64+
- Supporting any estimator compatible with scikit-learn (e.g. Xgboost, LightGBM, Catboost, etc.);
6265

63-
* 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|_));
66+
- All approaches can be used in the ``sklearn.pipeline``. See the example of usage on `the Tutorials page <https://www.uplift-modeling.com/en/latest/tutorials.html>`__;
6467

65-
* Almost all implemented approaches solve classification and regression problem;
68+
- Also metrics are compatible with the classes from ``sklearn.model_selection``. See the example of usage on `the Tutorials page <https://www.uplift-modeling.com/en/latest/tutorials.html>`__;
6669

67-
* More uplift metrics that you have ever seen in one place! Include brilliants like *Area Under Uplift Curve* (AUUC) or *Area Under Qini Curve* (Qini coefficient) with ideal cases;
70+
- Almost all implemented approaches solve classification and regression problems;
6871

69-
* Nice and useful viz for analyzing a performance model.
72+
- Nice and useful viz for analysing a performance model.
7073

7174
Installation
7275
-------------
@@ -112,24 +115,25 @@ Use the intuitive python API to train uplift models with `sklift.models <https:
112115
.. code-block:: python
113116
114117
# import approaches
115-
from sklift.models import SoloModel, ClassTransformation, TwoModels
118+
from sklift.models import SoloModel, ClassTransformation
116119
# import any estimator adheres to scikit-learn conventions.
117-
from catboost import CatBoostClassifier
118-
120+
from lightgbm import LGBMClassifier
119121
120122
# define models
121-
treatment_model = CatBoostClassifier(iterations=50, thread_count=3,
122-
random_state=42, silent=True)
123-
control_model = CatBoostClassifier(iterations=50, thread_count=3,
124-
random_state=42, silent=True)
123+
estimator = LGBMClassifier(n_estimators=10)
124+
125+
# define metamodel
126+
slearner = SoloModel(estimator=estimator)
125127
126-
# define approach
127-
tm = TwoModels(treatment_model, control_model, method='vanilla')
128128
# fit model
129-
tm = tm.fit(X_train, y_train, treat_train)
129+
slearner.fit(
130+
X=X_tr,
131+
y=y_tr,
132+
treatment=trmnt_tr,
133+
)
130134
131135
# predict uplift
132-
uplift_preds = tm.predict(X_val)
136+
uplift_slearner = slearner.predict(X_val)
133137
134138
**Evaluate your uplift model**
135139

@@ -144,33 +148,48 @@ Uplift model evaluation metrics are available in `sklift.metrics <https://www.u
144148
145149
146150
# Uplift@30%
147-
tm_uplift_at_k = uplift_at_k(y_true=y_val, uplift=uplift_preds, treatment=treat_val,
148-
strategy='overall', k=0.3)
151+
uplift_at_k = uplift_at_k(y_true=y_val, uplift=uplift_slearner,
152+
treatment=trmnt_val,
153+
strategy='overall', k=0.3)
149154
150155
# Area Under Qini Curve
151-
tm_qini_auc = qini_auc_score(y_true=y_val, uplift=uplift_preds, treatment=treat_val)
156+
qini_coef = qini_auc_score(y_true=y_val, uplift=uplift_slearner,
157+
treatment=trmnt_val)
152158
153159
# Area Under Uplift Curve
154-
tm_uplift_auc = uplift_auc_score(y_true=y_val, uplift=uplift_preds, treatment=treat_val)
160+
uplift_auc = uplift_auc_score(y_true=y_val, uplift=uplift_slearner,
161+
treatment=trmnt_val)
155162
156163
# Weighted average uplift
157-
tm_wau = weighted_average_uplift(y_true=y_val, uplift=uplift_preds, treatment=treat_val)
164+
wau = weighted_average_uplift(y_true=y_val, uplift=uplift_slearner,
165+
treatment=trmnt_val)
158166
159167
**Vizualize the results**
160168

161169
Visualize performance metrics with `sklift.viz <https://www.uplift-modeling.com/en/latest/api/viz/index.html>`__.
162170

163171
.. code-block:: python
164172
165-
# import vizualisation tools
166173
from sklift.viz import plot_qini_curve
174+
import matplotlib.pyplot as plt
175+
176+
fig, ax = plt.subplots(1, 1)
177+
ax.set_title('Qini curves')
178+
179+
plot_qini_curve(
180+
y_test, uplift_slearner, trmnt_test,
181+
perfect=True, name='Slearner', ax=ax
182+
);
167183
168-
plot_qini_curve(y_true=y_val, uplift=uplift_preds, treatment=treat_val, negative_effect=True)
184+
plot_qini_curve(
185+
y_test, uplift_revert, trmnt_test,
186+
perfect=False, name='Revert label', ax=ax
187+
);
169188
170-
.. image:: docs/_static/images/Readme_qini_curve.png
189+
.. image:: docs/_static/images/quick_start_qini.png
171190
:width: 514px
172191
:height: 400px
173-
:alt: Example of model's qini curve, perfect qini curve and random qini curve
192+
:alt: Example of some models qini curves, perfect qini curve and random qini curve
174193

175194
Development
176195
-----------

docs/404.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
:orphan:
2+
13
*******************
24
404 Page Not Found
35
*******************
46

5-
.. image:: ../../_static/images/sklift_404.png
7+
.. image:: _static/images/sklift_404.png
68
:alt: 404 Page not found
79
:align: center
810
:width: 250 px
-52.6 KB
Binary file not shown.
-18.8 KB
Loading
-2.67 KB
Loading
2.88 KB
Loading

docs/api/datasets/fetch_megafon.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
.. _Megafon:
22

3-
***********************************
3+
***************************************
44
`sklift.datasets <./>`_.fetch_megafon
5-
***********************************
5+
***************************************
66

77
.. autofunction:: sklift.datasets.datasets.fetch_megafon
88

docs/changelog.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,17 @@
1010

1111
## Version 0.3.2
1212

13-
### [sklift.datasets](https://www.uplift-modeling.com/en/v0.3.1/api/datasets/index.html)
13+
### [sklift.datasets](https://www.uplift-modeling.com/en/v0.3.2/api/datasets/index.html)
1414

15-
* 🔨 Fix bug in [fetch_x5](https://www.uplift-modeling.com/en/v0.3.1/api/datasets/fetch_x5.html) function by [@Muhamob](https://github.com/Muhamob).
15+
* 🔨 Fix bug in [fetch_x5](https://www.uplift-modeling.com/en/v0.3.2/api/datasets/fetch_x5.html) function by [@Muhamob](https://github.com/Muhamob).
1616

17-
### [sklift.metrics](https://www.uplift-modeling.com/en/v0.3.1/api/index/metrics.html)
17+
### [sklift.metrics](https://www.uplift-modeling.com/en/v0.3.2/api/index/metrics.html)
1818

19-
* 📝 Fix docstring in [uplift_by_percentile](https://www.uplift-modeling.com/en/v0.3.1/api/metrics/uplift_by_percentile.html) function by [@ElisovaIra](https://github.com/ElisovaIra).
19+
* 📝 Fix docstring in [uplift_by_percentile](https://www.uplift-modeling.com/en/v0.3.2/api/metrics/uplift_by_percentile.html) function by [@ElisovaIra](https://github.com/ElisovaIra).
2020

21-
### [sklift.viz](https://www.uplift-modeling.com/en/v0.3.1/api/viz/index.html)
21+
### [sklift.viz](https://www.uplift-modeling.com/en/v0.3.2/api/viz/index.html)
2222

23-
* 🔨 Fix bug in [plot_uplift_preds](https://www.uplift-modeling.com/en/v0.3.1/api/viz/plot_uplift_preds.html) function by [@bwbelljr](https://github.com/bwbelljr).
23+
* 🔨 Fix bug in [plot_uplift_preds](https://www.uplift-modeling.com/en/v0.3.2/api/viz/plot_uplift_preds.html) function by [@bwbelljr](https://github.com/bwbelljr).
2424

2525
### Miscellaneous
2626

0 commit comments

Comments
 (0)