Exemplo n.º 1
0
    regressor.fit(input, target)

    mult = 1  #provider.multiplier

    results = regressor.predict(input)
    print(results)
    w = open('output4_1_sr.txt', 'w')
    for i, line in enumerate(results):
        w.write('%f;%f\n' % (target[i] * mult, line * mult))
    w.close()

    input = []
    target = []
    etrue = []
    epredict = []
    for d in provider.getTestData():
        input.append(d[0])
        target.append(d[1][0])
    results = regressor.predict(input)
    w = open('output4_2_sr.txt', 'w')
    for i, line in enumerate(results):
        w.write('%f;%f\n' % (target[i] * mult, line * mult))
    w.close()
    w = open('rt_mse.txt', 'w')
    w.write('%f;\n' % sqrt(mean_squared_error(target, results)))
    w.close()
    plt.plot(target, 'b', results, 'r')
    plt.ylabel('Reikšmė')
    plt.xlabel('Masyvo elementas')
    plt.title('Regression tree grafikas')
    plt.show()
Exemplo n.º 2
0
    regressor = LinearRegression()
    regressor.fit(input, target)
    print(regressor.coef_)

    mult = 1  #reducer.provider.multiplier

    results = regressor.predict(input)
    print(results)
    w = open('output2_1_s.txt', 'w')
    for i, line in enumerate(results):
        w.write('%f;%f\n' % (target[i] * mult, line * mult))
    w.close()

    input = []
    target = []
    for d in reducer.getTestData():
        input.append(d[0])
        target.append(d[1][0])
    results = regressor.predict(input)
    w = open('output2_2_s.txt', 'w')
    for i, line in enumerate(results):
        w.write('%f;%f\n' % (target[i] * mult, line * mult))
    w.close()


class Linear:
    def __init__(self, provider):
        self.provider = provider
        input = []
        target = []
        for d in self.provider.getLearnData():