示例#1
0
    def generate_measure_constructor(self):
        # Note, won't contain self.quantity_goal, since this isn't really in the measure
        if self.locality_kv[0] == 'Global':
            raise NotImplementedError()
        
        all_comp_measure_constructors = []
        
        for rcdl_set_kv in self.rcdl_sets_kvs:
            comp_measurer = self.cross_label_aggregator_kv[1](SplitterHider(
                                lambda s, *args, **kwargs: comp_sum(s.dn, 'added', rcdl_set_kv[1], 
                                                                    partial(self.set_item_score_seq_generator_kv[1], 
                                                                            op=self.set_item_score_combiner_kv[1]), 
                                                                    **kwargs)))
            measure_constructor = partial(GenericCompetenceMeasure, comp_measurer) 
            
            if self.density_inclusion_kv[1]:
                measure_constructor = Measure.create_measure_constructor(average, [measure_constructor, self.density_inclusion_kv[1]])
            
            all_comp_measure_constructors.append(measure_constructor)
        
        if len(all_comp_measure_constructors) > 1:
            measure_constructor = Measure.create_measure_constructor(self.measure_reducer_kv[1], all_comp_measure_constructors)

        return measure_constructor
示例#2
0
                                            sum((direct_other(comp_sum(s.do, 'added', rcdl, direct_other_totaller, **kwargs)),
                                                 flip_added(comp_sum(s.f, 'added', rcdl, flip_added_totaller, **kwargs)),
                                                 flip_removed(comp_sum(s.f, 'removed', rcdl, flip_removed_totaller, **kwargs)))))),
                    Any(SplitterHider(lambda s, *args, **kwargs: comp_sum(s.s, 'removed', rcdl, shunt_totaller, **kwargs)))), 
             op=op)

named_selection_strategy_generators = [
    ("Random Selection", random_selection_strategy_generator),
    ("Uncertainty Sampling", classifier_output_selection_strategy_generator),
    ("Margin Sampling", margin_sampling_selection_strategy_generator),
    ("Maximum Diversity Sampling", maximum_diversity_selection_strategy_generator),
    ("Sparsity Minimization",  partial(SingleCompetenceSelectionStrategy,  
                                       SparsityMeasure, 
                                       SingleCompetenceSelectionStrategy.take_minimum)),
    ("Diversity + Density Maximization",  partial(SingleCompetenceSelectionStrategy,  
                                                   Measure.create_measure_constructor(average, [DiversityMeasure, DensityMeasure]), 
                                                   SingleCompetenceSelectionStrategy.take_maximum)),
    ("Certainty + Sparsity Minimization",  partial(SingleCompetenceSelectionStrategy,  
                                                   Measure.create_measure_constructor(average, [ClassifierCertaintyMeasure, SparsityMeasure]), 
                                                   SingleCompetenceSelectionStrategy.take_minimum)),
                         
    ("CompStrat - Global Coverage (Counting)", 
     create_other_case_generic('c', pos, pos, neg, pos, take_minimum)),
                                       
    ("CompStrat - Global Reachability (Counting)", 
     create_other_case_generic('r', pos, pos, neg, pos, take_minimum)),
                                       
    ("CompStrat - Global Liability (Counting)", 
     create_other_case_generic('l', lambda e: 0, pos, neg, pos, take_maximum)),
                                       
    ("CompStrat - Global Dissimilarity (Counting)",