Пример #1
0
    def __init__(self,
                 matrix,
                 max_neighbours=20,
                 lshashes=[RandomBinaryProjections("rbp", 10)],
                 vector_filters=[UniqueFilter()],
                 distance=Pearson()):

        if not isinstance(lshashes, list):

            raise TypeError("'lshashes' must be an instance of 'list'")

        if not isinstance(vector_filters, list):

            raise TypeError("'vector_filters' must be an instance of 'list'")

        self.underlying = Engine(len(matrix[0]),
                                 lshashes=lshashes,
                                 vector_filters=vector_filters +
                                 [NearestFilter(max_neighbours)],
                                 distance=distance)

        for vector in matrix:

            self.underlying.store_vector(vector)
Пример #2
0
def main(args):
    Pearson(args[1:]).global_()
Пример #3
0
import sys
from pearson import Pearson

def main(args):
    Pearson(args[1:]).global_()

if __name__ == '__main__':
    Pearson(sys.argv[1:]).global_()
def main():

    if len(sys.argv) == 1:
        K = 200
    else:
        K = int(sys.argv[1])

    pearObj = Pearson("test5.txt", K)
    pearObj.compute()
    print("test5.txt processed. result5.txt produced")

    pearObj = Pearson("test10.txt", K)
    pearObj.compute()
    print("test10.txt processed. result10.txt produced")

    pearObj = Pearson("test20.txt", K)
    pearObj.compute()
    print("test20.txt processed. result20.txt produced")
Пример #5
0
def train(users, algorithm):
    if algorithm == 'pearson':
        model = Pearson()
        model.train(users)
        return model
    elif algorithm == 'spearman':
        model = Spearman()
        model.train(users)
        return model
    elif algorithm == 'mean_squared':
        model = Meansquared()
        model.train(users)
        return model
    elif algorithm == "cosine":
        model = Cosine()
        model.train(users)
        return model
    else:
        print("No model found given algorithm " + algorithm)
        sys.exit(-1)
Пример #6
0
def main(args):
    Pearson(args[1:]).local_()
Пример #7
0
import sys
from pearson import Pearson


def main(args):
    Pearson(args[1:]).local_()


if __name__ == "__main__":
    Pearson(sys.argv[1:]).local_()
Пример #8
0
def main():
    pearObj = Pearson("test5.txt", 200)
    pearObj.compute(False, True)
    print("test5.txt processed. result5.txt produced")

    pearObj = Pearson("test10.txt", 200)
    pearObj.compute(False, True)
    print("test10.txt processed. result10.txt produced")

    pearObj = Pearson("test20.txt", 200)
    pearObj.compute(False, True)
    print("test20.txt processed. result20.txt produced")