Running Decision Tree in Neo4j - clumsyspeedboat/Decision-Tree-Neo4j GitHub Wiki

This is an instruction on how to run decision tree in Neo4j according to Max de Marzi's blog

Click for Max de Marzi's blog

Click for Github Source Code

1. Clone the repository

The first step is to clone the repository from the link above

2. Build Maven file for the source code

The next step is to use maven, to build a jar-file with the procedure for this project. The user need to package the project with Maven. This step need to use software such as eclipse or IntelliJ.

3. Copy Jar file to Neo4j plugins directory

After the 2nd step a Jar file will be created.

The user then need to copy this file and paste it into the Neo4j plugins directory.

4. Copy two additional files to Neo4j plugins directory

The next step is to download 2 additional files (link below) and copy them into the Neo4j plugins directory.

commons-compiler-tests-3.0.8.jar

janino-3.0.8.jar

5. Edit Neo4j/conf/neo4j.conf file

Add the line below in to your Neo4j/conf/neo4j.conf file

*dbms.security.procedures.unrestricted=com.maxdemarzi. **

6. Create the Schema in Neo4j

Then to create the Schema in Neo4j. The user need to run the line below

CALL com.maxdemarzi.schema.generate

7. Create test data

Then create the test data in Neo4j

CREATE (tree:Tree { id: 'bar entrance' })

CREATE (over21_rule:Rule { name: 'Over 21?', parameter_names: 'age', parameter_types:'int', expression:'age >= 21' })

CREATE (gender_rule:Rule { name: 'Over 18 and female', parameter_names: 'age,gender', parameter_types:'int,String', expression:'(age >= 18) && gender.equals("female")' })

CREATE (answer_yes:Answer { id: 'yes'})

CREATE (answer_no:Answer { id: 'no'})

CREATE (tree)-[:HAS]->(over21_rule)

CREATE (over21_rule)-[:IS_TRUE]->(answer_yes)

CREATE (over21_rule)-[:IS_FALSE]->(gender_rule)

CREATE (gender_rule)-[:IS_TRUE]->(answer_yes)

CREATE (gender_rule)-[:IS_FALSE]->(answer_no)

8. Try to call the Decision Tree in Neo4j

To call the decision tree in Neo4j run the example lines below

CALL com.maxdemarzi.traverse.decision_tree('bar entrance', {gender:'male', age:'20'}) yield path return path;

CALL com.maxdemarzi.traverse.decision_tree('bar entrance', {gender:'female', age:'19'}) yield path return path;

CALL com.maxdemarzi.traverse.decision_tree('bar entrance', {gender:'male', age:'23'}) yield path return path;