API Methods 3.x

Alerts

AlertRule

AlertRule object contains the below fields.

Parameter
Type
Default
Description

id

UUID

-

Unique identifier of the AlertRule.

name

str

-

Unique name of the AlertRule.

model

-

The associated model details.

project

-

The associated project details

baseline

None

The associated baseline.

segment

None

Details of segment for the alert.

priority

-

To set the priority for the AlertRule. Select from: 1. Priority.LOW 2. Priority.MEDIUM 3. Priority.HIGH.

compare_to

-

Select from the two: 1. CompareTo.RAW_VALUE 2. CompareTo.TIME_PERIOD

metric_id

Union[str, UUID]

-

critical_threshold

float

-

Critical alert is triggered when this value satisfies the condition to the selected metric_id.

condition

-

Select from: 1. AlertCondition.LESSER 2. AlertCondition.GREATER

bin_size

-

Bin size for example fdl.BinSize.HOUR.

columns

Optional[List[str]]

None

List of 1 or more column names for the rule to evaluate. Use ['__ANY__'] to evaluate all columns.

baseline_id

Optional[UUID]

None

UUID of the baseline for the alert.

segment_id

Optional[UUID]

None

UUID of segment for the alert

compare_bin_delta

Optional[int]

None

Indicates previous period for comparison e.g. for fdl.BinSize.DAY, compare_bin_delta=1 will compare 1 day back, compare_bin_delta=7 will compare 7 days back.

warning_threshold

Optional[float]

None

Warning alert is triggered when this value satisfies the condition to the selected metric_id.

created_at

datetime

-

The creation timestamp.

updated_at

datetime

-

The timestamp of most recent update.

evaluation_delay

int

0

Specifies a delay in hours before AlertRule is evaluated. The delay period must not exceed one year(8760 hours).

constructor()

Initialize a new AlertRule on Fiddler Platform.

Parameters

Parameter
Type
Default
Description

name

str

-

Unique name of the model

model_id

UUID

-

Details of the model.

metric_id

Union[str, UUID]

-

Type of alert metric UUID or enum.

columns

Optional[List[str]]

None

List of column names on which AlertRule is to be created. It can take ['__ANY__'] to check for all columns.

baseline_id

Optional[UUID]

None

UUID of the baseline for the alert.

segment_id

Optional[UUID]

None

UUID of the segment for the alert.

priority

-

To set the priority for the AlertRule. Select from: 1. Priority.LOW 2. Priority.MEDIUM 3. Priority.HIGH.

compare_to

-

Select from the two: 1. CompareTo.RAW_VALUE (absolute alert) 2. CompareTo.TIME_PERIOD (relative alert)

compare_bin_delta

Optional[int]

None

Compare the metric to a previous time period in units of bin_size.

warning_threshold

Optional[float]

None

Threshold value to crossing which a warning level severity alert will be triggered.

critical_threshold

float

-

Threshold value to crossing which a critical level severity alert will be triggered.

condition

-

Select from: 1. AlertCondition.LESSER 2. AlertCondition.GREATER

bin_size

-

Size of the bin for AlertRule.

evaluation_delay

int

0

To introduce a delay in the evaluation of the alert, specifying the duration in hours. The delay period must not exceed one year(8760 hours).

Usage

MODEL_NAME = 'test_model'
PROJECT_NAME = 'test_project'
BASELINE_NAME = 'test_baseline'
SEGMENT_NAME = 'test_segment'

project = fdl.Project.from_name(name=PROJECT_NAME)
model = fdl.Model.from_name(name=MODEL_NAME, project_id=project.id)
baseline = fdl.Baseline.from_name(name=BASELINE_NAME, model_id=model.id)
segment = fdl.Segment.from_name(name=SEGMENT_NAME, model_id=model.id)

alert_rule = fdl.AlertRule(
    name='Bank Churn Drift Hawaii Region',
    model_id=model.id,
    baseline_id=baseline.id,
    metric_id='jsd',
    priority=fdl.Priority.HIGH,
    compare_to=fdl.CompareTo.TIME_PERIOD,
    compare_bin_delta=1,
    condition=fdl.AlertCondition.GREATER,
    bin_size=fdl.BinSize.DAY,
    critical_threshold=0.5,
    warning_threshold=0.1,
    columns=['gender', 'creditscore'],
    segment_id=segment.id,
    evaluation_delay=1
)

create()

Create a new AlertRule.

Parameters

No

Usage

MODEL_NAME = 'test_model'
PROJECT_NAME = 'test_project'
BASELINE_NAME = 'test_baseline'
SEGMENT_NAME = 'test_segment'

