Chapter 368. Weka Component
Since Camel 3.1
Only producer is supported
The Weka component provides access to the (Weka Data Mining) toolset.
Weka is tried and tested open source machine learning software that can be accessed through a graphical user interface, standard terminal applications, or a Java API. It is widely used for teaching, research, and industrial applications, contains a plethora of built-in tools for standard machine learning tasks, and additionally gives transparent access to well-known toolboxes such as scikit-learn, R, and Deeplearning4j.
Maven users will need to add the following dependency to their pom.xml
for this component:
368.1. URI format Copy linkLink copied to clipboard!
weka://cmd
weka://cmd
368.2. Options Copy linkLink copied to clipboard!
The Weka component supports 2 options, which are listed below.
Name | Description | Default | Type |
---|---|---|---|
lazyStartProducer (producer) | Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel’s routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing. | false | boolean |
basicPropertyBinding (advanced) | Whether the component should use basic property binding (Camel 2.x) or the newer property binding with additional capabilities | false | boolean |
The Weka endpoint is configured using URI syntax:
weka:command
weka:command
with the following path and query parameters:
368.2.1. Path Parameters (1 parameters): Copy linkLink copied to clipboard!
Name | Description | Default | Type |
---|---|---|---|
command | Required The command to use. The value can be one of: filter, model, read, write, push, pop, version | Command |
368.2.2. Query Parameters (12 parameters): Copy linkLink copied to clipboard!
Name | Description | Default | Type |
---|---|---|---|
lazyStartProducer (producer) | Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel’s routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing. | false | boolean |
basicPropertyBinding (advanced) | Whether the endpoint should use basic property binding (Camel 2.x) or the newer property binding with additional capabilities | false | boolean |
synchronous (advanced) | Sets whether synchronous processing should be strictly used, or Camel is allowed to use asynchronous processing (if supported). | false | boolean |
apply (filter) | The filter spec (i.e. Name Options) | String | |
build (model) | The classifier spec (i.e. Name Options) | String | |
dsname (model) | The named dataset to train the classifier with | String | |
folds (model) | Number of folds to use for cross-validation | 10 | int |
loadFrom (model) | Path to load the model from | String | |
saveTo (model) | Path to save the model to | String | |
seed (model) | An optional seed for the randomizer | 1 | int |
xval (model) | Flag on whether to use cross-validation with the current dataset | false | boolean |
path (write) | An in/out path for the read/write commands | String |
368.3. Karaf support Copy linkLink copied to clipboard!
This component is not supported in Karaf
368.4. Message Headers Copy linkLink copied to clipboard!
368.5. Samples Copy linkLink copied to clipboard!
368.5.1. Read + Filter + Write Copy linkLink copied to clipboard!
This first example shows how to read a CSV file with the file component and then pass it on to Weka. In Weka we apply a few filters to the data set and then pass it on to the file component for writing.
Here we do the same as above without use of the file component.
In this example, the client would provide the input path or some other supported type. Have a look at the WekaTypeConverters
for the set of supported input types.
368.5.2. Building a Model Copy linkLink copied to clipboard!
When building a model, we first choose the classification algorithm to use and then train it with some data. The result is the trained model that we can later use to classify unseen data.
Here we train J48 with 10 fold cross-validation.
368.5.3. Predicting a Class Copy linkLink copied to clipboard!
Here we use a Processor
to access functionality that is not directly available from endpoint URIs.
In case you come here directly and this syntax looks a bit overwhelming, you might want to have a brief look at the section about Nessus API Concepts.