Checking if a model exists

We can check if a model is available in the catalog by looking up its name.

Syntax

Check if a model exists in the catalog:
CALL gds.model.exists([ sessionInfo: String or Map, ] modelName: String)
YIELD
    modelName: String,
    modelType: String,
    exists: Boolean
Table 1. Parameters
Name Type Default Optional Description

sessionInfo Aura Graph Analytics

String or Map

n/a

no

The name of the GDS Session on which the model might exist. Accepts the output of the helper function sessionInfo.

modelName

String

n/a

no

The name of a model.

Table 2. Results
Name Type Description

modelName

String

The name of a model.

modelType

String

The type of the model.

exists

Boolean

True, if the model exists in the model catalog.

Examples

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

Check an existing model

We can check if a model exists in the catalog by specifying its name.

Check if a model exists in the catalog:
CALL gds.model.exists('my-model1');
Table 3. Results
modelName modelType exists

"my-model1"

"example-model-type"

true

As we can see, the model does exist in the model catalog.

Check a non-existing model

If we instead use a non-existing model name, we will get a false value for the exists field.

Check if a model exists in the catalog:
CALL gds.model.exists('does-not-exist');
Table 4. Results
modelName modelType exists

"does-not-exist"

"n/a"

false

As we can see, this model does not exist in the model catalog. Since this model does not exist, its type is n/a.