Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Hoeffding Adaptive Tree Classification sample #44

Merged
merged 5 commits into from
Sep 7, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions modules/samples/artifacts/0045/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Prerequisites:
Convert moa-2016.04.jar from https://mvnrepository.com/artifact/nz.ac.waikato.cms.moa/moa/2016.04
into osgi bundle and copy it into {WSO2SPHome}/lib folder

1. Copy {WSO2SPHome}/samples/artifacts/0045/hoeffding-adaptive-tree-sample.siddhi file to {WSO2SPHome}/deployment/siddhi-files

2. Copy {WSO2SPHome}/samples/artifacts/0045/train.json and test.json files to {WSO2SPHome}/deployment/simulation-configs

3. Copy {WSO2SPHome}/samples/artifacts/0045/hoeffdingTraining.csv and hoeffdingTesting.csv file to {WSO2SPHome}/deployment/csv-files

4. Start the worker using ./{WSO2SPHome}/bin/worker.sh

5. Run the following curl command to simulate classification with events in hoeffdingTraining.csv and hoeffdingTesting.csv
curl -X POST http://localhost:9090/simulation/feed/train/?action=run

curl -X POST http://localhost:9090/simulation/feed/test/?action=run

6. See the output in the WSO2SP terminal

Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
@App:name("hoeffding-adaptive-tree-sample")

define stream StreamTrain (attribute_0 double, attribute_1 double, attribute_2 double, attribute_3 double, attribute_4 string );

define stream StreamA (attribute_0 double, attribute_1 double, attribute_2 double, attribute_3 double);

@info(name = 'query-train')
from StreamTrain#streamingml:updateHoeffdingTree('model1', 4, attribute_0, attribute_1, attribute_2, attribute_3, attribute_4 )
select *
insert into trainOutputStream;

@info(name = 'query-predict')
from StreamA#streamingml:hoeffdingTreeClassifier('model1', attribute_0, attribute_1, attribute_2, attribute_3 )
select attribute_0, attribute_1, attribute_2, attribute_3, prediction, confidenceLevel
insert into outputStream;

from outputStream#log("LOGGER")
select *
insert into temp2;
6 changes: 6 additions & 0 deletions modules/samples/artifacts/0045/hoeffdingTesting.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
6.5,2.8,4.6,1.5
5.7,2.5,5,2
6.5,3,5.8,2.2
6.4,2.9,4.3,1.3
6.3,2.5,5,1.9

20 changes: 20 additions & 0 deletions modules/samples/artifacts/0045/hoeffdingTraining.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
6,2.2,4,1,versicolor
5.4,3.4,1.7,0.2,setosa
6.9,3.1,5.4,2.1,virginica
4.3,3,1.1,0.1,setosa
6.1,2.8,4.7,1.2,versicolor
4.9,3,1.4,0.2,setosa
5.5,2.5,4,1.3,versicolor
5.4,3.9,1.3,0.4,setosa
4.3,3,1.1,0.1,setosa
6.8,2.8,4.8,1.4,versicolor
6.4,3.1,5.5,1.8,virginica
6.8,3,5.5,2.1,virginica
6.1,2.6,5.6,1.4,virginica
7.4,2.8,6.1,1.9,virginica
4.8,3.4,1.9,0.2,setosa
5.8,2.7,4.1,1,versicolor
5.1,2.5,3,1.1,versicolor
6.3,2.8,5.1,1.5,virginica
7.7,3.8,6.7,2.2,virginica
5.1,3.8,1.6,0.2,setosa
1 change: 1 addition & 0 deletions modules/samples/artifacts/0045/test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"properties":{"simulationName":"test","startTimestamp":"","endTimestamp":"","noOfEvents":"5","description":"","timeInterval":""},"sources":[{"siddhiAppName":"hoeffding-adaptive-tree-sample","streamName":"StreamA","timeInterval":"1000","simulationType":"CSV_SIMULATION","fileName":"hoeffdingTesting.csv","delimiter":",","isOrdered":true}]}
1 change: 1 addition & 0 deletions modules/samples/artifacts/0045/train.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"properties":{"simulationName":"train","startTimestamp":"","endTimestamp":"","noOfEvents":"20","description":"","timeInterval":""},"sources":[{"siddhiAppName":"hoeffding-adaptive-tree-sample","streamName":"StreamTrain","timeInterval":"1000","simulationType":"CSV_SIMULATION","fileName":"hoeffdingTraining.csv","delimiter":",","isOrdered":true}]}
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -799,7 +799,7 @@
<siddhi.execution.math.version>4.0.1</siddhi.execution.math.version>
<siddhi.execution.stat.version>1.0.1</siddhi.execution.stat.version>
<siddhi.execution.timeseries.version>4.0.1</siddhi.execution.timeseries.version>
<siddhi.execution.streamingml.version>1.0.0</siddhi.execution.streamingml.version>
<siddhi.execution.streamingml.version>1.0.1</siddhi.execution.streamingml.version>
<siddhi.execution.geo.version>4.0.0</siddhi.execution.geo.version>
<siddhi.script.js.version>4.0.1</siddhi.script.js.version>
<siddhi.io.jms.version>1.0.5</siddhi.io.jms.version>
Expand Down