Beispiel #1
0
def test_support_with_conditions(root, rows_csv, **unused):
    with loom.preql.get_server(root, debug=True) as preql:
        features = preql.feature_names
        conditions = make_fully_observed_row(rows_csv)
        target_feature_sets = [
            [features[0], features[1]],
            [features[2]]]
        observed_feature_sets = [
            [features[0], features[1]],
            [features[2]],
            [features[3]]]
        preql.support(
            target_feature_sets,
            observed_feature_sets,
            conditions)
        conditions[5] = None
        preql.support(
            target_feature_sets,
            observed_feature_sets,
            conditions)
        conditions[0] = None
        assert_raises(
            ValueError,
            preql.support,
            target_feature_sets,
            observed_feature_sets,
            conditions)
Beispiel #2
0
def test_support_shape(root, rows_csv, **unused):
    with loom.preql.get_server(root, debug=True) as preql:
        features = preql.feature_names
        conditioning_row = make_fully_observed_row(rows_csv)
        target_sets = [
            features[2 * i: 2 * (i + 1)]
            for i in xrange(len(features) / 2)
        ]
        observed_sets = [
            features[2 * i: 2 * (i + 1)]
            for i in xrange(len(features) / 2)
        ]
        result = preql.support(
            target_sets,
            observed_sets,
            conditioning_row,
            sample_count=10)
        reader = csv.reader(StringIO(result))
        header = reader.next()
        header.pop(0)
        assert_equal(header, map(min, observed_sets))
        for row, target_set in izip(reader, target_sets):
            label = row.pop(0)
            assert_equal(label, min(target_set))
            assert_equal(len(row), len(observed_sets))