public void test_has_class_value_with_limited_training_set() { TestingRow5[] rows = new[] { new TestingRow5 { CLASS = 1.0, ATT_1 = "1" }, new TestingRow5 { CLASS = 33.0, ATT_1 = "2" }, new TestingRow5 { CLASS = 22.0, ATT_1 = "3" }, new TestingRow5 { CLASS = 33.0, ATT_1 = "4" }, new TestingRow5 { CLASS = 33.0, ATT_1 = "5" }, new TestingRow5 { CLASS = 11.0, ATT_1 = "2" } }; InstancesBuilder <TestingRow5> builder = new InstancesBuilder <TestingRow5>(rows, 0, 3); weka.core.Instances instances = builder.Build(); Assert.AreEqual(3, instances.numAttributes()); Assert.AreEqual(6, instances.numInstances()); CollectionAssert.AreEqual(new[] { "1", "2", "3", "4", "5", "2" }, instances.GetAttrStrings(1)); CollectionAssert.AreEqual(new[] { "0", "1", "0", "0", "0", "1" }, instances.GetAttrStrings(2)); }
public void flatten_attribute() { FlattenClass[] rows = new[] { new FlattenClass { CLASS = 0, Att1 = new [] { 1, 2, 3, 4, 5 } }, new FlattenClass { CLASS = 1, Att1 = new [] { 6, 7, 8, 9, 10 } } }; InstancesBuilder <FlattenClass> builder = new InstancesBuilder <FlattenClass>(rows, 0); weka.core.Instances instances = builder.Build(); Assert.AreEqual(2, instances.numInstances()); Assert.AreEqual(6, instances.numAttributes()); CollectionAssert.AreEqual(new[] { "1", "2" }, instances.GetAttrStrings(1)); CollectionAssert.AreEqual(new[] { "1.2", "2.2" }, instances.GetAttrStrings(2)); }
public void test_ignore_attributes() { TestingRow6[] rows = new[] { new TestingRow6 { CLASS = 1.0, ATT_1 = "1", ATT_2 = "1.1", ATT_3 = "1.2" }, new TestingRow6 { CLASS = 2.0, ATT_1 = "2", ATT_2 = "2.1", ATT_3 = "2.2" } }; InstancesBuilder <TestingRow6> builder = new InstancesBuilder <TestingRow6>(rows, 0); weka.core.Instances instances = builder.Build(); Assert.AreEqual(3, instances.numAttributes()); // 1 is ignored Assert.AreEqual(2, instances.numInstances()); CollectionAssert.AreEqual(new[] { "1", "2" }, instances.GetAttrStrings(1)); CollectionAssert.AreEqual(new[] { "1.2", "2.2" }, instances.GetAttrStrings(2)); }