-
Notifications
You must be signed in to change notification settings - Fork 132
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #44 from pcnfernando/master
Added Hoeffding Adaptive Tree Classification sample
- Loading branch information
Showing
7 changed files
with
67 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
19 changes: 19 additions & 0 deletions
19
modules/samples/artifacts/0045/hoeffding-adaptive-tree-sample.siddhi
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters