示例#1
0
        public static ConfusionMatrix Test(DataTable t)
        {
            ConfusionMatrix cmat = new ConfusionMatrix(classValues);
            int numDims = t.Columns.Count - 1; //remove 1 for the class labels
            foreach (DataRow row in t.Rows) {
                //convert the datarow into an expression
                Sample sample = new Sample(row, classIndex);

                //test the sample and update results
                string prediction = TestInstance(sample);
                cmat.matrix[prediction][sample.classLabel]++;
                if (sample.classLabel.Equals(prediction)) {
                    cmat.numCorrect++;
                } else {
                    cmat.numWrong++;
                }
            }
            cmat.accuracy = ((double)cmat.numCorrect) / t.Rows.Count;
            return cmat;
        }
示例#2
0
 //update the data cloud for the network to draw upon
 public void UpdateDataLayer(Sample s)
 {
     for (int i = 0; i < s.data.Count; i++) { dataLayer[i].value = Double.Parse(s.data[i]); }
     for (int i = 0; i < brain[brain.Count - 1].Count; i++) {
         brain[brain.Count - 1][i].target = 0;
     }
     brain[brain.Count - 1][int.Parse(s.classLabel) - 1].target = 1;
 }
示例#3
0
 public static string TestInstance(Sample sample)
 {
     neural.UpdateDataLayer(sample);
     neural.FeedForward();
     return (neural.GetMaxOutputIndex() + 1).ToString();
 }