Ejemplo n.º 1
0
        public void ComputerVendorsSupportVectorMachineClassifierTest()
        {
            DataSetLoader dataSetLoader = new DataSetLoader();

            Console.WriteLine(" Reading DataSet.. ");
            var computerVendors = dataSetLoader.SelectComputerVendors();

            for (double i = 0; i < 1; i = i + 1)
            {
                Kernel        kernel = new LinearKernel();
                SVMClassifier computerVendorsSVMClassifier = new SVMClassifier(computerVendors, kernel, 0.001, 10.0);
                computerVendorsSVMClassifier.Train();
                var computerVendorsTest = dataSetLoader.SelectComputerVendors();
                var trueCounter         = 0;
                var counter             = 0;
                foreach (var item in computerVendorsTest)
                {
                    var outputValue = computerVendorsSVMClassifier.Classify(item.Item1);
                    if (outputValue == item.Item2)
                    {
                        trueCounter++;
                    }
                    Debug.WriteLine(string.Format("Value {0} - Predicted {1} = {2}",
                                                  item.Item2, outputValue, (outputValue == item.Item2) ? "true" : "false"));
                    counter++;
                }
                Debug.WriteLine(string.Format(" i = {0} Data {1} - True {2} Verhältnis: {3}", i,
                                              counter.ToString(), trueCounter.ToString(), (Convert.ToDouble(trueCounter) / Convert.ToDouble(counter)).ToString()));
            }
        }
Ejemplo n.º 2
0
        public void ComputerVendorsDecisionTreeTest()
        {
            DataSetLoader dataSetLoader = new DataSetLoader();

            Console.WriteLine(" Reading DataSet.. ");
            var computerVendors = dataSetLoader.SelectComputerVendors();
            DecisionTreeClassifier decisionTreeClassifier =
                new DecisionTreeClassifier(computerVendors, new ShannonEntropySplitter());

            decisionTreeClassifier.Train();
            var computerVendorsTest = dataSetLoader.SelectComputerVendors();
            var trueCounter         = 0;
            var counter             = 0;

            foreach (var item in computerVendorsTest)
            {
                var outputValue = decisionTreeClassifier.Classify(item.Item1);
                if (outputValue == item.Item2)
                {
                    trueCounter++;
                }
                Debug.WriteLine(string.Format("Value {0} - Predicted {1} = {2}",
                                              item.Item2, outputValue, (outputValue == item.Item2) ? "true" : "false"));
                counter++;
            }
            Debug.WriteLine(string.Format("Data {0} - True {1} Verhältnis: {2}",
                                          counter.ToString(), trueCounter.ToString(), (Convert.ToDouble(trueCounter) / Convert.ToDouble(counter)).ToString()));
        }