sasctl.pzmm.model_parameters#
- class sasctl.pzmm.model_parameters.ModelParameters[source]#
Bases:
object
Methods
add_hyperparameters
(model, **kwargs)Adds custom hyperparameters to the hyperparameter file contained within the model in SAS Model Manager.
generate_hyperparameters
(model, ...)Generates hyperparameters for a given model and creates a JSON file representation.
get_hyperparameters
(model)Retrieves the hyperparameter json file from specified model on SAS Model Manager.
get_project_kpis
(project[, server, caslib, ...])Create a call to CAS to return the MM_STD_KPI table (SAS Model Manager Standard KPI) generated when custom KPIs are uploaded or when a performance definition is executed on SAS Model Manager on SAS Viya 4.
update_kpis
(project[, server, caslib])Updates hyperparameter file to include KPIs generated by performance definitions, as well as any custom KPIs imported by user to the SAS KPI data table.
sync_model_properties
- classmethod add_hyperparameters(model: str | dict | RestObj, **kwargs) None [source]#
Adds custom hyperparameters to the hyperparameter file contained within the model in SAS Model Manager.
- Parameters:
- modelstr, dict, or RestObj
The name or id of the model, or a dictionary representation of the model.
- kwargs
Named variables pairs representing hyperparameters to be added to the hyperparameter file.
- static generate_hyperparameters(model: Any, model_prefix: str, pickle_path: str | Path) None [source]#
Generates hyperparameters for a given model and creates a JSON file representation.
Currently only supports generation of scikit-learn model hyperparameters.
This function creates a json file named {model_prefix}Hyperparameters.json.
- Parameters:
- modelPython object
Python object representing the model.
- model_prefixstr
Name used to create model files. (e.g. (model_prefix) + “Hyperparameters.json”)
- pickle_pathstr, Path
Directory location of model files.
- static get_hyperparameters(model: str | dict | RestObj) Tuple[dict, str] [source]#
Retrieves the hyperparameter json file from specified model on SAS Model Manager.
- Parameters:
- modelstr, dict, or RestObj
The name or id of the model, or a dictionary representation of the model.
- Returns:
- dict, str
Dictionary containing the contents of the hyperparameter file and the file name.
- static get_project_kpis(project: str | dict | RestObj, server: str | None = 'cas-shared-default', caslib: str | None = 'ModelPerformanceData', filter_column: str | None = None, filter_value: str | None = None) DataFrame [source]#
Create a call to CAS to return the MM_STD_KPI table (SAS Model Manager Standard KPI) generated when custom KPIs are uploaded or when a performance definition is executed on SAS Model Manager on SAS Viya 4.
Filtering options are available as additional arguments. The filtering is based on column name and column value. Currently, only exact matches are available when filtering by this method.
- Parameters:
- projectstr, dict, RestObj
The name or id of the project, or a dictionary representation of the project.
- serverstr, optional
SAS Viya 4 server where the MM_STD_KPI table exists. The default value is “cas-shared-default”.
- caslibstr, optional
SAS Viya 4 caslib where the MM_STD_KPI table exists. The default value is “ModelPerformanceData”.
- filter_columnstr, optional
Column name from the MM_STD_KPI table to be filtered. The default value is None.
- filter_valuestr, optional
Column value filter by. The default value is None
- Returns:
- kpi_table_dfpandas DataFrame
A pandas DataFrame representing the MM_STD_KPI table. Note that SAS missing values are replaced with pandas-valid missing values.
- static sync_model_properties(project: str | dict | RestObj, overrwrite: bool | None = False)[source]#
- classmethod update_kpis(project: str | dict | RestObj, server: str | None = 'cas-shared-default', caslib: str | None = 'ModelPerformanceData') None [source]#
Updates hyperparameter file to include KPIs generated by performance definitions, as well as any custom KPIs imported by user to the SAS KPI data table.
- Parameters:
- projectstr, dict, or RestObj
The name or id of the project, or a dictionary representation of the project.
- serverstr, optional
Server on which the KPI data table is stored. The default value is “cas-shared-default”.
- caslibstr, optional
CAS Library on which the KPI data table is stored. The default value is “ModelPerformanceData”.