LogoLogo
👨‍💻 API Reference📣 Release Notes📺 Request a Demo
  • Introduction to Fiddler
    • Monitor, Analyze, and Protect your ML Models and Gen AI Applications
  • Fiddler Doc Chatbot
  • First Steps
    • Getting Started With Fiddler Guardrails
    • Getting Started with LLM Monitoring
    • Getting Started with ML Model Observability
  • Tutorials & Quick Starts
    • LLM and GenAI
      • LLM Evaluation - Compare Outputs
      • LLM Monitoring - Simple
    • Fiddler Free Guardrails
      • Guardrails - Quick Start Guide
      • Guardrails - Faithfulness
      • Guardrails - Safety
      • Guardrails FAQ
    • ML Observability
      • ML Monitoring - Simple
      • ML Monitoring - NLP Inputs
      • ML Monitoring - Class Imbalance
      • ML Monitoring - Model Versions
      • ML Monitoring - Ranking
      • ML Monitoring - Regression
      • ML Monitoring - Feature Impact
      • ML Monitoring - CV Inputs
  • Glossary
    • Product Concepts
      • Baseline
      • Custom Metric
      • Data Drift
      • Embedding Visualization
      • Fiddler Guardrails
      • Fiddler Trust Service
      • LLM and GenAI Observability
      • Metric
      • Model Drift
      • Model Performance
      • ML Observability
      • Trust Score
  • Product Guide
    • LLM Application Monitoring & Protection
      • LLM-Based Metrics
      • Embedding Visualizations for LLM Monitoring and Analysis
      • Selecting Enrichments
      • Enrichments (Private Preview)
      • Guardrails for Proactive Application Protection
    • Optimize Your ML Models and LLMs with Fiddler's Comprehensive Monitoring
      • Alerts
      • Package-Based Alerts (Private Preview)
      • Class Imbalanced Data
      • Enhance ML and LLM Insights with Custom Metrics
      • Data Drift: Monitor Model Performance Changes with Fiddler's Insights
      • Ensuring Data Integrity in ML Models And LLMs
      • Embedding Visualization With UMAP
      • Fiddler Query Language
      • Model Versions
      • How to Effectively Use the Monitoring Chart UI
      • Performance Tracking
      • Model Segments: Analyze Cohorts for Performance Insights and Bias Detection
      • Statistics
      • Monitoring ML Model and LLM Traffic
      • Vector Monitoring
    • Enhance Model Insights with Fiddler's Slice and Explain
      • Events Table in RCA
      • Feature Analytics Creation
      • Metric Card Creation
      • Performance Charts Creation
      • Performance Charts Visualization
    • Master AI Monitoring: Create, Customize, and Compare Dashboards
      • Creating Dashboards
      • Dashboard Interactions
      • Dashboard Utilities
    • Adding and Editing Models in the UI
      • Model Editor UI
      • Model Schema Editing Guide
    • Fairness
    • Explainability
      • Model: Artifacts, Package, Surrogate
      • Global Explainability: Visualize Feature Impact and Importance in Fiddler
      • Point Explainability
      • Flexible Model Deployment
        • On Prem Manual Flexible Model Deployment XAI
  • Technical Reference
    • Python Client API Reference
    • Python Client Guides
      • Installation and Setup
      • Model Onboarding
        • Create a Project and Onboard a Model for Observation
        • Model Task Types
        • Customizing your Model Schema
        • Specifying Custom Missing Value Representations
      • Publishing Inference Data
        • Creating a Baseline Dataset
        • Publishing Batches Of Events
        • Publishing Ranking Events
        • Streaming Live Events
        • Updating Already Published Events
        • Deleting Events From Fiddler
      • Creating and Managing Alerts
      • Explainability Examples
        • Adding a Surrogate Model
        • Uploading Model Artifacts
        • Updating Model Artifacts
        • ML Framework Examples
          • Scikit Learn
          • Tensorflow HDF5
          • Tensorflow Savedmodel
          • Xgboost
        • Model Task Examples
          • Binary Classification
          • Multiclass Classification
          • Regression
          • Uploading A Ranking Model Artifact
    • Integrations
      • Data Pipeline Integrations
        • Airflow Integration
        • BigQuery Integration
        • Integration With S3
        • Kafka Integration
        • Sagemaker Integration
        • Snowflake Integration
      • ML Platform Integrations
        • Integrate Fiddler with Databricks for Model Monitoring and Explainability
        • Datadog Integration
        • ML Flow Integration
      • Alerting Integrations
        • PagerDuty Integration
    • Comprehensive REST API Reference
      • Projects REST API Guide
      • Model REST API Guide
      • File Upload REST API Guide
      • Custom Metrics REST API Guide
      • Segments REST API Guide
      • Baselines REST API Guide
      • Jobs REST API Guide
      • Alert Rules REST API Guide
      • Environments REST API Guide
      • Explainability REST API Guide
      • Server Info REST API Guide
      • Events REST API Guide
      • Fiddler Trust Service REST API Guide
    • Fiddler Free Guardrails Documentation
  • Configuration Guide
    • Authentication & Authorization
      • Adding Users
      • Overview of Role-Based Access Control
      • Email Authentication
      • Okta Integration
      • SSO with Azure AD
      • Ping Identity SAML SSO Integration
      • Mapping LDAP Groups & Users to Fiddler Teams
    • Application Settings
    • Supported Browsers
  • History
    • Release Notes
    • Python Client History
    • Compatibility Matrix
    • Product Maturity Definitions
