12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- package classifier;
- import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.Packet;
- import weka.clusterers.HierarchicalClusterer;
- import weka.core.EuclideanDistance;
- import weka.core.Instance;
- import weka.core.Instances;
- public class HierarchicalClustering extends BasicPacketClassifier {
-
- private HierarchicalClusterer clusterer;
-
-
- public HierarchicalClustering() {
- clusterer = new HierarchicalClusterer();
- clusterer.setDistanceFunction(new EuclideanDistance());
- clusterer.setNumClusters(16);
- }
-
- @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;
- }
- @Override
- public long getClassificationStart() {
- return 3600000;
- }
- @Override
- public String getAlgoName() {
- return "HC";
- }
- }
|