Model Utilities
Examples
Examples of using the Model Utilities are listed at the bottom of this page Examples.
Model Utilities for Workbench models
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
model_instance_info()
Get the instance information for the Model
Source code in src/workbench/utils/model_utils.py
proximity_model(model, prox_model_name, track_columns=None)
Create a 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 |
track_columns
|
list
|
List of columns to track in the proximity model |
None
|
Returns: Model: The proximity model
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
200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 |
|
uq_model(model, uq_model_name, train_all_data=False)
Create a Uncertainty Quantification (UQ) model based on the given model
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model
|
Model
|
The model to create the UQ model from |
required |
uq_model_name
|
str
|
The name of the UQ model to create |
required |
train_all_data
|
bool
|
Whether to train the UQ model on all data (default: False) |
False
|
Returns:
Name | Type | Description |
---|---|---|
Model |
Model
|
The UQ model |
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