Skip to content

Commit aa0fdfb

Browse files
MTN Made the distinction between predictor and transformer clearer (#856)
1 parent 83232a4 commit aa0fdfb

File tree

4 files changed

+22
-8
lines changed

4 files changed

+22
-8
lines changed

notebooks/02_numerical_pipeline_introduction.ipynb

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,11 +162,18 @@
162162
"![Predictor fit diagram](../figures/api_diagram-predictor.fit.svg)\n",
163163
"\n",
164164
"In scikit-learn an object that has a `fit` method is called an **estimator**.\n",
165+
"If the estimator additionally has :\n",
166+
"- a `predict` method, it is called a **predictor**. Examples of predictors\n",
167+
" are classifiers or regressors.\n",
168+
"- a `transform` method, it is called a **transformer**. Examples of\n",
169+
" transformers are scalers or encoders. We will see more about transformers in\n",
170+
" the next notebook.\n",
171+
"\n",
165172
"The method `fit` is composed of two elements: (i) a **learning algorithm** and\n",
166173
"(ii) some **model states**. The learning algorithm takes the training data and\n",
167174
"training target as input and sets the model states. These model states are\n",
168-
"later used to either predict (for classifiers and regressors) or transform\n",
169-
"data (for transformers).\n",
175+
"later used to either predict or transform data as explained above. See the\n",
176+
"glossary for more detailed definitions.\n",
170177
"\n",
171178
"Both the learning algorithm and the type of model states are specific to each\n",
172179
"type of model."
@@ -204,8 +211,7 @@
204211
"cell_type": "markdown",
205212
"metadata": {},
206213
"source": [
207-
"An estimator (an object with a `fit` method) with a `predict` method is called\n",
208-
"a **predictor**. We can illustrate the prediction mechanism as follows:\n",
214+
"We can illustrate the prediction mechanism as follows:\n",
209215
"\n",
210216
"![Predictor predict diagram](../figures/api_diagram-predictor.predict.svg)\n",
211217
"\n",

notebooks/02_numerical_pipeline_scaling.ipynb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@
137137
"We show how to apply such normalization using a scikit-learn transformer\n",
138138
"called `StandardScaler`. This transformer shifts and scales each feature\n",
139139
"individually so that they all have a 0-mean and a unit standard deviation.\n",
140+
"We recall that transformers are estimators that have a `transform` method.\n",
140141
"\n",
141142
"We now investigate different steps used in scikit-learn to achieve such a\n",
142143
"transformation of the data.\n",

python_scripts/02_numerical_pipeline_introduction.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,18 @@
101101
# ![Predictor fit diagram](../figures/api_diagram-predictor.fit.svg)
102102
#
103103
# In scikit-learn an object that has a `fit` method is called an **estimator**.
104+
# If the estimator additionally has :
105+
# - a `predict` method, it is called a **predictor**. Examples of predictors
106+
# are classifiers or regressors.
107+
# - a `transform` method, it is called a **transformer**. Examples of
108+
# transformers are scalers or encoders. We will see more about transformers in
109+
# the next notebook.
110+
#
104111
# The method `fit` is composed of two elements: (i) a **learning algorithm** and
105112
# (ii) some **model states**. The learning algorithm takes the training data and
106113
# training target as input and sets the model states. These model states are
107-
# later used to either predict (for classifiers and regressors) or transform
108-
# data (for transformers).
114+
# later used to either predict or transform data as explained above. See the
115+
# glossary for more detailed definitions.
109116
#
110117
# Both the learning algorithm and the type of model states are specific to each
111118
# type of model.
@@ -124,8 +131,7 @@
124131
target_predicted = model.predict(data)
125132

126133
# %% [markdown]
127-
# An estimator (an object with a `fit` method) with a `predict` method is called
128-
# a **predictor**. We can illustrate the prediction mechanism as follows:
134+
# We can illustrate the prediction mechanism as follows:
129135
#
130136
# ![Predictor predict diagram](../figures/api_diagram-predictor.predict.svg)
131137
#

python_scripts/02_numerical_pipeline_scaling.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@
8888
# We show how to apply such normalization using a scikit-learn transformer
8989
# called `StandardScaler`. This transformer shifts and scales each feature
9090
# individually so that they all have a 0-mean and a unit standard deviation.
91+
# We recall that transformers are estimators that have a `transform` method.
9192
#
9293
# We now investigate different steps used in scikit-learn to achieve such a
9394
# transformation of the data.

0 commit comments

Comments
 (0)