project = fdl.Project.from_name(name=PROJECT_NAME)
model = fdl.Model.from_name(name=MODEL_NAME, project_id=project.id)
baseline = fdl.Baseline.from_name(name=BASELINE_NAME, model_id=model.id)
segment = fdl.Segment.from_name(name=SEGMENT_NAME, model_id=model.id)

alert_rule = fdl.AlertRule(
    name='Bank Churn Drift Hawaii Region',
    model_id=model.id,
    baseline_id=baseline.id,
    metric_id='jsd',
    priority=fdl.Priority.HIGH,
    compare_to=fdl.CompareTo.TIME_PERIOD,
    compare_bin_delta=1,
    condition=fdl.AlertCondition.GREATER,
    bin_size=fdl.BinSize.DAY,
    critical_threshold=0.5,
    warning_threshold=0.1,
    columns=['gender', 'creditscore'],
    segment_id=segment.id,
    evaluation_delay=1
).create()

Returns

Return Type
Description

AlertRule instance.

get()

Get a single AlertRule.

Parameters

Parameter
Type
Default
Description

id_

UUID

-

Unique identifier for the AlertRule.

Usage

ALERT_RULE_ID='ed8f18e6-c319-4374-8884-71126a6bab85'

alert = fdl.AlertRule.get(id_=ALERT_RULE_ID)

Returns

Return Type
Description

AlertRule instance.

Raises

Error code
Issue

NotFound

AlertRule with given identifier not found.

Forbidden

Current user may not have permission to view details of AlertRule.


list()

Get a list of AlertRules .

Parameters

Parameter
Type
Default
Description

model_id

Union[str, UUID]

None

Unique identifier for the model to which AlertRule belongs.

project_id

Optional[UUID]

None

Unique identifier for the project to which AlertRule belongs

metric_id

Optional[UUID]

None

Type of alert metric UUID or enum.

columns

Optional[List[str]]

None

List of column names on which AlertRule is to be created. It can take ['ANY'] to check for all columns.

baseline_id

Optional[UUID]

None

UUID of the baseline for the AlertRule.

ordering

Optional[List[str]]

None

List of AlertRule fields to order by. Eg. [‘alert_time_bucket’] or [‘- alert_time_bucket’] for descending order.

Usage

MODEL_ID = '299c7b40-b87c-4dad-bb94-251dbcd3cbdf'

alerts = fdl.AlertRule.list(model_id=MODEL_ID)

Returns

Return Type
Description

Iterator of AlertRule instances.


delete()

Delete an existing AlertRule.

Parameters

Parameter
Type
Default
Description

id_

UUID

-

Unique UUID of the AlertRule .

Usage

MODEL_ID = '299c7b40-b87c-4dad-bb94-251dbcd3cbdf'
ALERT_RULE_NAME = 'Testing Alert API'

alert_rules = fdl.AlertRule.list(model_id=MODEL_ID)

for alert_rule in alert_rules:
    if alert_rule.name == ALERT_RULE_NAME:
        alert_rule.delete()
        break

Returns

No

Raises

Error code
Issue

NotFound

AlertRule with given identifier not found.

Forbidden

Current user may not have permission to view details of AlertRule.


enable_notifications()

Enable an AlertRule's notification.

Parameters

Parameter
Type
Default
Description

id_

UUID

-

Unique UUID of the AlertRule .

Usage

ALERT_NAME = "YOUR_ALERT_NAME"
MODEL_ID = '299c7b40-b87c-4dad-bb94-251dbcd3cbdf'

alerts_list = fdl.AlertRule.list(model_id=MODEL_ID)
for alert_rule in alerts_list:
    if ALERT_NAME == alert.name:
        alert_rule.enable_notifications()
        break

Returns

None

Raises

Error code
Issue

NotFound

AlertRule with given identifier not found.

Forbidden

Current user may not have permission to view details of AlertRule.


disable_notifications()

Disable notifications for an AlertRule.

Parameters

Parameter
Type
Default
Description

id_

UUID

-

Unique UUID of the AlertRule .

Usage

ALERT_NAME = "YOUR_ALERT_NAME"
MODEL_ID = '299c7b40-b87c-4dad-bb94-251dbcd3cbdf'

alerts_list = fdl.AlertRule.list(model_id=MODEL_ID)
for alert_rule in alerts_list:
    if ALERT_NAME == alert.name:
        alert_rule.disable_notifications()

Returns

None

Raises

Error code
Issue

NotFound

AlertRule with given identifier not found.

Forbidden

Current user may not have permission to view details of AlertRule.


Alert Notifications

Alert notifications for an AlertRule.

Parameter
Type
Default
Description

emails

Optional[List[str]]

None

List of emails to send notification to.

