Storing models on disk
This feature is not available in GDS Sessions. |
The model catalog exists as long as the Neo4j instance is running. When Neo4j is restarted, models are no longer available in the catalog and need to be trained again. This can be prevented by storing a model on disk.
The location of the stored models can be configured via the configuration parameter gds.model.store_location
in the neo4j.conf
.
The location must be a directory and writable by the Neo4j process.
The |
Storing models from the catalog on disk
Models that can be stored
Syntax
CALL gds.model.store(
modelName: String,
failIfUnsupported: Boolean
)
YIELD
modelName: String,
storeMillis: Integer
Name | Type | Default | Optional | Description |
---|---|---|---|---|
modelName |
String |
|
no |
The name of a model. |
failIfUnsupported |
Boolean |
|
yes |
By default, the library will raise an error when trying to store a non-supported model. When set to |
Name | Type | Description |
---|---|---|
modelName |
String |
The name of the stored model. |
storeMillis |
Integer |
The number of milliseconds it took to store the model. |
Loading models from disk
This feature is not available in GDS Sessions. |
GDS will discover available models from the configured store location upon database startup. During discovery, only model metadata is loaded, not the actual model data. In order to use a stored model, it has to be explicitly loaded.
Syntax
CALL gds.model.load(modelName: String)
YIELD
modelName: String,
loadMillis: Integer
Name | Type | Default | Optional | Description |
---|---|---|---|---|
modelName |
String |
|
no |
The name of a model. |
Name | Type | Description |
---|---|---|
modelName |
String |
The name of the loaded model. |
loadMillis |
Integer |
The number of milliseconds it took to load the model. |
Example
CALL gds.model.load('my-model')
YIELD
modelName,
loadMillis
To verify if a model is loaded, we can use the gds.model.list
procedure.
The procedure returns flags to indicate if the model is stored and if the model is loaded into memory.
The operation is idempotent, and skips loading if the model is already loaded.
Deleting models from disk
This feature is not available in GDS Sessions. |
To remove a stored model from disk, it has to be deleted. This is different from dropping a model. Dropping a model will remove it from the in-memory model catalog, but not from disk. Deleting a model will remove it from disk, but keep it in the in-memory model catalog if it was already loaded.
Syntax
CALL gds.model.delete(modelName: String)
YIELD
modelName: String,
deleteMillis: Integer
Name | Type | Default | Optional | Description |
---|---|---|---|---|
modelName |
String |
|
no |
The name of a model. |
Name | Type | Description |
---|---|---|
modelName |
String |
The name of the loaded model. |
deleteMillis |
Integer |
The number of milliseconds it took to delete the model. |