Model Utilities
Examples
Examples of using the Model Utilities are listed at the bottom of this page Examples.
Model Utilities for Workbench models
cleanlab_model_local(model)
Create a CleanlabModels instance for detecting data quality issues in a Model's training data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
Model
|
The Model used to create the cleanlab models |
required |
Returns:
| Name | Type | Description |
|---|---|---|
CleanlabModels |
CleanlabModels
|
Factory providing access to CleanLearning and Datalab models. - clean_learning(): CleanLearning model with enhanced get_label_issues() - datalab(): Datalab instance with report(), get_issues() |
Source code in src/workbench/utils/model_utils.py
fingerprint_prox_model_local(model, include_all_columns=False, radius=2, n_bits=2048)
Create a FingerprintProximity Model for this Model
Note: FingerprintProximity auto-detects binary vs. count fingerprints from the fingerprint column format (comma-separated → count, otherwise binary).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
Model
|
The Model used to create the fingerprint proximity model |
required |
include_all_columns
|
bool
|
Include all DataFrame columns in neighbor results (default: False) |
False
|
radius
|
int
|
Morgan fingerprint radius (default: 2) |
2
|
n_bits
|
int
|
Number of bits for the fingerprint (default: 2048) |
2048
|
Returns:
| Name | Type | Description |
|---|---|---|
FingerprintProximity |
FingerprintProximity
|
The fingerprint proximity model |
Source code in src/workbench/utils/model_utils.py
get_model_hyperparameters(workbench_model)
Get the hyperparameters used to train a Workbench model.
This retrieves the hyperparameters.json file from the model artifacts that was saved during model training.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
workbench_model
|
Any
|
Workbench model object |
required |
Returns:
| Name | Type | Description |
|---|---|---|
dict |
Optional[dict]
|
The hyperparameters used during training, or None if not found |
Source code in src/workbench/utils/model_utils.py
instance_architecture(instance_name)
Get the architecture for the given instance name
load_category_mappings_from_s3(model_artifact_uri)
Download and extract category mappings from a model artifact in S3.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_artifact_uri
|
str
|
S3 URI of the model artifact. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
dict |
Optional[dict]
|
The loaded category mappings or None if not found. |
Source code in src/workbench/utils/model_utils.py
load_hyperparameters_from_s3(model_artifact_uri)
Download and extract hyperparameters from a model artifact in S3.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_artifact_uri
|
str
|
S3 URI of the model artifact (model.tar.gz). |
required |
Returns:
| Name | Type | Description |
|---|---|---|
dict |
Optional[dict]
|
The loaded hyperparameters or None if not found. |
Source code in src/workbench/utils/model_utils.py
model_instance_info()
Get the instance information for the Model
Source code in src/workbench/utils/model_utils.py
noise_model_local(model)
Create a NoiseModel for detecting noisy/problematic samples in a Model's training data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
Model
|
The Model used to create the noise model |
required |
Returns:
| Name | Type | Description |
|---|---|---|
NoiseModel |
NoiseModel
|
The noise model with precomputed noise scores for all samples |
Source code in src/workbench/utils/model_utils.py
proximity_model_local(model, include_all_columns=False)
Create a FeatureSpaceProximity Model for this Model
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
Model
|
The Model/FeatureSet used to create the proximity model |
required |
include_all_columns
|
bool
|
Include all DataFrame columns in neighbor results (default: False) |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
FeatureSpaceProximity |
FeatureSpaceProximity
|
The proximity model |
Source code in src/workbench/utils/model_utils.py
published_proximity_model(model, prox_model_name, include_all_columns=False)
Create a published proximity model based on the given model
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
Model
|
The model to create the proximity model from |
required |
prox_model_name
|
str
|
The name of the proximity model to create |
required |
include_all_columns
|
bool
|
Include all DataFrame columns in results (default: False) |
False
|
Returns: Model: The proximity model
Source code in src/workbench/utils/model_utils.py
safe_extract_tarfile(tar_path, extract_path)
Extract a tarball safely, using data filter if available.
The filter parameter was backported to Python 3.8+, 3.9+, 3.10.13+, 3.11+ as a security patch, but may not be present in older patch versions.
Source code in src/workbench/utils/model_utils.py
supported_instance_types(arch='x86_64')
Get the supported instance types for the Model/Model
Source code in src/workbench/utils/model_utils.py
uq_metrics(df, target_col)
Evaluate uncertainty quantification model with essential metrics. Args: df: DataFrame with predictions and uncertainty estimates. Must contain the target column, a "prediction" column, and a "prediction_std" column (required for CRPS and median_std). Quantile columns ("q_025", "q_975", "q_05", "q_95", "q_10", "q_90", "q_25", "q_75") are used for coverage/width when present; otherwise Gaussian bounds are derived from "prediction_std". target_col: Name of the true target column in the DataFrame. Returns: Dictionary of computed metrics.
Source code in src/workbench/utils/model_utils.py
494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 | |
uq_model_local(model, version=None, refresh_proximity=False, radius=2, n_bits=2048)
Load the fitted UQModel (V0, V1, or V2) from this Model's artifact.
Pairs with the existing fp_prox_model() / proximity_model() factory pattern:
model = Model("my-model")
rm = model.uq_model()
out = rm.predict(test_df[["smiles"]], predictions, prediction_std)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
Model
|
The Workbench Model whose artifact contains a fitted UQModel. |
required |
version
|
Optional[str]
|
Which UQ version to load — |
None
|
refresh_proximity
|
bool
|
V1/V2 only. If False (default), use the proximity backend that was embedded in the model artifact at training time — exact reference set used to fit the residual estimator, reproducible, no fingerprint recomputation. If True, build a fresh FingerprintProximity from the current source FeatureSet. Ignored for V0 (no proximity). |
False
|
radius / n_bits
|
Morgan fingerprint parameters (only used for V1/V2 when refresh_proximity=True). |
required |
Returns:
| Type | Description |
|---|---|
|
A ready-to-use UQModelV0, UQModelV1, or UQModelV2 instance. |
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If the requested version's artifact is not in the bundle. |
Source code in src/workbench/utils/model_utils.py
Examples
Feature Importance
"""Example for using some Model Utilities"""
from workbench.utils.model_utils import feature_importance
model = Model("aqsol_classification")
feature_importance(model)
Output
[('mollogp', 469.0),
('minabsestateindex', 277.0),
('peoe_vsa8', 237.0),
('qed', 237.0),
('fpdensitymorgan1', 230.0),
('fpdensitymorgan3', 221.0),
('estate_vsa4', 220.0),
('bcut2d_logphi', 218.0),
('vsa_estate5', 218.0),
('vsa_estate4', 209.0),
Additional Resources

- Workbench API Classes: API Classes
- Consulting Available: SuperCowPowers LLC