Esempio n. 1
0
def testTrain():
    #saveCombinationClass()
    combination = loadCombinationClass()
    combination.train(alpha = 0.01, iter = 10000)
    tdata = "Data/100k/u1.test"
    answers, predicts = combination.predict(np.loadtxt(tdata))
    err = evaluationRMSE(answers, predicts)
    print("Error : %f" % err)
def test_predict():
    fdata = "Data/100k/u1.base"
    ftest = "Data/100k/u1.test"
    bias = Bias(np.loadtxt(fdata), np.loadtxt(ftest))
    bias.calculateBias()
    answer, predicts = bias.predict()
    err = evaluationRMSE(answer, predicts)
    print("Err: %f" % (err))
def testTrain():
    #saveCombinationClass()
    combination = loadCombinationClass()
    combination.train(alpha=0.01, iter=10000)
    tdata = "Data/100k/u1.test"
    answers, predicts = combination.predict(np.loadtxt(tdata))
    err = evaluationRMSE(answers, predicts)
    print("Error : %f" % err)
Esempio n. 4
0
def test_predict():
    fdata = "Data/100k/u1.base"
    ftest = "Data/100k/u1.test"
    bias = Bias(np.loadtxt(fdata), np.loadtxt(ftest))
    bias.calculateBias()
    answer, predicts = bias.predict()
    err = evaluationRMSE(answer, predicts)
    print("Err: %f" % (err))
Esempio n. 5
0
def test_SVD():
    fdata = "Data/100k/u1.base"
    ftest = "Data/100k/u1.test"
    svd = SVD(np.loadtxt(fdata), np.loadtxt(ftest))
    svd.generaterMat()
    svd.calcSVD()
    answer, predicts = svd.predict()
    err = evaluationRMSE(answer, predicts)
    print("Error: %f" % err)
def test_knn():
    fdata = "Data/100k/u1.base"
    ftest = "Data/100k/u1.test"
    knn = KNN(np.loadtxt(fdata), np.loadtxt(ftest))
    #knn.calcSimMatrix()
    #knn.saveSim(100)
    knn.loadSim(100)
    answer, predicts = knn.predict(n = 15)
    err = evaluationRMSE(answer, predicts)
    print("Error: %f" % err)
Esempio n. 7
0
def test_matFactory():
    fdata = "Data/100k/u1.base"
    ftest = "Data/100k/u1.test"
    matFactory = MatFactory(np.loadtxt(fdata), np.loadtxt(ftest))
    factors = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 100, 200]
    for i in factors:
        matFactory.train(20, i)
        answer, predicts = matFactory.predict()
        err = evaluationRMSE(answer, predicts)
        print("Factors: %d, Error: %f" % (i, err))
def test_matFactory():
    fdata = "Data/100k/u1.base"
    ftest = "Data/100k/u1.test"
    matFactory = MatFactory(np.loadtxt(fdata), np.loadtxt(ftest))
    factors = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 100, 200]
    for i in factors:
        matFactory.train(20, i)
        answer, predicts = matFactory.predict()
        err = evaluationRMSE(answer, predicts)
        print("Factors: %d, Error: %f" % (i, err))
Esempio n. 9
0
def test():
    fdata = "Data/100k/u1.base"
    ftest = "Data/100k/u1.test"
    simi = Similarity(fdata, ftest)
    #simi.calcSimi()
    #simi.calcSimiLocal()
    #simi.saveSimi(1)
    simi.calcSimiMatrix()
    answer, predicts = simi.predict()
    err = evaluationRMSE(answer, predicts)
    print("Error: %f" % err)
Esempio n. 10
0
def test():
    from bias import Bias
    fdata = "Data/100k/u1.base"
    ftest = "Data/100k/u1.test"
    simi = Similarity(np.loadtxt(fdata), np.loadtxt(ftest))
    #simi.calcSimi()
    simi.calcSimiMatrix()
    #simi.saveSimi(10)
    #simi.loadSimi(10)
    answer, predicts = simi.predict()
    err = evaluationRMSE(answer, predicts)
    print("Error: %f" % err)
Esempio n. 11
0
def test():
    from bias import Bias
    fdata = "Data/100k/u1.base"
    ftest = "Data/100k/u1.test"
    simi = Similarity(np.loadtxt(fdata), np.loadtxt(ftest))
    #simi.calcSimi()
    simi.calcSimiMatrix()
    #simi.saveSimi(10)
    #simi.loadSimi(10)
    answer, predicts = simi.predict()
    err = evaluationRMSE(answer, predicts)
    print("Error: %f" % err)
Esempio n. 12
0
    def calAll(self):
        self.errs = [0] * 5
        bias = Bias(self.data, self.test)
        bias.calculateBias()
        answers, predicts = bias.predict()
        err = evaluationRMSE(answers, predicts)
        self.errs[0] = err
        print("Bias: %f" % err)

        similarity = Similarity(self.data, self.test)
        similarity.calculateBias()
        similarity.calcSimiMatrix()
        answers, predicts = similarity.predict()
        err = evaluationRMSE(answers, predicts)
        self.errs[1] = err
        print("Similarity: %f" % err)

        svd = SVD(self.data, self.test)
        svd.generaterMat()
        svd.calcSVD()
        answers, predicts = svd.predict()
        err = evaluationRMSE(answers, predicts)
        self.errs[2] = err
        print("SVD: %f" % err)

        matFactory = MatFactory(self.data, self.test)
        matFactory.train(20, 35)
        answers, predicts = matFactory.predict()
        err = evaluationRMSE(answers, predicts)
        self.errs[3] = err
        print("MatFactory: %f" % evaluationRMSE(answers, predicts))

        combination = Combination(self.data)
        combination.separateData()
        combination.calculate()
        combination.train(alpha=0.01, iter=10000)
        answers, predicts = combination.predict(self.test)
        err = evaluationRMSE(answers, predicts)
        self.errs[4] = err
        print("Combination: %f" % err)
        return self.errs
Esempio n. 13
0
    def calAll(self):
        self.errs = [0] * 5
        bias = Bias(self.data, self.test)
        bias.calculateBias()
        answers, predicts = bias.predict()
        err = evaluationRMSE(answers, predicts)
        self.errs[0] = err
        print("Bias: %f" % err)

        similarity = Similarity(self.data, self.test)
        similarity.calculateBias()
        similarity.calcSimiMatrix()
        answers, predicts = similarity.predict()
        err = evaluationRMSE(answers, predicts)
        self.errs[1] = err
        print("Similarity: %f" % err)

        svd = SVD(self.data, self.test)
        svd.generaterMat()
        svd.calcSVD()
        answers, predicts = svd.predict()
        err = evaluationRMSE(answers, predicts)
        self.errs[2] = err
        print("SVD: %f" % err)

        matFactory = MatFactory(self.data, self.test)
        matFactory.train(20, 35)
        answers, predicts = matFactory.predict()
        err = evaluationRMSE(answers, predicts)
        self.errs[3] = err
        print("MatFactory: %f" % evaluationRMSE(answers, predicts))

        combination = Combination(self.data)
        combination.separateData()
        combination.calculate()
        combination.train(alpha = 0.01, iter = 10000)
        answers, predicts = combination.predict(self.test)
        err = evaluationRMSE(answers, predicts)
        self.errs[4] = err
        print("Combination: %f" % err)
        return self.errs