Embeddings for Tabular Data (Multivariate Drift)
Use Embeddings to Catch Multivariate Drift in Tabular Data
Google Colaboratory
Google Colab for Generating Embeddings from Tabular Data
Tabular Embeddings are embeddings that are generated from a row of tabular data. Each row of your dataframe will be represented by 1 embedding vector.
We can use our embeddings from tabular data to monitor multivariate drift. Multivariate drift catches drift across combinations of multiple features that may not be present when looking at a single feature level.
Conceptual Example: There's an abnormal increase of tall people with small shoe size, but not obvious just looking at increase in average height or decrease in shoe size.
Visual for how to generate Tabular Embeddings
- 1.Select the columns in your data that you want to convert to embeddings. If you're not sure which columns would work best, start with using all of your feature and prediction columns. In addition, we suggest not selecting columns that contain incomprehensible strings, e.g., hashed fields, user ids, etc.
Example Row:
age (feature 1) | state (feature 2) | credit_score |
---|---|---|
10 | "CA" | 560 |
- 2.(Optional) You can also provide a dictionary mapping your column names to more verbose versions of them. This helps the embedding generator understand what each column means, in case the dataframe has column names that are not found in the vocabulary. For example:
delinq_6mnths
can be mapped todelinquencies_in_the_last_6_months
. This won't change the column names of your dataframe. - 3.Choose a model type for generating embeddings. Read about supported models here. In this example, we've chosen
distilbert-base-uncased
for performance and simplicity. - 4.Generate the embedding and assign it to a new column in your dataframe. In this example we named it
"tabular_embedding_vector"
. - 5.Log the whole dataframe to Arize. This means Arize will receive your data in both tabular and embedding formatting, which will assist in debugging and analysis in the platform. An example is presented below but refer to our SDK documentation for a complete list of attributes.
from arize.pandas.embeddings import EmbeddingGenerator, UseCases
# Instantiate the embeddding generator
generator = EmbeddingGeneratorForTabularFeatures(
model_name="distilbert-base-uncased",
tokenizer_max_length=512
)
# Select the columns from your dataframe to consider
selected_cols = [...]
# (Optional) Provide a mapping for more verbose column names
column_name_map = {...: ...}
# Generate tabular embeddings and assign them to a new column
df["tabular_embedding_vector"] = generator.generate_embeddings(
df,
selected_columns=selected_cols,
col_name_map=column_name_map # (OPTIONAL, can remove)
)
# Create embedding features dictionary
tabular_embedding_features = {
# Dictionary keys will be name of embedding feature in the app
"arize_tabular_embedding": EmbeddingColumnNames(
vector_column_name="tabular_embedding_vector",
),
}
# Log to Arize using the Arize pandas logger
response = arize_client.log(
dataframe=df,
model_id="tabular-model-with-embeddings",
model_version="1.0",
model_type=ModelTypes.REGRESSION,
metrics_validation=[Metrics.REGRESSION],
environment=Environments.PRODUCTION,
schema = Schema(
prediction_id_column_name="prediction_id",
timestamp_column_name="prediction_ts",
prediction_label_column_name="prediction_label",
actual_label_column_name="actual_label",
feature_column_names=feature_cols,
embedding_feature_column_names=tabular_embedding_features,
)
)
Once your embedding is logged to Arize, you can monitor for multivariate drift. To learn more about Embedding Drift, visit here.

Monitoring an Embedding Generated from Tabular Data
Click on a point on the drift over time graph above to visualize data points using UMAP. To learn more about UMAP, visit here.

Last modified 3mo ago