dtoolkit.transformer.RavelTF#
- class dtoolkit.transformer.RavelTF(*args, **kwargs)[source]#
A transformer could return a contiguous flattened array.
This transformer is used to handle that sklearn model requires
y
’s shape is(n, )
. But actually we always forget this. So you would get aDataConversionWarning
DataConversionWarning: A column-vector y was passed when a 1d array was expected. Please change the shape of y to (n_samples, ), for example using ravel().
See also
numpy.ravel
This transformer’s prototype method.
Examples
>>> from dtoolkit.transformer import RavelTF >>> x = np.array([[1, 2, 3], [4, 5, 6]]) >>> tf = RavelTF()
RavelTF.transform()
, flatten data:>>> transformed_data = tf.transform(x) >>> transformed_data array([1, 2, 3, 4, 5, 6])
RavelTF.inverse_transform()
, transform data toSeries
:>>> tf.inverse_transform(transformed_data).astype('int64') 0 1 1 2 2 3 3 4 4 5 5 6 dtype: int64
- Attributes:
- inverse_transform_method
Methods
fit
(*_)Fit transformer.
fit_transform
(X[, y])Fit to data, then transform it.
Transform
X
to a columnSeries
(1D data).set_output
(*[, transform])Set output container.
transform
(X)Transform
X
.transform_method
(a[, order])Return a contiguous flattened array.
update_invargs
(*args, **kwargs)Inverse transform method argument entry.