cellxgene_census.experimental.ml.encoders.Encoder
- class cellxgene_census.experimental.ml.encoders.Encoder
Base class for
obsencoders.To define a custom encoder, five methods must be implemented:
fit: defines how the encoder will be fitted to the data.transform: defines how the encoder will be applied to the data in order to create anobstensor.inverse_transform: defines how to decode the encoded values back to the original values.name: The name of the encoder. This will be used as the key in the dictionary of encoders. Each encoder passed to apytorch.ExperimentDataPipemust have a unique name.columns: List of columns inobsthat the encoder will be applied to.
See the implementation of
LabelEncoderfor an example.- __init__()
Methods
__init__()fit(obs)Fit the encoder with obs.
inverse_transform(encoded_values)Inverse transform the encoded values back to the original values.
transform(df)Transform the obs
pandas.DataFrameinto apandas.DataFrameof encoded values.Attributes
columnsColumns in
obsthat the encoder will be applied to.nameName of the encoder.