public void TestC45() { var c45 = new C45(); var c45Parameter = new C45Parameter(1, true, 0.2); var discreteToContinuous = new DiscreteToContinuous(car); discreteToContinuous.Convert(); c45.Train(car.GetInstanceList(), c45Parameter); Assert.AreEqual(29.98, 100 * c45.Test(car.GetInstanceList()).GetErrorRate(), 0.01); discreteToContinuous = new DiscreteToContinuous(tictactoe); discreteToContinuous.Convert(); c45.Train(tictactoe.GetInstanceList(), c45Parameter); Assert.AreEqual(34.66, 100 * c45.Test(tictactoe.GetInstanceList()).GetErrorRate(), 0.01); }
public static void RunC45() { List <DDataRecord> records = LoadSample(); C45 <DDataRecord> algorithm = new C45 <DDataRecord>(); algorithm.UpdateContinuousAttributes(records, "temperature"); algorithm.UpdateContinuousAttributes(records, "humidity"); algorithm.Train(records); //algorithm.RulePostPrune(records); //post pruning using cross valiation set Console.WriteLine("C4.5 Tree Built!"); for (int i = 0; i < records.Count; i++) { DDataRecord rec = records[i]; Console.WriteLine("rec: "); string[] feature_names = rec.FindFeatures(); foreach (string feature_name in feature_names) { Console.WriteLine(feature_name + " = " + rec[feature_name]); } Console.WriteLine("Label: " + rec.Label); Console.WriteLine("Predicted Label: " + algorithm.Predict(records[i])); Console.WriteLine(); } }
public void TestC45() { var c45 = new C45(); var c45Parameter = new C45Parameter(1, true, 0.2); var laryToBinary = new LaryToBinary(car); laryToBinary.Convert(); c45.Train(car.GetInstanceList(), c45Parameter); Assert.AreEqual(10.76, 100 * c45.Test(car.GetInstanceList()).GetErrorRate(), 0.01); laryToBinary = new LaryToBinary(tictactoe); laryToBinary.Convert(); c45.Train(tictactoe.GetInstanceList(), c45Parameter); Assert.AreEqual(16.08, 100 * c45.Test(tictactoe.GetInstanceList()).GetErrorRate(), 0.01); laryToBinary = new LaryToBinary(nursery); laryToBinary.Convert(); c45.Train(nursery.GetInstanceList(), c45Parameter); Assert.AreEqual(24.95, 100 * c45.Test(nursery.GetInstanceList()).GetErrorRate(), 0.01); }
public void TestC45() { var c45 = new C45(); var c45Parameter = new C45Parameter(1, true, 0.2); var discreteToIndexed = new DiscreteToIndexed(car); discreteToIndexed.Convert(); c45.Train(car.GetInstanceList(), c45Parameter); Assert.AreEqual(10.76, 100 * c45.Test(car.GetInstanceList()).GetErrorRate(), 0.01); discreteToIndexed = new DiscreteToIndexed(tictactoe); discreteToIndexed.Convert(); c45.Train(tictactoe.GetInstanceList(), c45Parameter); Assert.AreEqual(16.08, 100 * c45.Test(tictactoe.GetInstanceList()).GetErrorRate(), 0.01); discreteToIndexed = new DiscreteToIndexed(nursery); discreteToIndexed.Convert(); c45.Train(nursery.GetInstanceList(), c45Parameter); Assert.AreEqual(24.95, 100 * c45.Test(nursery.GetInstanceList()).GetErrorRate(), 0.01); }
public void TestTrain() { var c45 = new C45(); var c45Parameter = new C45Parameter(1, true, 0.2); c45.Train(iris.GetInstanceList(), c45Parameter); Assert.AreEqual(4.67, 100 * c45.Test(iris.GetInstanceList()).GetErrorRate(), 0.01); c45.Train(bupa.GetInstanceList(), c45Parameter); Assert.AreEqual(42.03, 100 * c45.Test(bupa.GetInstanceList()).GetErrorRate(), 0.01); c45.Train(dermatology.GetInstanceList(), c45Parameter); Assert.AreEqual(6.28, 100 * c45.Test(dermatology.GetInstanceList()).GetErrorRate(), 0.01); c45.Train(car.GetInstanceList(), c45Parameter); Assert.AreEqual(21.35, 100 * c45.Test(car.GetInstanceList()).GetErrorRate(), 0.01); c45.Train(tictactoe.GetInstanceList(), c45Parameter); Assert.AreEqual(19.94, 100 * c45.Test(tictactoe.GetInstanceList()).GetErrorRate(), 0.01); c45.Train(nursery.GetInstanceList(), c45Parameter); Assert.AreEqual(29.03, 100 * c45.Test(nursery.GetInstanceList()).GetErrorRate(), 0.01); }