PagerDuty_services

Optional[List[str]]

None

List of PagerDuty services to trigger the alert to.

PagerDuty_severity

Optional[str]

None

Severity of PagerDuty.

webhooks

Optional[List[UUID]]

None

set_notification_config()

Set NotificationConfig for an AlertRule.

Parameters

Parameter
Type
Default
Description

emails

Optional[List[str]]

None

List of emails to send notification to.

PagerDuty_services

Optional[List[str]]

None

List of PagerDuty services to trigger the alert to.

PagerDuty_severity

Optional[str]

None

Severity of PagerDuty.

webhooks

Optional[List[UUID]]

None

Usage

ALERT_RULE_ID = '72e8835b-cde2-4dd2-a435-a35d4b51196b'
rule = fdl.AlertRule.get(id_=ALERT_RULE_ID)

rule.set_notification_config(
  emails=['abc@xyz.com', 'admin@xyz.com'],
  webhooks=['8b403d99-530a-4c5a-a519-89688d65ddc1'], # Webhook UUID
  PagerDuty_services = ['PagerDuty_service_1','PagerDuty_service_2'], # PagerDuty service names
  PagerDuty_severity = 'critical' # Only applies to PagerDuty, ignored otherwise
)

Returns

Return Type
Description

NotificationConfig

Alert notification settings for an AlertRule.

If PagerDuty_severity is passed without specifying PagerDuty_services then the PagerDuty_severity is ignored.

Raises

Error code
Issue

BadRequest

All 4 input parameters are empty.

ValueError

Webhook ID is incorrect.

get_notification_config()

Get notification configuration for an AlertRule.

Parameters

None

Usage

ALERT_RULE_ID = '72e8835b-cde2-4dd2-a435-a35d4b51196b'
rule = fdl.AlertRule.get(id_=ALERT_RULE_ID)

rule.get_notification_config()

Returns

Return Type
Description

NotificationConfig

Alert notification settings for an AlertRule.

Raises

Error code
Issue

BadRequest

All 4 input parameters are empty.

ValueError

Webhook ID is incorrect.


Triggered Alerts

AlertRecord

An AlertRecord details an AlertRule's triggered alert.

Parameter
Type
Default
Description

id

UUID

-

Unique identifier for the triggered AlertRule.

alert_rule_id

UUID

-

Unique identifier for the AlertRule which needs to be triggered.

alert_run_start_time

int

-

Timestamp of AlertRule evaluation in epoch.

alert_time_bucket

int

-

Timestamp pointing to the start of the time bucket in epoch.

alert_value

float

-

Value of the metric for alert_time_bucket.

baseline_time_bucket

Optional[int]

None

Timestamp pointing to the start of the baseline time bucket in epoch, only if AlertRule is of 'time period' based comparison.

baseline_value

Optional[float]

None

Value of the metric for baseline_time_bucket.

is_alert

bool

-

Boolean to indicate if alert was supposed to be triggered.

severity

str

-

failure_reason

str

-

String message if there was a failure sending notification.

message

str

-

String message sent as a part of email notification.

feature_name

Optional[str]

None

Name of feature for which alert was triggered.

alert_record_main_version

int

-

Main version of triggered alert record in int, incremented when the value of severity changes.

alert_record_sub_version

int

-

Sub version of triggered alert record in int, incremented when another alert with same severity as before is triggered.

created_at

datetime

-

Time at which trigger AlertRule was created.

updated_at

datetime

-

Latest time at which trigger AlertRule was updated.

list()

List AlertRecords triggered for an AlertRule.

Parameters

Parameter
Type
Default
Description

alert_rule_id

UUID

-

Unique identifier for the AlertRule which needs to be triggered.

start_time

Optional[datetime]

None

Start time to filter trigger alerts in yyyy-MM-dd format, inclusive.

end_time

Optional[datetime]

None

End time to filter trigger alerts in yyyy-MM-dd format, inclusive.

ordering

Optional[List[str]]

None

List of AlertRule fields to order by. Eg. [‘alert_time_bucket’] or [‘- alert_time_bucket’] for descending order.

Usage

ALERT_NAME = "YOUR_ALERT_NAME"
MODEL_ID = '299c7b40-b87c-4dad-bb94-251dbcd3cbdf'
triggered_alerts = None

alerts_list = fdl.AlertRule.list(model_id=MODEL_ID)
for alert_rule in alerts_list:
    if ALERT_NAME == alert.name:
        triggered_alerts = fdl.AlertRecord.list(
            alert_rule_id=ALERT_RULE_ID,
            start_time=datetime(2024, 9, 1), # optional
            end_time=datetime(2024, 9, 24), # optional
            ordering = ['alert_time_bucket'], # ['-alert_time_bucket'] for descending sort, optional.
        )

