00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 package de.picana.classifier;
00014
00015 import de.picana.control.*;
00016 import de.picana.math.*;
00017
00018 import weka.core.*;
00019 import java.io.*;
00020
00021
00028 public class EM extends Classifier {
00029
00030 private weka.clusterers.EM algo;
00031
00032
00034 public EM() {
00035 }
00036
00037 protected void loadModel(String filename) throws TaskException {
00038 try {
00039 File model = new File(filename);
00040 FileInputStream fmis = new FileInputStream(model);
00041 ObjectInputStream in = new ObjectInputStream(fmis);
00042
00043 num_clusters = in.readInt();
00044 algo = (weka.clusterers.EM)in.readObject();
00045 in.close();
00046
00047 } catch (Exception e) {
00048 throw new TaskException(e.toString());
00049 }
00050 }
00051
00052 protected int classify(Instance i) {
00053 int cl = -1;
00054 try {
00055 cl = algo.clusterInstance(i);
00056 } catch (Exception e) {
00057 }
00058 return cl;
00059 }
00060 }