123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- package classifier;
- import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.Packet;
- import weka.clusterers.EM;
- import weka.core.Instance;
- import weka.core.Instances;
- public class EMClustering extends BasicPacketClassifier {
-
- private EM clusterer;
-
-
- public EMClustering() {
- clusterer = new EM();
- }
-
- @Override
- public void trainModel(Instances instances) {
- try {
- clusterer.buildClusterer(instances);
- } catch (Exception e) {
-
- e.printStackTrace();
- }
- }
- @Override
- public double classifyInstance(Instance instance, Packet origin) throws Exception {
-
- int x = clusterer.clusterInstance(instance);
-
- return (1-clusterer.distributionForInstance(instance)[x])*800;
- }
- @Override
- public long getClassificationStart() {
- return 3600000;
- }
- @Override
- public String getAlgoName() {
- return "EM";
- }
- }
|