/** Classifies the test set */ public void classifyTest() { // Start of training time Timer.resetTime(); classifyTestSet(); // End of test time Timer.setTestTime(); // Showing results System.out.println(name + " " + relation + " Test " + Timer.getTestTime() + "s"); } // end-method
/** Generates the model of the algorithm */ public void generateModel() { double newEpsilon; // Start of model time Timer.resetTime(); double term = 0.7 / (double) (nClasses - 1); // Initialization of the membership matrix // 0.7 is assigned to the labeled instance in the training // set. 0.3 is split between the rest of classes for (int i = 0; i < trainData.length; i++) { Arrays.fill(membership[i], term); membership[i][trainOutput[i]] = 0.3; } epsilon = Double.MAX_VALUE; newEpsilon = Double.MAX_VALUE; int iterations = 0; do { epsilon = newEpsilon; computeCentroids(); newEpsilon = computeMembership(); System.out.println("Iteration " + iterations + " Error: " + newEpsilon); iterations++; } while ((Math.abs(epsilon - newEpsilon) > delta) && (iterations < maxIterations)); // End of model time Timer.setModelTime(); // Showing results System.out.println(name + " " + relation + " Model " + Timer.getModelTime() + "s"); } // end-method