Returns

Return Type
Description

Iterable of triggered AlertRule instances for an AlertRule.


Baselines

Baseline datasets are used for making comparisons with production data.

A baseline dataset should be sampled from your model's training set, so it can serve as a representation of what the model expects to see in production.

Baseline

Baseline object contains the below fields.

Parameter
Type
Default
Description

id

UUID

-

Unique identifier for the baseline.

name

str

-

Baseline name.

type_

-

Baseline type can be static (Pre-production or production) or rolling(production).

start_time

Optional[int]

None

Epoch to be used as start time for STATIC baseline.

end_time

Optional[int]

None

Epoch to be used as end time for STATIC baseline.

offset

Optional[int]

None

Offset in seconds relative to current time to be used for ROLLING baseline.

window_size

Optional[int]

None

Span of window in seconds to be used for ROLLING baseline.

row_count

Optional[int]

None

Number of rows in baseline.

model

-

Details of the model.

project

-

Details of the project to which the baseline belongs.

dataset

-

Details of the dataset from which baseline is derived.

created_at

datetime

-

Time at which baseline was created.

updated_at

datetime

-

Latest time at which baseline was updated.

constructor()

Initialize a new baseline instance.

Parameters

Parameter
Type
Default
Description

name

str

-

Unique name of the baseline.

model_id

UUID

-

Unique identifier for the model to add baseline to.

environment

-

Type of environment. Can either be PRE_PRODUCTION or PRODUCTION.

type_

-

Baseline type can be static (pre-production or production) or rolling(production).

dataset_id

Optional[UUID]

None

Unique identifier for the dataset on which the baseline is created.

start_time

Optional[int]

None

Epoch to be used as start time for STATIC baseline.

end_time

Optional[int]

None

Epoch to be used as end time for STATIC baseline.

offset_delta

Optional[int]

None

window_bin_size

Optional[str]

None

Usage

BASELINE_NAME = 'YOUR_BASELINE_NAME'
PROJECT_NAME = 'YOUR_PROJECT_NAME'
MODEL_NAME = 'YOUR_MODEL_NAME'
DATASET_NAME = 'YOUR_DATASET_NAME'

project = fdl.Project.from_name(name=PROJECT_NAME)
model = fdl.Model.from_name(name=MODEL_NAME, project_id=project.id)
dataset = fdl.Dataset.from_name(name=DATASET_NAME, model_id=model.id)

baseline = fdl.Baseline(
        name=BASELINE_NAME,
        model_id=model.id,
        environment=fdl.EnvType.PRE_PRODUCTION,
        dataset_id=dataset.id,
        type_=fdl.BaselineType.STATIC,
    )

create()

Adds a baseline to Fiddler.

Parameters

No

Usage

BASELINE_NAME = 'YOUR_BASELINE_NAME'
PROJECT_NAME = 'YOUR_PROJECT_NAME'
MODEL_NAME = 'YOUR_MODEL_NAME'
DATASET_NAME = 'YOUR_DATASET_NAME'

project = fdl.Project.from_name(name=PROJECT_NAME)
model = fdl.Model.from_name(name=MODEL_NAME, project_id=project.id)
dataset = fdl.Dataset.from_name(name=DATASET_NAME, model_id=model.id)

baseline = fdl.Baseline(
        name=BASELINE_NAME,
        model_id=model.id,
        environment=fdl.EnvType.PRE_PRODUCTION,
        dataset_id=dataset.id,
        type_=fdl.BaselineType.STATIC,
    ).create()

Returns

Return Type
Description

Baseline instance.

Raises

Error code
Issue

Conflict

Baseline with same name may exist in project .

NotFound

Given dataset may not exist in for the input model.

ValueError

Validation failures like wrong window size, start_time, end_time etc

get()

Get baseline from Fiddler Platform based on UUID.

Parameters

Parameter
Type
Default
Description

id_

UUID

-

Unique identifier for the baseline.

Usage

BASELINE_ID = 'af05646f-0cef-4638-84c9-0d195df2575d'
baseline = fdl.Baseline.get(id_=BASELINE_ID)

Returns

Return Type
Description

Baseline instance.

Raises

Error code
Issue

NotFound

Baseline with given identifier not found.

Forbidden

Current user may not have permission to view details of baseline.


from_name()

Get baseline from Fiddler Platform based on name.

Parameters

Parameter
Type
Default
Description

name

str

-

Name of the baseline.

model_id

UUID | str

-

Unique identifier for the model.

Usage

