public static double[] validate(Classifier cl, ArrayList<double[]> data)
    {
        int truePositive = 0,
            falsePositive = 0,
            trueNegative = 0,
            falseNegative = 0,
            prediction;
        double precision,recall, actualDiagnosis, accuracy,f1score;
        
        //make predictions on each data point and record results
        for(double[] d : data)
        {
            prediction = cl.predict(d);
            actualDiagnosis = d[1];
            if(prediction == 1 && actualDiagnosis == 1) truePositive++;
            else if(prediction == 1 && actualDiagnosis == 0) falsePositive++;
            else if(prediction == 0 && actualDiagnosis == 0) trueNegative++;
            else if(prediction == 0 && actualDiagnosis == 1) falseNegative++;
        }
        
        printConfusionMatrix(truePositive,falsePositive,trueNegative,falseNegative);
        
        precision = (double)truePositive/(double)(truePositive + falsePositive);
        recall = (double)truePositive/(double)(truePositive + falseNegative);
        accuracy = (double)(truePositive + trueNegative)/(double)(truePositive + trueNegative + falseNegative + falsePositive);
        f1score = 2.*(precision * recall)/(precision + recall);
        System.out.printf("Precision: %f    Recall:    %f  \nAccuracy:  %f    f-1 score: %f \n\n\n",precision,recall,accuracy,f1score);

        
        return new double[]{accuracy,precision,recall,f1score};
    }