MCPcopy
hub / github.com/scikit-learn/scikit-learn / transform

Method transform

sklearn/pipeline.py:2056–2097  ·  view source on GitHub ↗

Transform X separately by each transformer, concatenate results. Parameters ---------- X : iterable or array-like, depending on transformers Input data to be transformed. **params : dict, default=None Parameters routed to the `transform` met

(self, X, **params)

Source from the content-addressed store, hash-verified

2054 )
2055
2056 def transform(self, X, **params):
2057 """Transform X separately by each transformer, concatenate results.
2058
2059 Parameters
2060 ----------
2061 X : iterable or array-like, depending on transformers
2062 Input data to be transformed.
2063
2064 **params : dict, default=None
2065
2066 Parameters routed to the `transform` method of the sub-transformers via the
2067 metadata routing API. See :ref:`Metadata Routing User Guide
2068 <metadata_routing>` for more details.
2069
2070 .. versionadded:: 1.5
2071
2072 Returns
2073 -------
2074 X_t : array-like or sparse matrix of shape (n_samples, sum_n_components)
2075 The `hstack` of results of transformers. `sum_n_components` is the
2076 sum of `n_components` (output dimension) over transformers.
2077 """
2078 _raise_for_params(params, self, "transform")
2079
2080 if _routing_enabled():
2081 routed_params = process_routing(self, "transform", **params)
2082 else:
2083 # TODO(SLEP6): remove when metadata routing cannot be disabled.
2084 routed_params = Bunch()
2085 for name, _ in self.transformer_list:
2086 routed_params[name] = Bunch(transform={})
2087
2088 Xs = Parallel(n_jobs=self.n_jobs)(
2089 delayed(_transform_one)(trans, X, None, weight, params=routed_params[name])
2090 for name, trans, weight in self._iter()
2091 )
2092 if not Xs:
2093 # All transformers are None
2094 xp, _, device = get_namespace_and_device(X)
2095 return xp.zeros((X.shape[0], 0), device=device)
2096
2097 return self._hstack(Xs)
2098
2099 def _hstack(self, Xs):
2100 xp, _ = get_namespace(*Xs)

Callers 5

test_feature_unionFunction · 0.95

Calls 9

_iterMethod · 0.95
_hstackMethod · 0.95
BunchClass · 0.90
ParallelClass · 0.90
delayedFunction · 0.90
get_namespace_and_deviceFunction · 0.90
_raise_for_paramsFunction · 0.85
_routing_enabledFunction · 0.85
process_routingFunction · 0.85

Tested by 5

test_feature_unionFunction · 0.76