BASELINE_NAME = 'YOUR_BASELINE_NAME'
MODEL_ID = '4531bfd9-2ca2-4a7b-bb5a-136c8da09ca2'

baseline = fdl.Baseline.from_name(
    name=BASELINE_NAME,
    model_id=MODEL_ID
)

Returns

Return Type
Description

Baseline instance.

Raises

Error code
Issue

NotFound

Baseline with given identifier not found.

Forbidden

Current user may not have permission to view details of baseline.


list()

List all baselines accessible to user.

Parameters

Parameter
Type
Default
Description

model_id

UUID

-

UUID of the model associated with baseline.

Usage

MODEL_ID = '4531bfd9-2ca2-4a7b-bb5a-136c8da09ca2'
baselines = fdl.Baseline.list(model_id=MODEL_ID)

Returns

Return Type
Description

Iterable of all baseline objects.

Raises

Error code
Issue

Forbidden

Current user may not have permission to view details of baseline.


delete()

Deletes a baseline.

Parameters

Parameter
Type
Default
Description

id_

UUID

-

Unique UUID of the baseline .

Usage

BASELINE_NAME = 'YOUR_BASELINE_NAME'
MODEL_ID = '4531bfd9-2ca2-4a7b-bb5a-136c8da09ca2'

baseline = fdl.Baseline.from_name(name=BASELINE_NAME, model_id=MODEL_ID)
baseline.delete()

Returns

None

Raises

Error code
Issue

NotFound

Baseline with given identifier not found.

Forbidden

Current user may not have permission to delete baseline.


Custom Metrics

User-defined metrics to extend Fiddler's built-in metrics.

CustomMetric

CustomMetric object contains the below parameters.

Parameter
Type
Default
Description

id

UUID

-

Unique identifier for the custom metric.

name

str

-

Custom metric name.

model_id

UUID

-

UUID of the model in which the custom metric is being added.

definition

str

-

Definition of the custom metric.

description

Optional[str]

None

Description of the custom metric.

created_at

datetime

-

Time of creation of custom metric.

constructor()

Initialize a new custom metric.

Parameters

Parameter
Type
Default
Description

name

str

-

Custom metric name.

model_id

UUID

-

UUID of the model in which the custom metric is being added.

definition

str

-

Definition of the custom metric.

description

Optional[str]

None

Description of the custom metric.

Usage

METRIC_NAME = 'YOUR_CUSTOM_METRIC_NAME'
MODEL_ID = '4531bfd9-2ca2-4a7b-bb5a-136c8da09ca2'

metric = fdl.CustomMetric(
    name=METRIC_NAME,
    model_id=MODEL_ID,
    definition="average(if(\"spend_amount\">1000, \"spend_amount\", 0))", #Use Fiddler Query Language (FQL) to define your custom metrics
    description='Get average spend for users spending over $1000',
)

get()

Get CustomMetric from Fiddler Platform based on model UUID.

Parameters

Parameter
Type
Default
Description

model_id

UUID

-

UUID of the model associated with the custom metrics.

Usage

MODEL_ID = '4531bfd9-2ca2-4a7b-bb5a-136c8da09ca2'

metrics = fdl.CustomMetric.list(model_id=MODEL_ID)

Returns

Return Type
Description

Iterable of all custom metric objects.

Raises

Error code
Issue

Forbidden

Current user may not have permission to view details of custom metric.

from_name()

Get CustomMetric from Fiddler Platform based on name and model UUID.

Parameters

Parameter
Type
Default
Description

name

str

-

Name of the custom metric.

model_id

UUID | str

-

Unique identifier for the model.

Usage

METRIC_NAME = 'YOUR_CUSTOM_METRIC_NAME'
MODEL_ID = '4531bfd9-2ca2-4a7b-bb5a-136c8da09ca2'

metric = fdl.CustomMetric.from_name(
    name=METRIC_NAME,
    model_id=MODEL_ID
)

Returns

Return Type
Description

Custom Metric instance.

Raises

Error code
Issue

NotFound

Custom metric with given identifier not found.

Forbidden

Current user may not have permission to view details of custom metric.

create()

Creates a custom metric for a model on Fiddler Platform.

Parameters

None

Usage

METRIC_NAME = 'YOUR_CUSTOM_METRIC_NAME'
MODEL_ID = '4531bfd9-2ca2-4a7b-bb5a-136c8da09ca2'

metric = fdl.CustomMetric(
    name=METRIC_NAME,
    model_id=MODEL_ID,
    definition="average(if(\"spend_amount\">1000, \"spend_amount\", 0))", #Use Fiddler Query Language (FQL) to define your custom metrics
    description='Get average spend for users spending over $1000',
).create()

Returns

Return Type
Description

