torch_concepts.data.preprocessing.autoencoder.extract_embs_from_autoencoder¶
- extract_embs_from_autoencoder(df, autoencoder_kwargs={})[source]¶
Extract embeddings from a pandas DataFrame using an autoencoder.
Convenience function that trains an autoencoder on tabular data and returns the learned latent representations.
- Parameters:
df – Input pandas DataFrame.
autoencoder_kwargs – Dictionary of keyword arguments for AutoencoderTrainer. Can include ‘device’ to specify training device (default: ‘cpu’).
- Returns:
Latent representations of shape (n_samples, latent_dim).
- Return type:
Example
>>> import pandas as pd >>> import torch >>> from torch_concepts.data.preprocessing.autoencoder import extract_embs_from_autoencoder >>> >>> # Create sample DataFrame >>> df = pd.DataFrame(torch.randn(100, 50).numpy()) >>> >>> # Extract embeddings >>> embeddings = extract_embs_from_autoencoder( ... df, ... autoencoder_kwargs={ ... 'latent_dim': 10, ... 'epochs': 50, ... 'batch_size': 32, ... 'noise': 0.1, ... 'device': 'cpu' # or 'cuda' if desired ... } ... ) >>> print(embeddings.shape) torch.Size([100, 10])