|
| 1 | +========================== |
| 2 | +mlinsights.mlmodel (trees) |
| 3 | +========================== |
| 4 | + |
| 5 | +.. _blog-internal-api-impurity-improvement: |
| 6 | + |
| 7 | +Note about potentiel issues |
| 8 | +=========================== |
| 9 | + |
| 10 | +The main estimator `PiecewiseTreeRegressor` is based on the implementation |
| 11 | +on new criterion. It relies on a non-public API and as such is more likely |
| 12 | +to break. The unit test are unstable. They work when *scikit-learn* |
| 13 | +and this package are compiled with the same set of tools. If installed |
| 14 | +from PyPi, you can check which versions were used at compilation time. |
| 15 | + |
| 16 | +.. runpython:: |
| 17 | + :showcode: |
| 18 | + |
| 19 | + from mlinsights._config import ( |
| 20 | + CYTHON_VERSION, |
| 21 | + NUMPY_VERSION, |
| 22 | + SCIPY_VERSION, |
| 23 | + SKLEARN_VERSION, |
| 24 | + ) |
| 25 | + print(f"CYTHON_VERSION: {CYTHON_VERSION}") |
| 26 | + print(f"NUMPY_VERSION: {NUMPY_VERSION}") |
| 27 | + print(f"SCIPY_VERSION: {SCIPY_VERSION}") |
| 28 | + print(f"SKLEARN_VERSION: {SKLEARN_VERSION}") |
| 29 | + |
| 30 | + |
| 31 | +The signature of method *impurity_improvement* has changed in version 0.24. |
| 32 | +That's usually easy to handle two versions of *scikit-learn* even overloaded |
| 33 | +in a class except that method is implemented in cython. |
| 34 | +The method must be overloaded the same way with the same signature. |
| 35 | +Tricks such as `*args` or `**kwargs` cannot be used. |
| 36 | +The way it was handled is implemented in |
| 37 | +PR `88 <https://github.com/sdpython/mlinsights/pull/88>`_. |
| 38 | + |
| 39 | +Estimators |
| 40 | +========== |
| 41 | + |
| 42 | +PiecewiseTreeRegressor |
| 43 | +++++++++++++++++++++++ |
| 44 | + |
| 45 | +.. autoclass:: mlinsights.mlmodel.piecewise_tree_regression.PiecewiseTreeRegressor |
| 46 | + :members: |
| 47 | + |
| 48 | +Criterions |
| 49 | +========== |
| 50 | + |
| 51 | +The following classes require :epkg:`scikit-learn` *>= 1.3.0*, |
| 52 | +otherwise, they do not get compiled. |
| 53 | + |
| 54 | +SimpleRegressorCriterion |
| 55 | +++++++++++++++++++++++++ |
| 56 | + |
| 57 | +.. autoclass:: mlinsights.mlmodel.piecewise_tree_regression_criterion.SimpleRegressorCriterion |
| 58 | + :members: |
| 59 | + |
| 60 | +SimpleRegressorCriterionFast |
| 61 | +++++++++++++++++++++++++++++ |
| 62 | + |
| 63 | +A similar design but a much faster implementation close to what |
| 64 | +:epkg:`scikit-learn` implements. |
| 65 | + |
| 66 | +.. autoclass:: mlinsights.mlmodel.piecewise_tree_regression_criterion_fast.SimpleRegressorCriterionFast |
| 67 | + :members: |
| 68 | + |
| 69 | +LinearRegressorCriterion |
| 70 | +++++++++++++++++++++++++ |
| 71 | + |
| 72 | +The next one implements a criterion which optimizes the mean square error |
| 73 | +assuming the points falling into one node of the tree are approximated by |
| 74 | +a line. The mean square error is the error made with a linear regressor |
| 75 | +and not a constant anymore. The documentation will be completed later. |
| 76 | + |
| 77 | +`mlinsights.mlmodel.piecewise_tree_regression_criterion_linear.LinearRegressorCriterion` |
| 78 | + |
| 79 | +`mlinsights.mlmodel.piecewise_tree_regression_criterion_linear_fast.SimpleRegressorCriterionFast` |
0 commit comments