cellxgene_census.experimental.ml.encoders.Encoder

class cellxgene_census.experimental.ml.encoders.Encoder

Base class for obs encoders.

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 an obs tensor.

  • 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 a pytorch.ExperimentDataPipe must have a unique name.

  • columns: List of columns in obs that the encoder will be applied to.

See the implementation of LabelEncoder for 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.DataFrame into a pandas.DataFrame of encoded values.

Attributes

columns

Columns in obs that the encoder will be applied to.

name

Name of the encoder.