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 CleanLearning model for detecting label issues in a Model's training data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
Model
|
The Model used to create the cleanlab model |
required |
Returns:
| Name | Type | Description |
|---|---|---|
CleanLearning |
A fitted cleanlab model. Use get_label_issues() to get |
|
|
a DataFrame with id_column, label_quality, predicted_label, given_label, is_label_issue. |
Source code in src/workbench/utils/model_utils.py
fingerprint_prox_model_local(model, include_all_columns=False, radius=2, n_bits=1024, counts=False)
Create a FingerprintProximity Model for this Model
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: 1024) |
1024
|
counts
|
bool
|
Use count fingerprints instead of binary (default: False) |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
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 |
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 |
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 ("prediction"), and either quantile columns ("q_025", "q_975", "q_25", "q_75") or a standard deviation column ("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
380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 | |
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