Dropping models

If we no longer need a trained model and want to free up memory, we can drop the model from the catalog.

Syntax

Drop a model from the catalog:
CALL gds.model.drop(modelName: String, failIfMissing: Boolean)
YIELD
    modelName: String,
    modelType: String,
    modelInfo: Map,
    creationTime: DateTime,
    trainConfig: Map,
    graphSchema: Map,
    loaded: Boolean,
    stored: Boolean,
    published: Boolean
Table 1. Parameters
Name Type Default Optional Description

modelName

String

n/a

no

Name of a model stored in the catalog.

failIfMissing

Boolean

true

yes

Whether an error should be raised when the model does not exist. When set to false, the procedure returns an empty result if the model does not exist.

Table 2. Results
Name Type Description

modelName

String

Name of the model.

modelType

String

Type of the model. Indicates what training algorithm was used to train the model.

modelInfo

Map

Detailed type-specific information about the trained model.

creationTime

Datetime

Time when the model was created.

trainConfig

Map

Train configuration used for training the model.

graphSchema

Map

Schema of the graph on which the model was trained.

loaded

Boolean

True, if the model is loaded in the in-memory model catalog.

stored

Boolean

True, if the model is stored on disk.

published

Boolean

True, if the model has been published.

Examples

In this section we are going to demonstrate the usage of gds.model.drop. For simplicity, we will assume that an example model named my-model1 has already been trained and exists in the model catalog.

Dropping a model

To drop a model, we only need to specify its name.

Drop a model from the catalog:
CALL gds.model.drop('my-model1')
YIELD modelName, modelType, modelInfo, loaded, stored, published
Table 3. Results
modelName modelType modelInfo loaded stored published

"my-model1"

"example-model-type"

{exampleModelInfo="exampleValue"}

true

false

false

When dropping a model, we get a result that represents its state in the catalog just prior to being dropped. The dropped model is now no longer available in the catalog, which we can verify by running gds.model.list.

Listing a dropped model:
CALL gds.model.list('my-model1')
YIELD modelName, modelType, modelInfo, loaded, stored, published
Table 4. Results
modelName modelType modelInfo loaded stored published

Dropping a model that does not exist

If we try to drop a model that does not exist, an error is raised by default. To avoid this, we can set failIfMissing to false.

Dropping model from the catalog without failing:
CALL gds.model.drop('my-model1', false)
Table 5. Results
modelName modelType modelInfo creationTime trainConfig graphSchema loaded stored published

As we can see, the procedure returns an empty result instead of raising an error.