def setAlgorithms(self, algos):
     self.algos = {}
     wsum = sum([algo[1] for algo in algos])
     for algo in algos:
         self.algos[algo[0]] = {
             "weight": algo[1] * 1.0 / wsum,
             "object": loadAlgorithm(algo[0])
         }
def testAlgorithm(dataset, algorithm):

    print "[%s] Splitting learn & probe" % (algorithm)
    # (learn,probe) = dataset.splitInLearnAndProbe(lambda row:row[4]%80==0)
    # (learn,probe) = dataset.splitInLearnAndProbe(lambda row:row[1]!=33 )
    learn_ids = (
        33,
        80753,
        65893,
        51330,
        41201,
        24426,
        23932,
        16853,
        6534,
        2131,
        43152,
        43153,
        43155,
        43156,
        43161,
        43162,
        43163,
        43164,
        43169,
    )
    (learn, probe) = dataset.splitInLearnAndProbe(lambda row: row[1] not in learn_ids)
    # (learn,probe) = dataset.splitInLearnAndProbe(lambda row:row[1]!=32)

    a = loadAlgorithm(algorithm)

    learn._probe = probe

    print "[%s] Training dataset (%s rows of %s total)..." % (
        algorithm,
        len(learn.data),
        len(learn.data) + len(probe.data),
    )
    a.trainDataset(learn)

    print "[%s] Computing RMSE..." % (algorithm)
    # return (learn.rmse(a),probe.rmse(a))

    return (0, probe.rmse(a))
Пример #3
0
def testAlgorithm(dataset, algorithm):

    print "[%s] Splitting learn & probe" % (algorithm)
    #(learn,probe) = dataset.splitInLearnAndProbe(lambda row:row[4]%80==0)
    #(learn,probe) = dataset.splitInLearnAndProbe(lambda row:row[1]!=33 )
    learn_ids = (33, 80753, 65893, 51330, 41201, 24426, 23932, 16853, 6534,
                 2131, 43152, 43153, 43155, 43156, 43161, 43162, 43163, 43164,
                 43169)
    (learn,
     probe) = dataset.splitInLearnAndProbe(lambda row: row[1] not in learn_ids)
    #(learn,probe) = dataset.splitInLearnAndProbe(lambda row:row[1]!=32)

    a = loadAlgorithm(algorithm)

    learn._probe = probe

    print "[%s] Training dataset (%s rows of %s total)..." % (
        algorithm, len(learn.data), len(learn.data) + len(probe.data))
    a.trainDataset(learn)

    print "[%s] Computing RMSE..." % (algorithm)
    #return (learn.rmse(a),probe.rmse(a))

    return (0, probe.rmse(a))
 def setAlgorithms(self,algos):
     self.algos = {}
     wsum = sum([algo[1] for algo in algos])
     for algo in algos:
         self.algos[algo[0]] = {"weight":algo[1]*1.0/wsum,"object":loadAlgorithm(algo[0])}