Skip to main content
Version: 4.4

Registry Operation

Register a Model in Model Registryโ€‹

Create and Register the new version of the model in model registry.

# Initializing RandomForestClassifier
from katonic.ml.classification import Classifier

clf = Classifier(
X_train,
X_test,
y_train,
y_test,
exp_name,
source_name,
features,
)
clf.RandomForestClassifier()
clf.register_model(
model_name='my-new-exp_21_gradient_boosting_classifier_tuned',
run_id='91ebd975b96f40348523ce924976de0b',
)
>>> name: "my-new-exp_21_gradient_boosting_classifier_tuned"
>>> version: "1"
>>> creation_timestamp: 1648556401684
>>> last_updated_timestamp: 1648556401701
>>> user_id: ""
>>> current_stage: "None"
>>> description: ""
source: "s3://models/14/91ebd975b96f40348523ce924976de0b/artifacts/my-new-exp_21_gradient_boosting_classifier_tuned"
>>> run_id: "91ebd975b96f40348523ce924976de0b"
>>> status: READY
>>> run_link: ""

Change Stage of the Modelโ€‹

Transit a model to given stage in Model Registry. Staging, Production or Archived.

clf.change_stage(
model_name='my-new-exp_21_gradient_boosting_classifier_tuned',
ver_list=['1'],
stage="Staging"
)

s

clf.change_stage(
model_name='my-new-exp_21_gradient_boosting_classifier_tuned',
ver_list=['1'],
stage="Archived"
)

View Model Versionsโ€‹

This function returns the model versions if match with filter string.

from katonic.ml.util import model_versions
model_versions(model_name='my-new-exp_21_gradient_boosting_classifier_tuned')

Output

['1']

View Previous Model Versionโ€‹

Return list of all previous versions of registered model.

from katonic.ml.util import previous_version
previous_version(model_name='my-new-exp_21_gradient_boosting_classifier_tuned')
>>> ['1', '2']

Delete Model Versionโ€‹

Delete the model versions of given version list.

from katonic.ml.util import model_versions, delete_model_version
delete_model_version(
model_name='my-new-exp_21_gradient_boosting_classifier_tuned',
ver_list=['1']
)
model_versions(model_name='my-new-exp_21_gradient_boosting_classifier_tuned')

Output

['2', '3']

Delete Registered Modelโ€‹

Delete the register model of given model name.

from katonic.ml.util import delete_reg_model

delete_reg_model(
model_name='my-new-exp_21_gradient_boosting_classifier_tuned',
)

Upload Model Artifactsโ€‹

Store dataset as artifacts in model artifact.

from katonic.ml.classification import Classifier

clf = Classifier(
X_train,
X_test,
y_train,
y_test,
exp_name,
source_name,
features,
)
from katonic.ml.util import log_data
clf.log_data(
run_id='91ebd975b96f40348523ce924976de0b',
data_path="train.csv", # local-artifact-path
)

Load Modelโ€‹

  1. Load a model from a model URI in python function format.
from katonic.log.client import load_model
model_uri = "s3://models/21/91ebd975b96f40348523ce924976de0b/artifacts/my-new-exp_21_gradient_boosting_classifier_tuned"
load_model(model_uri)
>>> GradientBoostingClassifier(learning_rate=0.9, min_samples_leaf=5, n_estimators=90)
  1. Load a python function formatted model in Spark UDF.
model_uri = "s3://models/21/91ebd975b96f40348523ce924976de0b/artifacts/my-new-exp_21_gradient_boosting_classifier_tuned"
spark_udf(
spark, # Spark Session
model_uri
)

Delete Registered Modelโ€‹

Delete registered model versions.

from katonic.ml.util import delete_model_version
delete_model_version(
model_name='my-new-exp_21_gradient_boosting_classifier_tuned',
ver_list=['2']
)
model_versions(model_name='my-new-exp_21_gradient_boosting_classifier_tuned')

Output

['1', '3']