/**
   * Returns an array with the bevavior of the classifier with test dataset
   *
   * @param classifier Classifier to obtain the error
   * @return double[] Behavior array
   */
  public double[] getTestClassificationBehaviorArray(IClassifier classifier) {

    // Dataset to be used
    DoubleTransposedDataSet dataset;
    if (dataNormalized) dataset = scaledTestData;
    else dataset = unscaledTestData;

    // Resulting array
    double[] result = new double[dataset.getNofobservations()];

    // Obtained outputs with this dataSet
    byte obtained[][] = classifier.classify(dataset.getAllInputs());

    // Expected outputs
    double expected[][] = dataset.getAllOutputs();

    // Init result
    for (int j = 0; j < dataset.getNofobservations(); j++) result[j] = 1;

    // Put a 0 in observations where the expected is not
    // the same than the observed
    for (int o = 0; o < obtained.length; o++) // For each output (o)
    for (int e = 0; e < obtained[o].length; e++) // For each example (e)
      if (obtained[o][e] != expected[o][e]) if (result[e] == 1) result[e] = 0;

    return result;
  }
  /**
   * Returns the train error value of a neural net with an specified error function
   *
   * @param nnind Neural net to obtain the error
   * @param errorFunction Error function to obtain the error
   * @return double Train error value
   */
  public double getTrainClassificationError(
      IClassifier classifier, IErrorFunction<byte[][]> errorFunction) {

    // Dataset to be used
    DoubleTransposedDataSet dataset;
    if (dataNormalized) dataset = scaledTrainData;
    else dataset = unscaledTrainData;

    // Obtained outputs with this dataSet
    byte obtained[][] = classifier.classify(dataset.getAllInputs());

    // Casting the outputs
    double doubleExpected[][] = dataset.getAllOutputs();
    byte expected[][] = new byte[doubleExpected.length][doubleExpected[0].length];
    for (int i = 0; i < doubleExpected.length; i++)
      for (int j = 0; j < doubleExpected[i].length; j++)
        expected[i][j] = (byte) doubleExpected[i][j];

    // Obtain error
    double error = errorFunction.calculateError(obtained, expected);

    // Return train error value
    return error;
  }