Custom Metric instance.

Raises

Error code
Issue

Conflict

Custom metric with same name may exist in project .

BadRequest

Invalid definition.

NotFound

Given model may not exist.

delete()

Delete a custom metric.

Parameters

Parameter
Type
Default
Description

id_

UUID

-

Unique UUID of the custom metric.

Usage

METRIC_NAME = 'YOUR_CUSTOM_METRIC_NAME'
MODEL_ID = '4531bfd9-2ca2-4a7b-bb5a-136c8da09ca2'

metric = fdl.CustomMetric.from_name(name=METRIC_NAME, model_id=MODEL_ID)
metric.delete()

Returns

No

Raises

Error code
Issue

NotFound

Custom metric with given identifier not found.

Forbidden

Current user may not have permission to delete custom metric.


Datasets

Datasets (or baseline datasets) are used for making comparisons with production data.


Dataset

Dataset object contains the below parameters.

Parameter
Type
Default
Description

id

UUID

-

Unique identifier for the dataset.

name

str

-

Dataset name.

row_count

int

None

Number of rows in dataset.

model_id

-

Unique identifier of the associated model

project_id

-

Unique identifier of the associated project


get()

Get dataset from Fiddler Platform based on UUID.

Parameters

Parameter
Type
Default
Description

id_

UUID

-

Unique identifier for the dataset.

Usage

DATASET_ID = 'ba6ec4e4-7188-44c5-ba84-c2cb22b4bb00'
dataset = fdl.Dataset.get(id_=DATASET_ID)

Returns

Return Type
Description

Dataset instance.

Raises

Error code
Issue

NotFound

Dataset with given identifier not found.

Forbidden

Current user may not have permission to view details of dataset.


from_name()

Get dataset from Fiddler Platform based on name and model UUID.

Usage params

Parameter
Type
Default
Description

name

str

-

Name of the dataset.

model_id

UUID | str

-

Unique identifier for the model.

Usage

DATASET_NAME = 'YOUR_DATASET_NAME'
MODEL_ID = '4531bfd9-2ca2-4a7b-bb5a-136c8da09ca2'

dataset = fdl.Dataset.from_name(
    name=DATASET_NAME,
    model_id=MODEL_ID
)

Returns

Return Type
Description

Dataset instance.

Raises

Error code
Issue

NotFound

Dataset not found in the given project name.

Forbidden

Current user may not have permission to view details of dataset.


list()

Get a list of all datasets associated to a model.

Parameters

Parameter
Type
Default
Description

model_id

UUID

-

UUID of the model associated with baseline.

Usage

MODEL_ID = '4531bfd9-2ca2-4a7b-bb5a-136c8da09ca2'

datasets = fdl.Dataset.list(model_id=MODEL_ID)

Returns

Return Type
Description

Iterable of all dataset objects.

Raises

Error code
Issue

Forbidden

Current user may not have permission to view details of dataset.


Jobs

A Job is used to track asynchronous processes such as batch publishing of data.

Job

Job object contains the below fields.

Parameter
Type
Default
Description

id

UUID

-

Unique identifier for the job.

name

str

-

Name of the job.

status

str

-

Current status of job.

progress

float

-

Progress of job completion.

info

dict

-

Dictionary containing resource_type, resource_name, project_name.

error_message

Optional[str]

None

Message for job failure, if any.

error_reason

Optional[str]

None

Reason for job failure, if any.

extras

Optional[dict]

None

Metadata regarding the job.

get()

Get the job instance using job UUID.

Parameters

Parameter
Type
Default
Description

id_

UUID

-

Unique UUID of the project to which model is associated.

verbose

bool

False

Flag to get extras metadata about the tasks executed.

Usage

JOB_ID = '1531bfd9-2ca2-4a7b-bb5a-136c8da09ca1'
job = fdl.Job.get(id_=JOB_ID)

Returns

Return Type
Description

Single job object for the input params.

Raises

Error code
Issue

Forbidden

Current user may not have permission to view details of job.


wait()

Wait for job to complete either with success or failure status.

Parameters

Parameter
Type
Default
Description

interval

Optional[int]

3

Interval in seconds between polling for job status.

timeout

Optional[int]

1800

Timeout in seconds for iterator to stop.

Usage

JOB_ID = '1531bfd9-2ca2-4a7b-bb5a-136c8da09ca1'
job = fdl.Job.get(id_=JOB_ID)
job.wait()

Returns

Return Type
Description

Single job object for the input params.

Raises

Error code
Issue

Forbidden

Current user may not have permission to view details of job.

TimeoutError

When the default time out of 1800 secs.

watch()

Watch job status at given interval and yield job object.

Parameters