Powered by GitBook

© 2024 Fiddler Labs, Inc.

On this page

Was this helpful?

  1. Technical Reference
  2. Python Client Guides
  3. Model Onboarding

Customizing your Model Schema

PreviousModel Task TypesNextSpecifying Custom Missing Value Representations

Last updated 1 month ago

Was this helpful?

There can be occasions when the fdl.ModelSchema object generated by fdl.Model.from_data infers a column's data type differently than the type intended by the model developer. In these cases you can modify the ModelSchema columns as needed prior to creating the model in Fiddler.

Let's walk through an example of how to do this.


Suppose you've loaded in a dataset as a pandas DataFrame.

import pandas as pd

df = pd.read_csv('example_dataset.csv')

Below is an example of what is displayed upon inspection.


You then create a fdl.Model object by inferring the column schema details from this DataFrame.

model = fdl.Model.from_data(
  name='my_model',
  project_id=PROJECT_ID,
  source=df,
)

Below is an example of what is displayed upon inspection of model.schema.

Upon inspection you may notice that a few things are off:

What's the downside of not making sure that ranges and categories are reviewed and properly set? A production traffic event that encodes a number outside of the specified value range or a category value that is not in the set of valid category values will further down the line be flagged as a so-called Data Integrity violation. Depending on the alerting config, this may result in an alert. It's also worth noting however that an event which has a violation in its columns is still processed, and metrics that can be generated are still generated.

The below examples demonstrate how to address each of the issues noted:

Modifying a Column’s Value Range

Let's say we want to modify the range of output_column in the above fdl.Model object to be [0.0, 1.0].

You can do this by setting the min and max of the output_column column.

model.schema['output_column'].min = 0.0
model.schema['output_column'].max = 1.0

Modifying a Column’s Possible Values

Let's say we want to modify the possible values of feature_3 to be ['Yes', 'No'].

You can do this by setting the categories of the feature_3 column.

model.schema['feature_3'].categories = ['Yes', 'No']

Modifying a Column’s Data Type

You can do this by setting the data_type of the feature_3 column.

model.schema['feature_3'].data_type = fdl.DataType.CATEGORY

Note: when converting a column to a CATEGORY, you must also set the the list of unique possible values:

model.schema['feature_3'].categories = ['Yes', 'No']

Note: if converting a column from numeric (integer or float) to a category, you must also remove the min/max numeric range values that were automatically calculated from the sample data.

model.schema['output_column'].min = None
model.schema['output_column'].max = None

A complete example might look like this:

sample_data_df = pd.read_csv('some.csv')

# configure your ModelSpec here
# model_spec = ...

# configure your ModelTask here, or use NOT_SET
# model_task = ...

# Infer your model's schema from a sample of data
ml_model = fdl.Model.from_data(
  source=sample_data_df,
  name=MODEL_NAME,
  version=VERSION_NAME,
  project_id=project.id,
  spec=model_spec,
  task=model_task
)

# Make any adjustments to the inferred ModelSchema BEFORE creating the model
ml_model.schema['feature_3'].data_type = fdl.DataType.CATEGORY
ml_model.schema['feature_3'].categories = ['0', '1']

# The original datatype was inferred as an integer, but we preferred a category.
# Clear out the min and max values derived from the sample data as it does not apply to categories
ml_model.schema['output_column'].min = None
ml_model.schema['output_column'].max = None

# Now create the model with the inferred schema and your overrides
ml_model.create()

The of output_column is set to [0.01, 0.99], when it should really be [0.0, 1.0].

There are no set for feature_3.

The of feature_3 is set to , when it should really be .

Let's say we want to modify the data type of feature_3 to be .

value range
possible values
data type

Need help? Contact us at .

💡
help@fiddler.ai
Tabular view of CSV data.
Raw output of the the ModelSchema object properties.
fdl.DataType.STRING
fdl.DataType.CATEGORY
fdl.DataType.CATEGORY