Integrate scikit learn ML models into cypher policies

In this approach, you can deploy an externally trained ML model using Neo4j's Graph Data Science (GDS) library. GDS is a built-in Neo4j library that provides a variety of graph-based algorithms and machine learning functions, including support for training and deploying ML models on graph data. To deploy an externally trained ML model using GDS, you can follow these general steps:

  1. Train your ML model using your preferred machine learning framework, and save the trained model to a format that can be loaded by GDS (e.g., ONNX).
  2. Load your graph data into Neo4j.
  3. Use GDS to load your trained model into Neo4j. You can use the gds.alpha.ml.loadModel function to load your model from a file, and specify the name of the model and any additional configuration options (e.g., batch size).
  4. Use GDS to make predictions on your graph data using your loaded model. You can use the gds.beta.ml.predict function to apply your loaded model to your graph data, and specify any additional configuration options (e.g., the names of the input and output node properties).

Is this approach valid? Can we load external ML models into neo4j and make predictions using cypher policies workflow?

Hello @asamalla and welcome to the Neo4j community :slight_smile:

I don't think it's possible, the gds.alpha.model.load() function only load models which have been created by Neo4j.

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.

It must be possible to hack and execute a model from another Neo4j database but that's all.

So, for now, you must do everything with GDS. But it could be great new feature. You should propose that feature on their GitHub.

Best regards,
Cobra