Create a Project and Onboard a Model for Observation

This document explains the importance of creating a project in Fiddler to organize models and control access. It provides instructions on creating a project, listing all projects, defining a ModelSpec, and onboarding a model to Fiddler.

What is a Project?

A project within Fiddler helps organize models under observation. Additionally, a project acts as the authorization unit to govern access to your models. To onboard a model to Fiddler, you must first have a project that you wish to associate it with. After connecting Fiddler's Python client to your environment, you can either create a new project or use an existing project to onboard a model.

Create a Project

You can create a Project by using the client's create_project function


PROJECT_NAME = 'quickstart_example'

## Create the Project
project = fdl.Project(name=PROJECT_NAME)
project.create()
print(f'New project created with id = {project.id}')

## Please be mindful that the Project name must be unique,should not have spaces or special characters.

You should now see the newly created project on the UI.

List All Projects

Using an existing project, you may list all the projects that you are authorized to view.

for project in fdl.Project.list():
    print(f'Project: {project.id} - {project.name}')
    
## This will print ALL project IDs and Names that you have access to.

Onboarding a Model

To onboard a model you need to define a ModelSpec and optionally a Model Task. If you do not specify a model task during Model creation then you can update it after the model creation.

Define the ModelSpec

A ModelSpec object defines what each column of your inference data is. The model spec translates to model's schema in Fiddler

Fiddler supports five columns types:

  1. Inputs (features),
  2. Outputs (predictions),
  3. Targets (ground truth labels),
  4. Metadata (additional information passed along with the inference)
  5. Custom features (additional information that Fiddler should generate like embeddings or enrichments)
##Define the Model Spec

model_spec = fdl.ModelSpec(
    inputs=['CreditScore', 'Geography', 'Gender', 'Age', 'Tenure', 'Balance', 'NumOfProducts', 'HasCrCard', 'IsActiveMember', 'EstimatedSalary'],
    outputs=['probability_churned'],
    targets=['Churned'],
    decisions=[],
    metadata=[],
    custom_features=[],
)

Define the Model task

Fiddler supports a variety of model tasks. Create a ModelTask object and an additional ModelTaskParams object to specify the ordering of labels. For a detailed breakdown of all supported model tasks, click here.

model_task = fdl.ModelTask.BINARY_CLASSIFICATION
task_params = fdl.ModelTaskParams(target_class_order=['no', 'yes'])

Edit the Model Schema (Optional)

Onboard the Model

Onboard the model schema to Fiddler by passing in the data sample dataframe, the ModelSpec object, the ModelTask and ModelTaskParams objects, and the event/inference ID column and the event/inference timestamp columns:

MODEL_NAME = 'my_model'

model = fdl.Model.from_data(
    name=MODEL_NAME,
    project_id=fdl.Project.from_name(PROJECT_NAME).id,
    source=sample_df,
    spec=model_spec,
    task=model_task,
    task_params=task_params,
    event_id_col=id_column,
    event_ts_col=timestamp_column
)

model.create()