Search code examples
oraclemachine-learningk-means

How can I persist an Oracle Machine Learning (OML) k-means model?


This example doesn’t show how to save the k-means cluster model into the database. Is there a way to do that and is there example code for it?

Oracle Machine Learning for Python

Here's how I create the model,

# Create a KM model object and fit it.
km_mod = oml.km(n_clusters = 3, **setting).fit(data)

Solution

  • Use the model_name parameter. To provide a persistent model name during the model build:

    km_mod = oml.km(n_clusters = 3, **setting).fit(data, model_name = "MY_KM_MODEL")
    

    Or, rename a model with a new user-specified model name:

    km_mod.model_name = 'MY_KM_MODEL'
    km_mod.model_name
     'MY_KM_MODEL'