/** * Computes the given input to produce the corresponding output. * * @param inputs An input vector. * @param votes A vector containing the number of votes for each class. * @return The decision label for the given input. */ private int computeVoting(double[] inputs, int[] votes) { // Compute decision by Voting // out variables cannot be passed into delegates, // so will be creating a copy for the vote array. // int[] voting = new int[getClasses()]; // For each class for (int i = 0; i < getClasses(); i++) { // For each other class for (int j = 0; j < i; j++) { // Retrieve and compute the two-class problem for classes i x j double answer = machines[i - 1][j].Compute(inputs); // Determine the winner class int y = (answer < 0) ? i : j; // Increment votes for the winner votes[y]++; } } // Select class with maximum number of votes return Matrix.MaxIndex(votes); // Return the winner as the output. }