def test_load_dataset_with_unknowns_nominals(self): al = ArffLoader("tests/dataset_with_unknowns.arff") expected_instances = numpy.asarray([[1.0, 0.0, 0.0, 1.2], [0.0, 0.0, 0.0, 0.3], [0.0, 1.0, 0.0, 3.0], [0.0, 0.0, 1.0, 4.0]]) instances, _ = al.load_dataset() numpy.testing.assert_array_equal(expected_instances, instances)
def test_load_dataset_with_label_not_last_attribute(self): al = ArffLoader("tests/dataset.arff", label_attribute="first") expected_instances = numpy.asarray([[1.2, 0.0], [0.3, 0.0], [3.0, 1.0], [4.0, 1.0]]) expected_labels = numpy.asarray(["sheep", "cannon", "egg", "cannon"]) instances, labels = al.load_dataset() numpy.testing.assert_array_equal(expected_instances, instances) numpy.testing.assert_array_equal(expected_labels, labels)
def test_load_dataset_standard(self): al = ArffLoader("tests/dataset.arff") expected_instances = numpy.asarray([[1.0, 0.0, 0.0, 1.2], [0.0, 0.0, 1.0, 0.3], [0.0, 1.0, 0.0, 3.0], [0.0, 0.0, 1.0, 4.0]]) expected_labels = numpy.asarray(["POS", "POS", "NEG", "NEG"]) instances, labels = al.load_dataset() numpy.testing.assert_array_equal(expected_instances, instances) numpy.testing.assert_array_equal(expected_labels, labels)
def test_load_dataset_with_unknown_feature(self): al = ArffLoader("tests/dataset_with_unknown_feature.arff") expected_instances = numpy.asarray([ [1.2], [0.3], [3.0], [4.0] ]) instances, _ = al.load_dataset() numpy.testing.assert_array_equal(expected_instances, instances)
def test_load_dataset_with_useless_real_values(self): al = ArffLoader("tests/dataset_with_useless_real_values.arff") expected_instances = numpy.asarray([ [1.2], [0.3], [3.0], [4.0] ]) instances, _ = al.load_dataset() numpy.testing.assert_array_almost_equal(expected_instances, instances)
def test_load_dataset_with_unknowns_nominals(self): al = ArffLoader("tests/dataset_with_unknowns.arff") expected_instances = numpy.asarray([ [1.0, 0.0, 0.0, 1.2], [0.0, 0.0, 0.0, 0.3], [0.0, 1.0, 0.0, 3.0], [0.0, 0.0, 1.0, 4.0] ]) instances, _ = al.load_dataset() numpy.testing.assert_array_equal(expected_instances, instances)
def test_load_dataset_with_label_not_last_attribute(self): al = ArffLoader("tests/dataset.arff", label_attribute="first") expected_instances = numpy.asarray([ [1.2, 0.0], [0.3, 0.0], [3.0, 1.0], [4.0, 1.0] ]) expected_labels = numpy.asarray([ "sheep", "cannon", "egg", "cannon" ]) instances, labels = al.load_dataset() numpy.testing.assert_array_equal(expected_instances, instances) numpy.testing.assert_array_equal(expected_labels, labels)
def test_load_dataset_standard(self): al = ArffLoader("tests/dataset.arff") expected_instances = numpy.asarray([ [1.0, 0.0, 0.0, 1.2], [0.0, 0.0, 1.0, 0.3], [0.0, 1.0, 0.0, 3.0], [0.0, 0.0, 1.0, 4.0] ]) expected_labels = numpy.asarray([ "POS", "POS", "NEG", "NEG" ]) instances, labels = al.load_dataset() numpy.testing.assert_array_equal(expected_instances, instances) numpy.testing.assert_array_equal(expected_labels, labels)
def main(): for dataset_name in evaluation.dataset_names(): dataset_path = "evaluation/datasets/{}.arff".format(dataset_name) X, y = ArffLoader(dataset_path).load_dataset() X = preprocessing.MinMaxScaler().fit_transform(X) n, n_feats = X.shape n_classes = len(numpy.unique(y)) precisions = pow(X.var(axis=0), -1) mean_precision = numpy.mean(precisions) precision_var = numpy.var(precisions) numpy.set_printoptions(precision=3, suppress=True) print dataset_name print "\t size:{: 5d} ; features: {: 6d} ; classes: {}".format(n, n_feats, n_classes) print "\tmean precision: {: 8.3f}; precision variance: {:10.3f}".format(mean_precision, precision_var) print "\tprecisions:\n{}".format(precisions) print "\n\n"
def main(): for dataset_name in evaluation.dataset_names(): dataset_path = "evaluation/datasets/{}.arff".format(dataset_name) X, y = ArffLoader(dataset_path).load_dataset() X = preprocessing.MinMaxScaler().fit_transform(X) n, n_feats = X.shape n_classes = len(numpy.unique(y)) precisions = pow(X.var(axis=0), -1) mean_precision = numpy.mean(precisions) precision_var = numpy.var(precisions) numpy.set_printoptions(precision=3, suppress=True) print dataset_name print "\t size:{: 5d} ; features: {: 6d} ; classes: {}".format( n, n_feats, n_classes) print "\tmean precision: {: 8.3f}; precision variance: {:10.3f}".format( mean_precision, precision_var) print "\tprecisions:\n{}".format(precisions) print "\n\n"
def test_load_dataset_with_useless_real_values(self): al = ArffLoader("tests/dataset_with_useless_real_values.arff") expected_instances = numpy.asarray([[1.2], [0.3], [3.0], [4.0]]) instances, _ = al.load_dataset() numpy.testing.assert_array_almost_equal(expected_instances, instances)
def test_load_dataset_with_unknown_feature(self): al = ArffLoader("tests/dataset_with_unknown_feature.arff") expected_instances = numpy.asarray([[1.2], [0.3], [3.0], [4.0]]) instances, _ = al.load_dataset() numpy.testing.assert_array_equal(expected_instances, instances)