|
8 | 8 | from collections import OrderedDict |
9 | 9 | from unittest import mock |
10 | 10 | import warnings |
| 11 | +from packaging import version |
11 | 12 |
|
12 | 13 | import numpy as np |
13 | 14 | import scipy.optimize |
@@ -274,20 +275,35 @@ def test_serialize_pipeline(self): |
274 | 275 | 'scaler=sklearn.preprocessing.data.StandardScaler,' \ |
275 | 276 | 'dummy=sklearn.dummy.DummyClassifier)' |
276 | 277 | fixture_short_name = 'sklearn.Pipeline(StandardScaler,DummyClassifier)' |
277 | | - # str obtained from self.extension._get_sklearn_description(model) |
278 | | - fixture_description = "Pipeline of transforms with a final estimator.\n\nSequentially " \ |
279 | | - "apply a list of transforms and a final estimator.\nIntermediate "\ |
280 | | - "steps of the pipeline must be 'transforms', that is, they\nmust "\ |
281 | | - "implement fit and transform methods.\nThe final estimator only "\ |
282 | | - "needs to implement fit.\nThe transformers in the pipeline can be "\ |
283 | | - "cached using ``memory`` argument.\n\nThe purpose of the pipeline is"\ |
284 | | - " to assemble several steps that can be\ncross-validated together "\ |
285 | | - "while setting different parameters.\nFor this, it enables setting "\ |
286 | | - "parameters of the various steps using their\nnames and the "\ |
287 | | - "parameter name separated by a '__', as in the example below.\nA "\ |
288 | | - "step's estimator may be replaced entirely by setting the "\ |
289 | | - "parameter\nwith its name to another estimator, or a transformer "\ |
290 | | - "removed by setting\nit to 'passthrough' or ``None``." |
| 278 | + |
| 279 | + if version.parse(sklearn.__version__) >= version.parse("0.21.0"): |
| 280 | + fixture_description = "Pipeline of transforms with a final estimator.\n\nSequentially " \ |
| 281 | + "apply a list of transforms and a final estimator.\nIntermediate " \ |
| 282 | + "steps of the pipeline must be 'transforms', that is, they\nmust " \ |
| 283 | + "implement fit and transform methods.\nThe final estimator only " \ |
| 284 | + "needs to implement fit.\nThe transformers in the pipeline can be " \ |
| 285 | + "cached using ``memory`` argument.\n\nThe purpose of the pipeline is" \ |
| 286 | + " to assemble several steps that can be\ncross-validated together " \ |
| 287 | + "while setting different parameters.\nFor this, it enables setting " \ |
| 288 | + "parameters of the various steps using their\nnames and the " \ |
| 289 | + "parameter name separated by a '__', as in the example below.\nA " \ |
| 290 | + "step's estimator may be replaced entirely by setting the " \ |
| 291 | + "parameter\nwith its name to another estimator, or a transformer " \ |
| 292 | + "removed by setting\nit to 'passthrough' or ``None``." |
| 293 | + else: |
| 294 | + fixture_description = "Pipeline of transforms with a final estimator.\n\nSequentially"\ |
| 295 | + " apply a list of transforms and a final estimator.\nIntermediate"\ |
| 296 | + " steps of the pipeline must be 'transforms', that is, they\nmust "\ |
| 297 | + "implement fit and transform methods.\nThe final estimator only "\ |
| 298 | + "needs to implement fit.\nThe transformers in the pipeline can "\ |
| 299 | + "be cached using ``memory`` argument.\n\nThe purpose of the "\ |
| 300 | + "pipeline is to assemble several steps that can be\n"\ |
| 301 | + "cross-validated together while setting different parameters."\ |
| 302 | + "\nFor this, it enables setting parameters of the various steps"\ |
| 303 | + " using their\nnames and the parameter name separated by a '__',"\ |
| 304 | + " as in the example below.\nA step's estimator may be replaced "\ |
| 305 | + "entirely by setting the parameter\nwith its name to another "\ |
| 306 | + "estimator, or a transformer removed by setting\nto None." |
291 | 307 | fixture_structure = { |
292 | 308 | fixture_name: [], |
293 | 309 | 'sklearn.preprocessing.data.StandardScaler': ['scaler'], |
|
0 commit comments