sets the output-format for ClojureBatchFilter to use the process fn format
This commit is contained in:
parent
adff41dafe
commit
19a827d8b3
2 changed files with 16 additions and 7 deletions
|
@ -318,7 +318,8 @@
|
||||||
approach is to copy the Instance with the copy method or Instance
|
approach is to copy the Instance with the copy method or Instance
|
||||||
constructor and return a modified version of the copy.
|
constructor and return a modified version of the copy.
|
||||||
- :determine-dataset-format
|
- :determine-dataset-format
|
||||||
This function will receive the dataset's weka.core.Instances object.
|
This function will receive the dataset's weka.core.Instances object with
|
||||||
|
no actual Instance objects (i.e. just the format enocded in the attributes).
|
||||||
You must return a Instances object that contains the new format of the
|
You must return a Instances object that contains the new format of the
|
||||||
filtered dataset. Passing this fn is optional. If you are not changing
|
filtered dataset. Passing this fn is optional. If you are not changing
|
||||||
the format of the dataset then by omitting a function will use the
|
the format of the dataset then by omitting a function will use the
|
||||||
|
@ -335,13 +336,19 @@
|
||||||
- :process
|
- :process
|
||||||
This function will receive the entire dataset as a weka.core.Instances
|
This function will receive the entire dataset as a weka.core.Instances
|
||||||
objects. A processed Instances object should be returned with the
|
objects. A processed Instances object should be returned with the
|
||||||
new Instance objects added to it.
|
new Instance objects added to it. The format of the dataset (Instances)
|
||||||
|
that is returned from this will be returned from the filter (see below).
|
||||||
- :determine-dataset-format
|
- :determine-dataset-format
|
||||||
This function will receive the dataset's weka.core.Instances object.
|
This function will receive the dataset's weka.core.Instances object with
|
||||||
|
no actual Instance objects (i.e. just the format enocded in the attributes).
|
||||||
You must return a Instances object that contains the new format of the
|
You must return a Instances object that contains the new format of the
|
||||||
filtered dataset. Passing this fn is optional. If you are not changing
|
filtered dataset. Passing this fn is optional.
|
||||||
the format of the dataset then by omitting a function will use the
|
For many batch filters you need to process the entire dataset to determine
|
||||||
current format.
|
the correct format (e.g. filters that operate on nominal attributes). For
|
||||||
|
this reason the clj-batch filter will *always* use format of the dataset
|
||||||
|
that the process fn outputs. In other words, if you need to operate on the
|
||||||
|
entire dataset before determining the format then this should be done in the
|
||||||
|
process-fn and nothing needs to be passed for this fn.
|
||||||
|
|
||||||
For examples on how to use the filters, especially the clojure filters, you may
|
For examples on how to use the filters, especially the clojure filters, you may
|
||||||
refer to filters_test.clj of clj-ml."
|
refer to filters_test.clj of clj-ml."
|
||||||
|
|
|
@ -51,7 +51,9 @@ public class ClojureBatchFilter
|
||||||
|
|
||||||
protected Instances process(Instances instances) throws Exception {
|
protected Instances process(Instances instances) throws Exception {
|
||||||
try {
|
try {
|
||||||
return (Instances) processFn.invoke((Object) instances);
|
Instances result = (Instances) processFn.invoke((Object) instances);
|
||||||
|
this.setOutputFormat(result);
|
||||||
|
return result;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// Weka silently eats any exceptions in filters so we need to report on it...
|
// Weka silently eats any exceptions in filters so we need to report on it...
|
||||||
System.out.println("Unable to filter instances (dataset) with a clojure fn! The exception was:\n" +
|
System.out.println("Unable to filter instances (dataset) with a clojure fn! The exception was:\n" +
|
||||||
|
|
Loading…
Reference in a new issue