Parameter
Type
Default
Description

interval

Optional[int]

3

Interval in seconds between polling for job status.

timeout

Optional[int]

1800

Timeout in seconds for iterator to stop.

Usage

JOB_ID = "69f846db-5aac-44fe-9fa5-14f40048e4b2"
job = fdl.Job.get(id_=JOB_ID)

for ijob in job.watch(interval=30, timeout=1200):
    print(f'Status: {ijob.status} - progress: {ijob.progress}')

Returns

Return Type
Description

Iterator of job objects.

Raises

Error code
Issue

Forbidden

Current user may not have permission to view details of job.

TimeoutError

When the default time out of 1800 secs.


Models

A Model is a representation of your machine learning model which can be used for monitoring, explainability, and more. You do not need to upload your model artifact in order to onboard your model, but doing so will significantly improve the quality of explanations generated by Fiddler.

Model

Model object contains the below parameters.

Parameter
Type
Default
Description

id

UUID

-

Unique identifier for the model.

name

str

-

Unique name of the model (only alphanumeric and underscores are allowed).

input_type

ModelInputType.TABULAR

Input data type used by the model.

task

ModelTask.NOT_SET

Task the model is designed to address.

task_params

-

Task parameters given to a particular model.

schema

-

Model schema defines the details of each column.

version

Optional[str]

-

Unique version name within a model

spec

-

Model spec defines how model columns are used along with model task.

description

str

-

Description of the model.

event_id_col

str

-

Column containing event id.

event_ts_col

str

-

Column containing event timestamp.

xai_params

-

Explainability parameters of the model.

artifact_status

str

-

Artifact Status of the model.

artifact_files

list[dict]

-

Dictionary containing file details of model artifact.

is_binary_ranking_model

bool

-

created_at

datetime

-

Time at which model was created.

updated_at

datetime

-

Latest time at which model was updated.

created_by

-

Details of the who created the model.

updated_by

-

Details of the who last updated the model.

project

-

Details of the project to which the model belongs.

organization

-

Details of the organization to which the model belongs.

constructor()

Initialize a new model instance.

Usage

model = fdl.Model(
    name='model_name',
    project_id=project.id,
    task=fdl.ModelTask.BINARY_CLASSIFICATION,
    task_params=fdl.ModelTaskParams(target_class_order=['no', 'yes']),
    schema=model_schema,
    spec=model_spec,
    event_id_col='column_name_1',
    event_ts_col='column_name_2',
)

Parameters

Parameter
Type
Default
Description

name

str

-

Unique name of the model

project_id

UUID

-

Unique identifier for the project to which model belongs.

input_type

ModelInputType.TABULAR

Input data type used by the model.

task

ModelTask.NOT_SET

Task the model is designed to address.

schema

-

Model schema defines the details of each column.

spec

-

Model spec defines how model columns are used along with model task.

version

Optional[str]

-

Unique version name within a model

task_params

-

Task parameters given to a particular model.

description

str

-

Description of the model.

event_id_col

str

-

Column containing event id.

event_ts_col

str

-

Column containing event timestamp.

xai_params

-

Explainability parameters of the model.

from_data()

Build model instance from the given dataframe or file(csv/parquet).

Parameters

Parameter
Type
Default
Description

source

pd.DataFrame | Path | str

-

Pandas dataframe or path to csv/parquet file

name

str

-

Unique name of the model

project_id

UUID | str

-

Unique identifier for the project to which model belongs.

input_type

ModelInputType.TABULAR

Input data type used by the model.

task

ModelTask.NOT_SET

Task the model is designed to address.

spec

-

Model spec defines how model columns are used along with model task.

version

Optional[str]

-

Unique version name within a model

task_params

-

Task parameters given to a particular model.

description

Optional[str]

-

Description of the model.

event_id_col

Optional[str]

-

Column containing event id.

event_ts_col

Optional[str]

-

Column containing event timestamp.

xai_params

-

Explainability parameters of the model.

max_cardinality

Optional[int]

None

Max cardinality to detect categorical columns.

sample_size

Optional[int]

-

No. of samples to use for generating schema.

Usage

MODEL_NAME = 'example_model'
PROJECT_ID = '1531bfd9-2ca2-4a7b-bb5a-136c8da09ca1'
MODEL_SPEC = {
  'custom_features': [],
  'decisions': ['Decisions'],
  'inputs': [
    'CreditScore',
    'Geography',
  ],
  'metadata': [],
  'outputs': ['probability_churned'],
  'schema_version': 1,
  'targets': ['Churned'],
}

# Without version
model = fdl.Model.from_data(
  source=<file_path>,
  name=MODEL_NAME,
  project_id=PROJECT_ID,
  spec=fdl.ModelSpec(**MODEL_SPEC),
)

