sasctl.pzmm.model_parameters#

class sasctl.pzmm.model_parameters.ModelParameters[source]#

Bases: object

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:
  • model (str, 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:
  • model (Any) – Python object representing the model.

  • model_prefix (str) – Name used to create model files. (e.g. (model_prefix) + “Hyperparameters.json”)

  • pickle_path (str, pathlib.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:

model (str, 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:
  • project (str, dict, RestObj) – The name or id of the project, or a dictionary representation of the project.

  • server (str, optional) – SAS Viya 4 server where the MM_STD_KPI table exists. The default value is “cas-shared-default”.

  • caslib (str, optional) – SAS Viya 4 caslib where the MM_STD_KPI table exists. The default value is “ModelPerformanceData”.

  • filter_column (str, optional) – Column name from the MM_STD_KPI table to be filtered. The default value is None.

  • filter_value (str, optional) – Column value filter by. The default value is None

Returns:

kpi_table_df (pandas.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:
  • project (str, dict, or RestObj) – The name or id of the project, or a dictionary representation of the project.

  • server (str, optional) – Server on which the KPI data table is stored. The default value is “cas-shared-default”.

  • caslib (str, optional) – CAS Library on which the KPI data table is stored. The default value is “ModelPerformanceData”.