Take direct input from neo4j to ML model

29 views Asked by At

I am using py2neo to connect neo4j and python. I am doing this.`

# Connect to the Neo4j database
graph = Graph("bolt://localhost:11003", auth=("neo4j", "12345678"))

# Use Cypher query to retrieve the graph data
data_X = graph.run("MATCH (n:Battery) RETURN n.cycle, n.voltage_measured, n.current_measured, n.temperature_measured,n.voltage_load  ")
data_y =graph.run("MATCH (n:Battery) RETURN n.time ")

` But I don't want to convert it into any other type like list or dataframe.So, can we do it without changing the data type i.e. py2neo.cypher.Cursor as direct model.

I tried

# Split the data into train and test sets
X_train, X_test, y_train, y_test = train_test_split(graph.run("MATCH (n:Battery) RETURN n.cycle, n.voltage_measured, n.current_measured, n.temperature_measured,n.voltage_load  "),graph.run("MATCH (n:Battery) RETURN n.time "), test_size=0.2)

But it shows Expected sequence or array-like, got <class 'py2neo.cypher.Cursor'>

1

There are 1 answers

1
jose_bacoy On

You should read the documentation of the function train_test_split in sklearn.

https://scikit-learn.org/stable/modules/generated/sklearn.model_selection.train_test_split.html

It reads quote: Allowed inputs are lists, numpy arrays, scipy-sparse matrices or pandas dataframes.

and py2neo.cypher.Cursor is NOT one of them.