Simple Bayes Classifier Example


PILOTS home     WCL home
Tutorial index     (Basic ExamplesProgrammingRunningLearning Model OverviewLinear Regression ExampleBayes Classifier Example)

In this example, a Bayes classifier learning model will be trained to 2 modes of relationships between b and a.

Mode Relationship
0 b/a = 2
1 b/a = 3

After training the model, this dynamic learning model will be tested with some input data and will be able to recognize when the input data matches these 2 trained modes as well as 2 new modes (which will be automatically categorized as mode 2 and mode 3.

Complete the following steps:

Build a PILOTS jar file

In $PILOTS_HOME, run the build script:

$ ./build.sh    // (for Windows, use build.bat instead)

After doing so, pilots.jar will be created under the $PILOTS_HOME/lib directory.

Configure aliases

In order to make sure that aliases for the plc and plcsim compiler commands are correctly figured as well as the definition of $PILOTS_HOME, make sure that you are in the root directory of the project and then use the following command:

source setenv

Add definition for dynamic Bayes classifier model:

python engineIO.py definitions/bayes_prediction_test.json

Run the learning model server:

In Terminal 1, run server.sh in pilots/util/learningmodel/engine

(note: you may need to wait a few seconds for the server to start up)

Add Data for Producers

Make sure that the following data file is added to data/PredictionTest_mode

Run the Output Handler:

In Terminal 2, make sure to call source setenv from the root directory, and then execute outputHandler in examples/PredictionTest

Compile and Run the PLT file:

In Terminal 3, make sure to call source setenv from the root directory, and then compile PredictionTest_mode.plt in examples/PredictionTest_mode using the command:

plcsim PredictionTest_mode.plt

In Terminal 3, compile the generated PredictionTest_mode.java in examples/PredictionTest_mode

javac PredictionTest_mode.java

In Terminal 3, execute the new PredictionTest_mode class file with the appropriate arguments. To simplify this process, execute the script PredictionTest_mode in examples/PredictionTest_mode

(Notice that the classpath is defined within this execution script.)

Run the Producer:

In Terminal 4, make sure to call source setenv from the root directory, and then (in order to produce the simulation) execute PredictionTest_modeProducer in examples/PredictionTest_mode

Output simulated data to the Output Handler:

In Terminal 3, press enter. (After this, some warning messages may appear in this terminal, but they do not hinder the simulation.)

Final Output

If these steps are executed correctly, you should observe the following output in the Output Handler (terminal 2):


Notice in this output that modes 0 and 1 were correctly identified in the appropriate moments in the input data (from the producer). Additionally, 2 new modes were dynamically discovered when (b/a) fell into significantly new patterns (which were b/a=4 and b/a=0.5).


Tutorial index     (Basic ExamplesProgrammingRunningLearning Model OverviewLinear Regression ExampleBayes Classifier Example)
PILOTS home     WCL home

Worldwide Computing Laboratory

Department of Computer Science

Rensselaer Polytechnic Institute