def __init__(self, x_table, q_table, objects, attributes): """ Create a partial context from cross and question tables and list of objects, list of attributes. cross_table_x - the list of bool lists representing first context (only x in context) cross_table_q - the list of bool lists representing second context (only questions(q) in context) cross_table_x \subseteq cross_table_q objects - the list of objects attributes - the list of attributes """ if not subseteq_table(x_table, q_table): raise ValueError('x table should be \subseteq q table') else: self.objects = copy(objects) self.attributes = copy(attributes) self.x_context = Context(x_table, objects[:], self.attributes[:]) self.q_context = Context(q_table, objects[:], self.attributes[:])
if indexes: if mode == "part": ret = _filter_part(lattice, indexes, opt) elif mode == "abs": ret = _filter_abs(lattice, indexes, opt) elif mode == "value": ret = _filter_value(lattice, indexes, opt) return ret if __name__ == '__main__': # Test code from fca import ConceptLattice, Context from .probability import compute_probability from .stability import (compute_estability, compute_istability) from .separation import compute_separation_index ct = [[True, False, False, True], [True, False, True, False], [False, True, True, False], [False, True, True, True]] objs = ['1', '2', '3', '4'] attrs = ['a', 'b', 'c', 'd'] c = Context(ct, objs, attrs) cl = ConceptLattice(c) # compute_index(cl, compute_probability, "Probability") # cs = filter_concepts(cl, compute_probability, "abs", 4) # compute_index(cl, compute_separation_index, "Separation") # cs = filter_concepts(cl, compute_probability, "value", 0.5) # compute_index(cl, compute_istability, "Intensional Stability") # print cl cs = filter_concepts(cl, compute_istability, "abs", 2) print(cs)