¡@

Home 

python Programming Glossary: self.k

Creating class instance properties from a dictionary in Python

http://stackoverflow.com/questions/1639174/creating-class-instance-properties-from-a-dictionary-in-python

def __init__ self dictionary for k v in dictionary.items self.k v #of course this doesn't work. I've ended up doing this instead..

Modern, high performance bloom filter in Python?

http://stackoverflow.com/questions/311202/modern-high-performance-bloom-filter-in-python

raise Exception 'Must specify value of k between 1 and 4' self.k k if bits self.bits bits else self.bits BitVector size m self.rand.. i 1 bits.append i return dupe def __and__ self filter if self.k filter.k or self.m filter.m raise Exception 'Must use bloom.. m paramters for bitwise AND' return BloomFilter m self.m k self.k bits self.bits filter.bits def __or__ self filter if self.k..

Finding k-nearest neighbors for a given vector?

http://stackoverflow.com/questions/5684370/finding-k-nearest-neighbors-for-a-given-vector

self train_data k distf self.train_data train_data self.k min k len train_data self.distf distf def classify self x Ns.. xy self.distf xy 0 x return most_frequent y for x y in Ns self.k def batch_classify self xs return self.classify x for x in xs.. at. def __init__ self kNN self.classes set self.xs self.ys self.k None def equal_weight x y equal_weight x y 1 # everything gets..