def split_domain(domain, split_label):
 groups = defaultdict(list)
 for attr in domain.attributes:
  groups[attr.attributes.get(split_label)].append(attr)
 attr_values = [attr.attributes.get(split_label) for attr in domain.attributes]
 domains = []
 for (value, attrs) in groups.items():
  group_domain = Domain(attrs, domain.class_vars, domain.metas)
  domains.append((value, group_domain))
 if domains:
  assert all(((len(dom) == len(domains[0][1])) for (_, dom) in domains))
 return sorted(domains, key=(lambda t: attr_values.index(t[0])))

def split_domain ( domain , split_label ) : groups = defaultdict ( list ) for attr in domain . attributes : groups [ attr . attributes . get ( split_label ) ] . append ( attr ) attr_values = [ attr . attributes . get ( split_label ) for attr in domain . attributes ] domains = [ ] for ( value , attrs ) in groups . items ( ) : group_domain = Domain ( attrs , domain . class_vars , domain . metas ) domains . append ( ( value , group_domain ) ) if domains : assert all ( ( ( len ( dom ) == len ( domains [ 0 ] [ 1 ] ) ) for ( _ , dom ) in domains ) ) return sorted ( domains , key = ( lambda t : attr_values . index ( t [ 0 ] ) ) )
split the domain based on values of split_label value .