On Thu, Aug 30, 2007 at 02:10:29PM +0200, Marcin Zaj?czkowski wrote:
On 2007-08-30 04:00, Mark Hall wrote:
You would need to subclass FilteredClassifier. Be
aware that only some
filters can operate incrementally (weka.filters.StreamableFilter) as
is the case with classifiers.
I thought that weka.classifiers.UpdateableClassifier.
Many filters need to "see" all the training data before they can apply
their transformation (e.g. compute ranges for attributes, learn
discretization intervals etc.). Other filters can operate in a truely
incremental fashion, i.e. as soon as an input instance is available,
they can output a transformed instance.
Anyway I tried to do that "manually" (for a test). For an every message
from an update set I applied following procedure:
I fetch Classifier (which is Updateable - NaiveBayesUpdateable) and
Filter from FilteredClassifier:
UpdateableClassifier updateableClassifier =
Filter filter = filteredClassifier.getFilter();
This assumes an initial batch-trained scenario (unless the filter in
question is Streamable).
I normally create a instances' structure (Instances object).
Create a new instance (to be used in update method) like normal instance
used for training process.
Instance tempInstance = new Instance(2);
See this Wiki article on creating Instances programatically:
Add it to the created set.
Use an already read filter on it:
updateSet = Filter.useFilter(updateSet, filter);
Take a look at the "distributionForInstance()" method in
FilteredClassifier to see an example of how to apply a pre-trained
filter to a single instance.
Department of Computer Science
University of Waikato