Transform the data, and apply `decision_function` with the final estimator. Call `transform` of each transformer in the pipeline. The transformed data are finally passed to the final estimator that calls `decision_function` method. Only valid if the final estimator i
(self, X, **params)
| 935 | |
| 936 | @available_if(_final_estimator_has("decision_function")) |
| 937 | def decision_function(self, X, **params): |
| 938 | """Transform the data, and apply `decision_function` with the final estimator. |
| 939 | |
| 940 | Call `transform` of each transformer in the pipeline. The transformed |
| 941 | data are finally passed to the final estimator that calls |
| 942 | `decision_function` method. Only valid if the final estimator |
| 943 | implements `decision_function`. |
| 944 | |
| 945 | Parameters |
| 946 | ---------- |
| 947 | X : iterable |
| 948 | Data to predict on. Must fulfill input requirements of first step |
| 949 | of the pipeline. |
| 950 | |
| 951 | **params : dict of string -> object |
| 952 | Parameters requested and accepted by steps. Each step must have |
| 953 | requested certain metadata for these parameters to be forwarded to |
| 954 | them. |
| 955 | |
| 956 | .. versionadded:: 1.4 |
| 957 | Only available if `enable_metadata_routing=True`. See |
| 958 | :ref:`Metadata Routing User Guide <metadata_routing>` for more |
| 959 | details. |
| 960 | |
| 961 | Returns |
| 962 | ------- |
| 963 | y_score : ndarray of shape (n_samples, n_classes) |
| 964 | Result of calling `decision_function` on the final estimator. |
| 965 | """ |
| 966 | check_is_fitted(self) |
| 967 | _raise_for_params(params, self, "decision_function") |
| 968 | |
| 969 | # not branching here since params is only available if |
| 970 | # enable_metadata_routing=True |
| 971 | routed_params = process_routing(self, "decision_function", **params) |
| 972 | |
| 973 | Xt = X |
| 974 | for _, name, transform in self._iter(with_final=False): |
| 975 | Xt = transform.transform( |
| 976 | Xt, **routed_params.get(name, {}).get("transform", {}) |
| 977 | ) |
| 978 | return self.steps[-1][1].decision_function( |
| 979 | Xt, |
| 980 | **routed_params.get(self.steps[-1][0], {}).get("decision_function", {}), |
| 981 | ) |
| 982 | |
| 983 | @available_if(_final_estimator_has("score_samples")) |
| 984 | def score_samples(self, X): |