EMClustering.java 996 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. package classifier;
  2. import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.Packet;
  3. import weka.clusterers.EM;
  4. import weka.core.Instance;
  5. import weka.core.Instances;
  6. /**
  7. * Expectation Maximization Clustering Approach
  8. * @author Andreas T. Meyer-Berg
  9. */
  10. public class EMClustering extends BasicPacketClassifier {
  11. /**
  12. * EM cluster which is used
  13. */
  14. private EM clusterer;
  15. /**
  16. * Initialize the clusterer
  17. */
  18. public EMClustering() {
  19. clusterer = new EM();
  20. }
  21. @Override
  22. public void trainModel(Instances instances) {
  23. try {
  24. clusterer.buildClusterer(instances);
  25. } catch (Exception e) {
  26. // TODO Auto-generated catch block
  27. e.printStackTrace();
  28. }
  29. }
  30. @Override
  31. public void classifyInstance(Instance instance, Packet origin) throws Exception {
  32. clusterer.clusterInstance(instance);
  33. }
  34. @Override
  35. public long getClassificationStart() {
  36. return 3600000;
  37. }
  38. @Override
  39. public String getAlgoName() {
  40. return "EM";
  41. }
  42. }