检查模型是否存在

我们可以通过查找模型的名称来检查模型是否在目录中可用。

语法

检查模型是否在目录中存在
CALL gds.model.exists(modelName: String)
YIELD
    modelName: String,
    modelType: String,
    exists: Boolean
表 1. 参数
名称 类型 默认值 可选 描述

modelName

字符串

N/A

模型的名称。

表 2. 结果
名称 类型 描述

modelName

字符串

模型的名称。

modelType

字符串

模型的类型。

exists

布尔值

如果模型存在于模型目录中,则为 True。

示例

本节我们将演示 gds.model.exists 的用法。为简单起见,我们假设一个名为 my-model1 的示例模型已经过训练并存在于模型目录中。

检查现有模型

我们可以通过指定模型的名称来检查模型是否在目录中存在。

检查模型是否在目录中存在
CALL gds.model.exists('my-model1');
表 3. 结果
modelName modelType exists

"my-model1"

"example-model-type"

true

如我们所见,该模型确实存在于模型目录中。

检查不存在的模型

如果我们使用一个不存在的模型名称,exists 字段将返回 false 值。

检查模型是否在目录中存在
CALL gds.model.exists('does-not-exist');
表 4. 结果
modelName modelType exists

"does-not-exist"

"N/A"

false

如我们所见,该模型不存在于模型目录中。由于此模型不存在,其类型为 N/A

© . All rights reserved.