Ejemplo n.º 1
0
    def metric(self):
        totalTimer = Timer()
        with totalTimer:
            model = mlpy.LARS()
            model.learn(self.data[0], self.data[1])
            output = model.beta()

        metric = {}
        metric["runtime"] = totalTimer.ElapsedTime()
        return metric
Ejemplo n.º 2
0
def lars_base_main():
    x, y = get_input('train')
    lars = mlpy.LARS()
    lars.learn(x, y)
    test_x, test_y = get_input('test')
    right_num = 0
    for pos in range(0, len(test_x)):
        yy = lars.pred(test_x[pos])
        #print yy ,test_y[pos]
        if abs(yy - test_y[pos]) < 5.0:
            right_num += 1
    print right_num * 1.0 / len(test_x)
Ejemplo n.º 3
0
        def RunLARSMlpy():
            totalTimer = Timer()

            # Load input dataset.
            Log.Info("Loading dataset", self.verbose)
            inputData = np.genfromtxt(self.dataset[0], delimiter=',')
            responsesData = np.genfromtxt(self.dataset[1], delimiter=',')

            try:
                with totalTimer:
                    # Perform LARS.
                    model = mlpy.LARS()
                    model.learn(inputData, responsesData)
                    out = model.beta()
            except Exception as e:
                return -1

            return totalTimer.ElapsedTime()