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 )
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)
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 )
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)