# With version
model = fdl.Model.from_data(
  source=<file_path>,
  name=MODEL_NAME,
  version='v2',
  project_id=PROJECT_ID,
  spec=fdl.ModelSpec(**MODEL_SPEC),
)

Returns

Return Type
Description

Model instance.

Notes

  • from_data will not create a model entry on Fiddler Platform. Instead this method only returns a model instance which can be edited, call .create() to onboard the model to Fiddler Platform.

  • spec is optional to from_data method. However, a spec with at least inputs is required for model onboarding.

  • Make sure spec is passed to from_data method if model requires custom features. This method generates centroids which are needed for custom feature drift computation

  • If version is not explicitly passed, Fiddler Platform will treat it as v1 version of the model.

create()

Onboard a new model to Fiddler Platform

Parameters

No

Usage

model = fdl.Model.from_data(...)
model.create()

Returns

Return Type
Description

Model instance.

Raises

Error code
Issue

Conflict

Model with same name may exist in project .

get()

Get model from Fiddler Platform based on UUID.

Parameters

Parameter
Type
Default
Description

id_

UUID | str

-

Unique identifier for the model.

Returns

Return Type
Description

Model instance.

Raises

Error code
Issue

NotFound

Model with given identifier not found.

Forbidden

Current user may not have permission to view details of model.

Usage

MODEL_ID = '4531bfd9-2ca2-4a7b-bb5a-136c8da09ca2'
model = fdl.Model.get(id_=MODEL_ID)

from_name()

Get model from Fiddler Platform based on name and project UUID.

Parameters

Parameter
Type
Default
Description

name

str

-

Name of the model.

project_id

UUID | str

-

Unique identifier for the project.

version

Optional[str]

-

Unique version name within a model

version parameter is available from fiddler-client==3.1 onwards

Usage

PROJECT_NAME = 'YOUR_PROJECT_NAME'
MODEL_NAME = 'YOUR_MODEL_NAME'

PROJECT = fdl.Project.from_name(name=PROJECT_NAME)

# Without version
MODEL = fdl.Model.from_name(name=MODEL_NAME, project_id=PROJECT.id)

# With version
MODEL = fdl.Model.from_name(name=MODEL_NAME, project_id=PROJECT.id, version='v2')

Returns

Return Type
Description

Model instance.

Notes

  • When the version is not passed, then the model created without any version will be fetched. Fiddler internally assigns version=v1 when not passed.

  • When the version is passed, method will fetch the model corresponding to that specific version.

Raises

Error code
Issue

NotFound

Model not found in the given project name.

Forbidden

Current user may not have permission to view details of model.

list()

Gets all models of a project.

Parameters

Parameter
Type
Default
Description

project_id

UUID | str

-

Unique UUID of the project to which model is associated.

name

Optional[str]

-

Model name. Pass this to fetch all versions of a model.

Returns

Return Type
Description

Iterable of model compact objects.

Errors

Error code
Issue

Forbidden

Current user may not have permission to the given project.

Usage example

PROJECT_NAME = 'YOUR_PROJECT_NAME'
MODEL_NAME = 'YOUR_MODEL_NAME'

project = fdl.Project.from_name(name=PROJECT_NAME)

models = fdl.Model.list(project_id=project.id)

Notes

Since Model contains a lot of information, list operations does not return all the fields of a model. Instead this method returns ModelCompact objects on which .fetch() can be called to get the complete Model instance. For most of the use-cases, ModelCompact objects are sufficient.

update()

Update an existing model. Only following fields are allowed to be updated, backend will ignore if any other field is updated on the instance.

Parameters

Parameter
Type
Default
Description

version

Optional[str]

None

Model version name

xai_params

None

Explainability parameters of the model.

description

Optional[str]

None

Description of the model.

event_id_col

Optional[str]

None

Column containing event id.

event_ts_col

Optional[str]

None

Column containing event timestamp.

version parameter is available from fiddler-client==3.1 onwards

Usage

model.description = 'YOUR_MODEL_DESCRIPTION'
model.update()

Returns

No

Raises

Error code
Issue

BadRequest

If field is not updatable.

duplicate()

Duplicate the model instance with the given version name.

This call will not save the model on Fiddler Platform. After making changes to the model instance, call .create() to add the model version to Fiddler Platform.

Added in version 3.1.0

Parameters

Parameter
Type
Default
Description

version

Optional[str]

None

Model version name

Usage

PROJECT_ID = '1531bfd9-2ca2-4a7b-bb5a-136c8da09ca1'
MODEL_NAME = 'test_model'