예제 #1
0
def Algorithm(inputData, outputData, outputList, parameters, param):

    train_x = inputData[:, 0:4000]
    train_y = outputData[:, 0:4000]
    test_x = inputData[:, 4000:4600]
    test_y = outputData[:, 4000:4600]
    test_y_List = outputList

    if (param == True):
        startTime = time.time()
        parameters = L_layer_model(train_x,
                                   train_y,
                                   layers_dims,
                                   num_iterations=10000,
                                   print_cost=True)
        endTime = time.time()
    t1 = time.time()
    pred_test, cost = functions.predict(test_x, test_y, parameters)
    t2 = time.time()
    avgError = functions.averageError(pred_test, test_y)
    outList.append(pred_test[0])
    outList.append(test_y[0])
    outList.append([cost])
    outList.append([avgError])
    if (param == True):
        outList.append([endTime - startTime])
    outList.append([t2 - t1])

    costList = []
    averageErrorList = []

    for j in range(0, np.shape(test_y_List)[0]):
        pred_test, cost = functions.predict(test_x, test_y_List[j][:,
                                                                   4000:4600],
                                            parameters)
        test_x = np.concatenate((test_x[1:6, :], pred_test, test_x[6:, :]), 0)
        costList.append(cost)
        averageError = functions.averageError(pred_test,
                                              test_y_List[j][:, 4000:4600])
        averageErrorList.append(averageError)

    outList.append(costList)
    outList.append(averageErrorList)
예제 #2
0
def CostList(parameters):
    costList = []
    averageErrorList = []
    for i in range(0 + predictionData.p, 136 - predictionData.p):
        X, Y, Y_List = predictionData.DataSet(predictionData.postMile[i])
        pred_test, cost = functions.predict(X[:, 4000:4600], Y[:, 4000:4600],
                                            parameters)
        averageError = functions.averageError(pred_test, Y[:, 4000:4600])
        costList.append(cost)
        averageErrorList.append(averageError)

    outList.append(costList)
    outList.append(averageErrorList)
예제 #3
0
import functions

test_x = predictionData.inputData[:, 4000:4600]
test_y = predictionData.outputData[:, 4000:4600]

print(np.shape(test_y))

initial_val = test_x[:, 1]


def MovingAverage(inputArray):
    #weights = np.array([1.0/21, 2.0/21, 3.0/21, 4.0/21, 5.0/21, 6.0/21])
    #inputArray = np.multiply(inputArray, weights)
    return np.average(inputArray)


predict_y = []
inputArray = initial_val
print(inputArray)
for i in range(0, np.shape(test_x)[1]):
    print(inputArray)
    y = MovingAverage(test_x[:, i:i + 1])
    #inputArray = np.append(inputArray[1:], y)
    predict_y.append(y)

cost = functions.compute_cost(predict_y, test_y)
averageError = functions.averageError(predict_y, test_y)

print(cost)
print(averageError)