Ejemplo n.º 1
0
 def _fingerprint_similarity( self, f1, f2 ):
     print "computing similarity for fingerprints:    {}    {}".format(f1, f2)
     f1,f2= DictTree.intersect( f1, f2 )
     def feature_map(*features):
         f1,f2= features
         return f1.similarity(f2)
     similarities= DictTree.map( feature_map, f1, f2 )
     return self._reducer( similarities )   
Ejemplo n.º 2
0
    def _fingerprint_similarity(self, f1, f2):
        print "computing similarity for fingerprints:    {}    {}".format(
            f1, f2)
        f1, f2 = DictTree.intersect(f1, f2)

        def feature_map(*features):
            f1, f2 = features
            return f1.similarity(f2)

        similarities = DictTree.map(feature_map, f1, f2)
        return self._reducer(similarities)
Ejemplo n.º 3
0
def visualize_normal_composites( composites, show=True ):
    COLORS= ('red', 'orange','yellow','green', 'blue', 'violet')
    n= len(composites)
    width= 0.9-(0.1*n)
    common= DictTree.intersect( *composites )
    colors= COLORS[:n]
    for i,c,color in zip(range(n),common, colors):
        visualize_normal_composite( c, color=color, show=False, offset=i*0.1, width=width)
    if show:
        pyplot.show()
Ejemplo n.º 4
0
 def fit( self, data, labels=None ):
     def feature_map(*features):
         assert len(features)==1
         f= features[0]
         try:
             if isinstance( f, FloatSeq ):
                 return GaussianAnomalyModel.from_features( f.name, f.data )
             else:
                 raise Exception("Unknown feature: {}".format(f))
         except InsufficientData:
             return self.IGNORE_CHILD
     assert isinstance( data, CompositeFeature)
     newmodel= DictTree.map( feature_map, data)
     self.clear()
     self.update( newmodel )
Ejemplo n.º 5
0
    def fit(self, data, labels=None):
        def feature_map(*features):
            assert len(features) == 1
            f = features[0]
            try:
                if isinstance(f, FloatSeq):
                    return GaussianAnomalyModel.from_features(f.name, f.data)
                else:
                    raise Exception("Unknown feature: {}".format(f))
            except InsufficientData:
                return self.IGNORE_CHILD

        assert isinstance(data, CompositeFeature)
        newmodel = DictTree.map(feature_map, data)
        self.clear()
        self.update(newmodel)