ads.model.framework other package
Submodules
ads.model.artifact module
- exception ads.model.artifact.AritfactFolderStructureError(required_files: Tuple[str])
Bases:
Exception
- exception ads.model.artifact.ArtifactNestedFolderError(folder: str)
Bases:
Exception
- exception ads.model.artifact.ArtifactRequiredFilesError(required_files: Tuple[str])
Bases:
Exception
- class ads.model.artifact.ModelArtifact(artifact_dir: str, model_file_name: str, reload: Optional[bool] = False)
Bases:
object
The class that represents model artifacts. It is designed to help to generate and manage model artifacts.
Initializes a ModelArtifact instance.
- Parameters
artifact_dir (str) – The local artifact folder to store the files needed for deployment.
model_file_name (str) – The file name of the serialized model.
reload ((bool, optional). Defaults to False.) – Determine whether will reload the Model into the env.
- Returns
A ModelArtifact instance.
- Return type
- Raises
ValueError – If artifact_dir not provided. If model_file_name not provided.
- classmethod from_uri(uri: str, artifact_dir: str, model_file_name: str, force_overwrite: Optional[bool] = False, auth: Optional[Dict] = None)
Constructs a ModelArtifact object from the existing model artifacts.
- Parameters
uri (str) – The URI of source artifact folder or achive. Can be local path or OCI object storage URI.
artifact_dir (str) – The local artifact folder to store the files needed for deployment.
model_file_name ((str)) – The file name of the serialized model.
force_overwrite ((bool, optional). Defaults to False.) – Whether to overwrite existing files or not.
auth ((Dict, optional). Defaults to None.) – The default authetication is set using ads.set_auth API. If you need to override the default, use the ads.common.auth.api_keys or ads.common.auth.resource_principal to create appropriate authentication signer and kwargs required to instantiate IdentityClient object.
- Returns
A ModelArtifact instance
- Return type
- Raises
ValueError – If uri is equal to artifact_dir, and it not exists.
- prepare_runtime_yaml(inference_conda_env: str, inference_python_version: Optional[str] = None, training_conda_env: Optional[str] = None, training_python_version: Optional[str] = None, force_overwrite: bool = False, namespace: str = 'id19sfcrra6z', bucketname: str = 'service-conda-packs') None
Generate a runtime yaml file and save it to the artifact directory.
- Parameters
inference_conda_env ((str, optional). Defaults to None.) – The object storage path of conda pack which will be used in deployment. Can be either slug or object storage path of the conda pack. You can only pass in slugs if the conda pack is a service pack.
inference_python_version ((str, optional). Defaults to None.) – The python version which will be used in deployment.
training_conda_env ((str, optional). Defaults to None.) – The object storage path of conda pack used during training. Can be either slug or object storage path of the conda pack. You can only pass in slugs if the conda pack is a service pack.
training_python_version ((str, optional). Defaults to None.) – The python version used during training.
force_overwrite ((bool, optional). Defaults to False.) – Whether to overwrite existing files.
namespace ((str, optional)) – The namespace of region.
bucketname ((str, optional)) – The bucketname of service pack.
- Raises
ValueError – If neither slug or conda_env_uri is provided.
- Returns
A RuntimeInfo instance.
- Return type
- prepare_score_py(jinja_template_filename: str)
write score.py file.
- Parameters
jinja_template_filename (str.) – The jinja template file name.
- Returns
Nothing
- Return type
None
- reload()
Syncs the score.py to reload the model and predict function.
- Returns
Nothing
- Return type
None
ads.model.generic_model module
- class ads.model.generic_model.GenericModel(estimator: Callable, artifact_dir: str, properties: Optional[ModelProperties] = None, auth: Optional[Dict] = None, serialize: bool = True, **kwargs: dict)
Bases:
MetadataMixin
,Introspectable
Generic Model class which is the base class for all the frameworks including the unsupported frameworks.
- algorithm
The algorithm of the model.
- Type
str
- artifact_dir
Artifact directory to store the files needed for deployment.
- Type
str
- auth
Default authentication is set using the ads.set_auth API. To override the default, use the ads.common.auth.api_keys or ads.common.auth.resource_principal to create an authentication signer to instantiate an IdentityClient object.
- Type
Dict
- ds_client
The data science client used by model deployment.
- Type
DataScienceClient
- estimator
Any model object generated by sklearn framework
- Type
Callable
- framework
The framework of the model.
- Type
str
- hyperparameter
The hyperparameters of the estimator.
- Type
dict
- metadata_custom
The model custom metadata.
- Type
- metadata_provenance
The model provenance metadata.
- metadata_taxonomy
The model taxonomy metadata.
- model_artifact
This is built by calling prepare.
- Type
- model_deployment
A ModelDeployment instance.
- Type
- model_file_name
Name of the serialized model.
- Type
str
- model_id
The model ID.
- Type
str
- properties
ModelProperties object required to save and deploy model.
- Type
- runtime_info
A RuntimeInfo instance.
- Type
- schema_input
Schema describes the structure of the input data.
- Type
Schema
- schema_output
Schema describes the structure of the output data.
- Type
Schema
- serialize
Whether to serialize the model to pkl file by default. If False, you need to serialize the model manually, save it under artifact_dir and update the score.py manually.
- Type
bool
- version
The framework version of the model.
- Type
str
- delete_deployment(...)
Deletes the current model deployment.
- deploy(..., \*\*kwargs)
Deploys a model.
- from_model_artifact(uri, model_file_name, artifact_dir, ..., \*\*kwargs)
Loads model from the specified folder, or zip/tar archive.
- from_model_catalog(model_id, model_file_name, artifact_dir, ..., \*\*kwargs)
Loads model from model catalog.
- from_model_deployment(model_deployment_id, model_file_name, artifact_dir, ..., \*\*kwargs)
Loads model from model deployment.
- introspect(...)
Runs model introspection.
- predict(data, ...)
Returns prediction of input data run against the model deployment endpoint.
- prepare(..., \*\*kwargs)
Prepare and save the score.py, serialized model and runtime.yaml file.
- reload(...)
Reloads the model artifact files: score.py and the runtime.yaml.
- save(..., \*\*kwargs)
Saves model artifacts to the model catalog.
- summary_status(...)
Gets a summary table of the current status.
- verify(data, ...)
Tests if deployment works in local environment.
Examples
>>> import tempfile >>> from ads.model.generic_model import GenericModel
>>> class Toy: ... def predict(self, x): ... return x ** 2 >>> estimator = Toy()
>>> model = GenericModel(estimator=estimator, artifact_dir=tempfile.mkdtemp()) >>> model.summary_status() >>> model.prepare(inference_conda_env="oci://service-conda-packs@id19sfcrra6z/service_pack/cpu/Data Exploration and Manipulation for CPU Python 3.7/3.0/dataexpl_p37_cpu_v3", ... inference_python_version="3.7", ... model_file_name="toy_model.pkl", ... training_id=None, ... force_overwrite=True ... ) >>> model.verify(2) >>> model.save() >>> model.deploy() >>> model.predict(2) >>> model.delete_deployment()
GenericModel Constructor.
- Parameters
estimator ((Callable).) – Trained model.
artifact_dir (str) – Artifact directory to store the files needed for deployment.
properties ((ModelProperties, optional). Defaults to None.) – ModelProperties object required to save and deploy model.
auth ((Dict, optional). Defaults to None.) – The default authetication is set using ads.set_auth API. If you need to override the default, use the ads.common.auth.api_keys or ads.common.auth.resource_principal to create appropriate authentication signer and kwargs required to instantiate IdentityClient object.
serialize ((bool, optional). Defaults to True.) – Whether to serialize the model to pkl file by default. If False, you need to serialize the model manually, save it under artifact_dir and update the score.py manually.
- delete_deployment(wait_for_completion: bool = False)
Deletes the current deployment.
- Parameters
wait_for_completion ((bool, optional). Defaults to False.) – Whether to wait till completion.
- Raises
ValueError – if there is not deployment attached yet.:
- deploy(wait_for_completion: Optional[bool] = True, display_name: Optional[str] = None, description: Optional[str] = None, deployment_instance_shape: Optional[str] = None, deployment_instance_count: Optional[int] = None, deployment_bandwidth_mbps: Optional[int] = None, deployment_log_group_id: Optional[str] = None, deployment_access_log_id: Optional[str] = None, deployment_predict_log_id: Optional[str] = None, **kwargs: Dict) ModelDeployment
Deploys a model. The model needs to be saved to the model catalog at first.
- Parameters
wait_for_completion ((bool, optional). Defaults to True.) – Flag set for whether to wait for deployment to complete before proceeding.
display_name ((str, optional). Defaults to None.) – The name of the model.
description ((str, optional). Defaults to None.) – The description of the model.
deployment_instance_shape ((str, optional). Default to VM.Standard2.1.) – The shape of the instance used for deployment.
deployment_instance_count ((int, optional). Defaults to 1.) – The number of instance used for deployment.
deployment_bandwidth_mbps ((int, optional). Defaults to 10.) – The bandwidth limit on the load balancer in Mbps.
deployment_log_group_id ((str, optional). Defaults to None.) – The oci logging group id. The access log and predict log share the same log group.
deployment_access_log_id ((str, optional). Defaults to None.) – The access log OCID for the access logs. https://docs.oracle.com/en-us/iaas/data-science/using/model_dep_using_logging.htm
deployment_predict_log_id ((str, optional). Defaults to None.) – The predict log OCID for the predict logs. https://docs.oracle.com/en-us/iaas/data-science/using/model_dep_using_logging.htm
kwargs –
- project_id: (str, optional).
Project OCID. If not specified, the value will be taken from the environment variables.
- compartment_id(str, optional).
Compartment OCID. If not specified, the value will be taken from the environment variables.
- max_wait_time(int, optional). Defaults to 1200 seconds.
Maximum amount of time to wait in seconds. Negative implies infinite wait time.
- poll_interval(int, optional). Defaults to 60 seconds.
Poll interval in seconds.
- Returns
The ModelDeployment instance.
- Return type
- Raises
ValueError – If model_id is not specified.
- classmethod from_model_artifact(uri: str, model_file_name: str, artifact_dir: str, auth: Optional[Dict] = None, force_overwrite: Optional[bool] = False, properties: Optional[ModelProperties] = None, **kwargs: dict) GenericModel
Loads model from a folder, or zip/tar archive.
- Parameters
uri (str) – The folder path, ZIP file path, or TAR file path. It could contain a seriliazed model(required) as well as any files needed for deployment including: serialized model, runtime.yaml, score.py and etc. The content of the folder will be copied to the artifact_dir folder.
model_file_name (str) – The serialized model file name.
artifact_dir (str) – The artifact directory to store the files needed for deployment.
auth ((Dict, optional). Defaults to None.) – The default authetication is set using ads.set_auth API. If you need to override the default, use the ads.common.auth.api_keys or ads.common.auth.resource_principal to create appropriate authentication signer and kwargs required to instantiate IdentityClient object.
force_overwrite ((bool, optional). Defaults to False.) – Whether to overwrite existing files or not.
properties ((ModelProperties, optional). Defaults to None.) – ModelProperties object required to save and deploy model.
- Returns
An instance of GenericModel class.
- Return type
- Raises
ValueError – If model_file_name not provided.
- classmethod from_model_catalog(model_id: str, model_file_name: str, artifact_dir: str, auth: Optional[Dict] = None, force_overwrite: Optional[bool] = False, properties: Optional[Union[ModelProperties, Dict]] = None, **kwargs) GenericModel
Loads model from model catalog.
- Parameters
model_id (str) – The model OCID.
model_file_name ((str)) – The name of the serialized model.
artifact_dir (str) – The artifact directory to store the files needed for deployment. Will be created if not exists.
auth ((Dict, optional). Defaults to None.) – The default authetication is set using ads.set_auth API. If you need to override the default, use the ads.common.auth.api_keys or ads.common.auth.resource_principal to create appropriate authentication signer and kwargs required to instantiate IdentityClient object.
force_overwrite ((bool, optional). Defaults to False.) – Whether to overwrite existing files or not.
properties ((ModelProperties, optional). Defaults to None.) – ModelProperties object required to save and deploy model.
kwargs –
- compartment_id(str, optional)
Compartment OCID. If not specified, the value will be taken from the environment variables.
- timeout(int, optional). Defaults to 10 seconds.
The connection timeout in seconds for the client.
- Returns
An instance of GenericModel class.
- Return type
- classmethod from_model_deployment(model_deployment_id: str, model_file_name: str, artifact_dir: str, auth: Optional[Dict] = None, force_overwrite: Optional[bool] = False, properties: Optional[Union[ModelProperties, Dict]] = None, **kwargs) GenericModel
Loads model from model deployment.
- Parameters
model_deployment_id (str) – The model deployment OCID.
model_file_name ((str)) – The name of the serialized model.
artifact_dir (str) – The artifact directory to store the files needed for deployment. Will be created if not exists.
auth ((Dict, optional). Defaults to None.) – The default authetication is set using ads.set_auth API. If you need to override the default, use the ads.common.auth.api_keys or ads.common.auth.resource_principal to create appropriate authentication signer and kwargs required to instantiate IdentityClient object.
force_overwrite ((bool, optional). Defaults to False.) – Whether to overwrite existing files or not.
properties ((ModelProperties, optional). Defaults to None.) – ModelProperties object required to save and deploy model.
kwargs –
- compartment_id(str, optional)
Compartment OCID. If not specified, the value will be taken from the environment variables.
- timeout(int, optional). Defaults to 10 seconds.
The connection timeout in seconds for the client.
- Returns
An instance of GenericModel class.
- Return type
- introspect() DataFrame
Conducts instrospection.
- Returns
A pandas DataFrame which contains the instrospection results.
- Return type
pandas.DataFrame
- predict(data: Any) Dict[str, Any]
Returns prediction of input data run against the model deployment endpoint.
- Parameters
data (Any) – JSON serializable data for the prediction for onnx models, for local serialization method, data can be the data types that each framework support.
- Returns
Dictionary with the predicted values.
- Return type
Dict[str, Any]
- Raises
NotActiveDeploymentError – If model deployment process was not started or not finished yet.
ValueError – If data is empty or not JSON serializable.
- prepare(inference_conda_env: Optional[str] = None, inference_python_version: Optional[str] = None, training_conda_env: Optional[str] = None, training_python_version: Optional[str] = None, model_file_name: Optional[str] = None, as_onnx: bool = False, initial_types: Optional[List[Tuple]] = None, force_overwrite: bool = False, namespace: str = 'id19sfcrra6z', use_case_type: Optional[str] = None, X_sample: Optional[Union[list, tuple, Series, ndarray, DataFrame]] = None, y_sample: Optional[Union[list, tuple, Series, ndarray, DataFrame]] = None, training_script_path: Optional[str] = None, training_id: Optional[str] = None, ignore_pending_changes: bool = True, max_col_num: int = 2000, **kwargs: Dict) None
Prepare and save the score.py, serialized model and runtime.yaml file.
- Parameters
inference_conda_env ((str, optional). Defaults to None.) – Can be either slug or object storage path of the conda pack. You can only pass in slugs if the conda pack is a service pack.
inference_python_version ((str, optional). Defaults to None.) – Python version which will be used in deployment.
training_conda_env ((str, optional). Defaults to None.) – Can be either slug or object storage path of the conda pack. You can only pass in slugs if the conda pack is a service pack. If training_conda_env is not provided, training_conda_env will use the same value of training_conda_env.
training_python_version ((str, optional). Defaults to None.) – Python version used during training.
model_file_name ((str).) – Name of the serialized model.
as_onnx ((bool, optional). Defaults to False.) – Whether to serialize as onnx model.
initial_types ((list[Tuple], optional).) – Defaults to None. Only used for SklearnModel, LightGBMModel and XGBoostModel. Each element is a tuple of a variable name and a type. Check this link http://onnx.ai/sklearn-onnx/api_summary.html#id2 for more explanation and examples for initial_types.
force_overwrite ((bool, optional). Defaults to False.) – Whether to overwrite existing files.
namespace ((str, optional).) – Namespace of region. This is used for identifying which region the service pack is from when you pass a slug to inference_conda_env and training_conda_env.
use_case_type (str) – The use case type of the model. Use it through UserCaseType class or string provided in UseCaseType. For example, use_case_type=UseCaseType.BINARY_CLASSIFICATION or use_case_type=”binary_classification”. Check with UseCaseType class to see all supported types.
X_sample (Union[list, tuple, pd.Series, np.ndarray, pd.DataFrame]. Defaults to None.) – A sample of input data that will be used to generate input schema.
y_sample (Union[list, tuple, pd.Series, np.ndarray, pd.DataFrame]. Defaults to None.) – A sample of output data that will be used to generate output schema.
training_script_path (str. Defaults to None.) – Training script path.
training_id ((str, optional). Defaults to value from environment variables.) – The training OCID for model. Can be notebook session or job OCID.
ignore_pending_changes (bool. Defaults to False.) – whether to ignore the pending changes in the git.
max_col_num ((int, optional). Defaults to utils.DATA_SCHEMA_MAX_COL_NUM.) – Do not generate the input schema if the input has more than this number of features(columns).
kwargs –
- impute_values: (dict, optional).
The dictionary where the key is the column index(or names is accepted for pandas dataframe) and the value is the impute value for the corresponding column.
- Raises
FileExistsError – when files already exist but force_overwrite is False.:
ValueError – when inference_python_version is not provided, but also cannot be found through manifest file.:
- Returns
Nothing.
- Return type
None
- reload() None
Reloads the model artifact files: score.py and the runtime.yaml.
- Returns
Nothing.
- Return type
None
- save(display_name: Optional[str] = None, description: Optional[str] = None, freeform_tags: Optional[dict] = None, defined_tags: Optional[dict] = None, ignore_introspection: Optional[bool] = False, **kwargs) None
Saves model artifacts to the model catalog.
- Parameters
display_name ((str, optional). Defaults to None.) – The name of the model.
description ((str, optional). Defaults to None.) – The description of the model.
freeform_tags (Dict(str, str), Defaults to None.) – Freeform tags for the model.
defined_tags ((Dict(str, dict(str, object)), optional). Defaults to None.) – Defined tags for the model.
ignore_introspection ((bool, optional). Defaults to None.) – Determine whether to ignore the result of model introspection or not. If set to True, the save will ignore all model introspection errors.
kwargs –
- project_id: (str, optional).
Project OCID. If not specified, the value will be taken either from the environment variables or model properties.
- compartment_id(str, optional).
Compartment OCID. If not specified, the value will be taken either from the environment variables or model properties.
- timeout: (int, optional). Defaults to 10 seconds.
The connection timeout in seconds for the client.
- Raises
RuntimeInfoInconsistencyError – When .runtime_info is not synched with runtime.yaml file.
- Returns
Nothing
- Return type
None
- serialize_model(as_onnx: bool = False, initial_types: Optional[List[Tuple]] = None, force_overwrite: bool = False, X_sample: Optional[any] = None)
Serialize and save model using ONNX or model specific method.
- Parameters
as_onnx ((boolean, optional)) – If set as True, convert into ONNX model.
initial_types ((List[Tuple], optional)) – a python list. Each element is a tuple of a variable name and a data type.
force_overwrite ((boolean, optional)) – If set as True, overwrite serialized model if exists.
X_sample ((any, optional). Defaults to None.) – Contains model inputs such that model(X_sample) is a valid invocation of the model, used to valid model input type.
- Returns
Nothing
- Return type
None
- summary_status() DataFrame
A summary table of the current status.
- Returns
The summary stable of the current status.
- Return type
pd.DataFrame
- verify(data: Any) Dict[str, Any]
test if deployment works in local environment.
- Parameters
data (Any.) – Data used to test if deployment works in local environment.
- Returns
A dictionary which contains prediction results.
- Return type
Dict
- class ads.model.generic_model.ModelState(value)
Bases:
Enum
An enumeration.
- AVAILABLE = 'Available'
- DONE = 'Done'
- NEEDSACTION = 'Needs Action'
- NOTAVAILABLE = 'Not Available'
- exception ads.model.generic_model.NotActiveDeploymentError(state: str)
Bases:
Exception
- exception ads.model.generic_model.RuntimeInfoInconsistencyError
Bases:
Exception
- exception ads.model.generic_model.SerializeInputNotImplementedError
Bases:
NotImplementedError
- exception ads.model.generic_model.SerializeModelNotImplementedError
Bases:
NotImplementedError
- class ads.model.generic_model.SummaryStatus
Bases:
object
SummaryStatus class which track the status of the Model frameworks.
- update_action(detail: str, action: str) None
Updates the action of the summary status table of the corresponding detail.
- Parameters
detail ((str)) – Value of the detail in the Details column. Used to locate which row to update.
status ((str)) – New status to be updated for the row specified by detail.
- Returns
Nothing.
- Return type
None
- update_status(detail: str, status: str) None
Updates the status of the summary status table of the corresponding detail.
- Parameters
detail ((str)) – value of the detail in the Details column. Used to locate which row to update.
status ((str)) – new status to be updated for the row specified by detail.
- Returns
Nothing.
- Return type
None
ads.model.model_properties module
- class ads.model.model_properties.ModelProperties(inference_conda_env: Optional[str] = None, inference_python_version: Optional[str] = None, training_conda_env: Optional[str] = None, training_python_version: Optional[str] = None, training_resource_id: Optional[str] = None, training_script_path: Optional[str] = None, training_id: Optional[str] = None, compartment_id: Optional[str] = None, project_id: Optional[str] = None, deployment_instance_shape: Optional[str] = None, deployment_instance_count: Optional[int] = None, deployment_bandwidth_mbps: Optional[int] = None, deployment_log_group_id: Optional[str] = None, deployment_access_log_id: Optional[str] = None, deployment_predict_log_id: Optional[str] = None)
Bases:
BaseProperties
Represents properties required to save and deploy model.
- compartment_id: str = None
- deployment_access_log_id: str = None
- deployment_bandwidth_mbps: int = None
- deployment_instance_count: int = None
- deployment_instance_shape: str = None
- deployment_log_group_id: str = None
- deployment_predict_log_id: str = None
- inference_conda_env: str = None
- inference_python_version: str = None
- project_id: str = None
- training_conda_env: str = None
- training_id: str = None
- training_python_version: str = None
- training_resource_id: str = None
- training_script_path: str = None
ads.model.runtime.runtime_info module
- class ads.model.runtime.runtime_info.RuntimeInfo(model_artifact_version: str = '', model_deployment: ~ads.model.runtime.model_deployment_details.ModelDeploymentDetails = <factory>, model_provenance: ~ads.model.runtime.model_provenance_details.ModelProvenanceDetails = <factory>)
Bases:
DataClassSerializable
RuntimeInfo class which is the data class represenation of the runtime yaml file.
- classmethod from_env() RuntimeInfo
Popolate the RuntimeInfo from environment variables.
- Returns
A RuntimeInfo instance.
- Return type
- model_artifact_version: str = ''
- model_deployment: ModelDeploymentDetails
- model_provenance: ModelProvenanceDetails
- save()
Save the RuntimeInfo object into runtime.yaml file under the artifact directory.
- Returns
Nothing.
- Return type
None
ads.model.extractor.model_info_extractor_factory module
- class ads.model.extractor.model_info_extractor_factory.ModelInfoExtractorFactory
Bases:
object
Class that extract Model Taxonomy Metadata for all supported frameworks.
- static extract_info(model)
Extracts model taxonomy metadata.
- Parameters
model ([ADS model, sklearn, xgboost, lightgbm, keras, oracle_automl]) – The model object
- Returns
A dictionary with keys of Framework, FrameworkVersion, Algorithm, Hyperparameters of the model
- Return type
ModelTaxonomyMetadata
Examples
>>> from ads.common.model_info_extractor_factory import ModelInfoExtractorFactory >>> metadata_taxonomy = ModelInfoExtractorFactory.extract_info(model)
ads.model.extractor.model_artifact module
ads.model.extractor.automl_extractor module
- class ads.model.extractor.automl_extractor.AutoMLExtractor(model)
Bases:
ModelInfoExtractor
Class that extract model metadata from automl models.
- model
The model to extract metadata from.
- Type
object
- estimator
The estimator to extract metadata from.
- Type
object
- property algorithm
Extracts the algorithm of the model.
- Returns
The algorithm of the model.
- Return type
object
- property framework
Extracts the framework of the model.
- Returns
The framework of the model.
- Return type
str
- property hyperparameter
Extracts the hyperparameters of the model.
- Returns
The hyperparameters of the model.
- Return type
dict
- property version
Extracts the framework version of the model.
- Returns
The framework version of the model.
- Return type
str
ads.model.extractor.xgboost_extractor module
- class ads.model.extractor.xgboost_extractor.XgboostExtractor(model)
Bases:
ModelInfoExtractor
Class that extract model metadata from xgboost models.
- model
The model to extract metadata from.
- Type
object
- estimator
The estimator to extract metadata from.
- Type
object
- framework(self) str
Returns the framework of the model.
- algorithm(self) object
Returns the algorithm of the model.
- version(self) str
Returns the version of framework of the model.
- hyperparameter(self) dict
Returns the hyperparameter of the model.
- property algorithm
Extracts the algorithm of the model.
- Returns
The algorithm of the model.
- Return type
object
- property framework
Extracts the framework of the model.
- Returns
The framework of the model.
- Return type
str
- property hyperparameter
Extracts the hyperparameters of the model.
- Returns
The hyperparameters of the model.
- Return type
dict
- property version
Extracts the framework version of the model.
- Returns
The framework version of the model.
- Return type
str
ads.model.extractor.lightgbm_extractor module
- class ads.model.extractor.lightgbm_extractor.LightgbmExtractor(model)
Bases:
ModelInfoExtractor
Class that extract model metadata from lightgbm models.
- model
The model to extract metadata from.
- Type
object
- estimator
The estimator to extract metadata from.
- Type
object
- framework(self) str
Returns the framework of the model.
- algorithm(self) object
Returns the algorithm of the model.
- version(self) str
Returns the version of framework of the model.
- hyperparameter(self) dict
Returns the hyperparameter of the model.
- property algorithm
Extracts the algorithm of the model.
- Returns
The algorithm of the model.
- Return type
object
- property framework
Extracts the framework of the model.
- Returns
The framework of the model.
- Return type
str
- property hyperparameter
Extracts the hyperparameters of the model.
- Returns
The hyperparameters of the model.
- Return type
dict
- property version
Extracts the framework version of the model.
- Returns
The framework version of the model.
- Return type
str
ads.model.extractor.model_info_extractor module
- class ads.model.extractor.model_info_extractor.ModelInfoExtractor
Bases:
ABC
The base abstract class to extract model metadata.
- framework(self) str
Returns the framework of the model.
- algorithm(self) object
Returns the algorithm of the model.
- version(self) str
Returns the version of framework of the model.
- hyperparameter(self) dict
Returns the hyperparameter of the model.
- info(self) dict
Returns the model taxonomy metadata information.
- abstract algorithm()
The abstract method to extracts the algorithm of the model.
- Returns
The algorithm of the model.
- Return type
object
- abstract framework()
The abstract method to extracts the framework of the model.
- Returns
The framework of the model.
- Return type
str
- abstract hyperparameter()
The abstract method to extracts the hyperparameters of the model.
- Returns
The hyperparameter of the model.
- Return type
dict
- info()
Extracts the taxonomy metadata of the model.
- Returns
The taxonomy metadata of the model.
- Return type
dict
- abstract version()
The abstract method to extracts the framework version of the model.
- Returns
The framework version of the model.
- Return type
str
- ads.model.extractor.model_info_extractor.normalize_hyperparameter(data: Dict) dict
Converts all the fields to string to make sure it’s json serializable.
- Parameters
data (([Dict])) – The hyperparameter returned by the model.
- Returns
Normalized (json serializable) dictionary.
- Return type
Dict
ads.model.extractor.sklearn_extractor module
- class ads.model.extractor.sklearn_extractor.SklearnExtractor(model)
Bases:
ModelInfoExtractor
Class that extract model metadata from sklearn models.
- model
The model to extract metadata from.
- Type
object
- estimator
The estimator to extract metadata from.
- Type
object
- framework(self) str
Returns the framework of the model.
- algorithm(self) object
Returns the algorithm of the model.
- version(self) str
Returns the version of framework of the model.
- hyperparameter(self) dict
Returns the hyperparameter of the model.
- property algorithm
Extracts the algorithm of the model.
- Returns
The algorithm of the model.
- Return type
object
- property framework
Extracts the framework of the model.
- Returns
The framework of the model.
- Return type
str
- property hyperparameter
Extracts the hyperparameters of the model.
- Returns
The hyperparameters of the model.
- Return type
dict
- property version
Extracts the framework version of the model.
- Returns
The framework version of the model.
- Return type
str
ads.model.extractor.keras_extractor module
- class ads.model.extractor.keras_extractor.KerasExtractor(model)
Bases:
ModelInfoExtractor
Class that extract model metadata from keras models.
- model
The model to extract metadata from.
- Type
object
- estimator
The estimator to extract metadata from.
- Type
object
- property algorithm
Extracts the algorithm of the model.
- Returns
The algorithm of the model.
- Return type
object
- property framework
Extracts the framework of the model.
- Returns
The framework of the model.
- Return type
str
- property hyperparameter
Extracts the hyperparameters of the model.
- Returns
The hyperparameters of the model.
- Return type
dict
- property version
Extracts the framework version of the model.
- Returns
The framework version of the model.
- Return type
str
ads.model.extractor.tensorflow_extractor module
- class ads.model.extractor.tensorflow_extractor.TensorflowExtractor(model)
Bases:
ModelInfoExtractor
Class that extract model metadata from tensorflow models.
- model
The model to extract metadata from.
- Type
object
- estimator
The estimator to extract metadata from.
- Type
object
- framework(self) str
Returns the framework of the model.
- algorithm(self) object
Returns the algorithm of the model.
- version(self) str
Returns the version of framework of the model.
- hyperparameter(self) dict
Returns the hyperparameter of the model.
- property algorithm
Extracts the algorithm of the model.
- Returns
The algorithm of the model.
- Return type
object
- property framework
Extracts the framework of the model.
- Returns
The framework of the model.
- Return type
str
- property hyperparameter
Extracts the hyperparameters of the model.
- Returns
The hyperparameters of the model.
- Return type
dict
- property version
Extracts the framework version of the model.
- Returns
The framework version of the model.
- Return type
str
ads.model.extractor.pytorch_extractor module
- class ads.model.extractor.pytorch_extractor.PytorchExtractor(model)
Bases:
ModelInfoExtractor
Class that extract model metadata from pytorch models.
- model
The model to extract metadata from.
- Type
object
- estimator
The estimator to extract metadata from.
- Type
object
- framework(self) str
Returns the framework of the model.
- algorithm(self) object
Returns the algorithm of the model.
- version(self) str
Returns the version of framework of the model.
- hyperparameter(self) dict
Returns the hyperparameter of the model.
- property algorithm
Extracts the algorithm of the model.
- Returns
The algorithm of the model.
- Return type
object
- property framework
Extracts the framework of the model.
- Returns
The framework of the model.
- Return type
str
- property hyperparameter
Extracts the hyperparameters of the model.
- Returns
The hyperparameters of the model.
- Return type
dict
- property version
Extracts the framework version of the model.
- Returns
The framework version of the model.
- Return type
str