-
Notifications
You must be signed in to change notification settings - Fork 6
Running Decision Tree in Neo4j
This is an instruction on how to run decision tree in Neo4j according to Max de Marzi's blog
The first step is to clone the repository from the link above
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.
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.
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
Add the line below in to your Neo4j/conf/neo4j.conf file
*dbms.security.procedures.unrestricted=com.maxdemarzi. **
Then to create the Schema in Neo4j. The user need to run the line below
CALL com.maxdemarzi.schema.generate
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)
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;







