validationOutputData = trainingOutputData #Tune the reservoir spectralRadius = 0.5 inputScaling = 0.5 reservoirScaling = 0.5 leakingRate = 0.3 size = 500 initialTransient = 50 #Train the reservoir with the optimal parameters res1 = reservoir.Reservoir(size=size, spectralRadius=spectralRadius, inputScaling=inputScaling, reservoirScaling=reservoirScaling, leakingRate=leakingRate, initialTransient=initialTransient, inputData=trainingInputData, outputData=trainingOutputData) res1.trainReservoir() # To predict the test data, predict training and valiadation data as a warm up trainingPredictedOutputData = res1.predict(trainingInputData) #Now, start predicting the future xAxis = [] predictedOutput = [] lastDayIndex = rawData.shape[0] -1 lastDay = date(int(availableData[lastDayIndex, 0]), int(availableData[lastDayIndex, 1]), int(availableData[lastDayIndex, 2]))
trainingOutputData=targetVectors, validationInputData=featureVectors, validationOutputData=targetVectors, spectralRadiusBound=spectralRadiusBound, inputScalingBound=inputScalingBound, reservoirScalingBound=reservoirScalingBound, leakingRateBound=leakingRateBound) spectralRadiusOptimum, inputScalingOptimum, reservoirScalingOptimum, leakingRateOptimum, inputWeightOptimum, reservoirWeightOptimum = resTuner.getOptimalParameters( ) #Train the reservoir with the optimal parameters res = reservoir.Reservoir(size=size, spectralRadius=spectralRadiusOptimum, inputScaling=inputScalingOptimum, reservoirScaling=reservoirScalingOptimum, leakingRate=leakingRateOptimum, initialTransient=initialTransient, inputData=featureVectors, outputData=targetVectors, inputWeightRandom=inputWeightOptimum, reservoirWeightRandom=reservoirWeightOptimum) res.trainReservoir() #Predict for the training data as a warmup trainingPredictedOutputData = res.predict(featureVectors) #Now, start predicted the future nextDate = series.last_valid_index() predicted = [] xAxis = []
trainingOutputData=trainingOutputData, validationInputData=validationInputData, validationOutputData=validationOutputData, spectralRadiusBound=spectralRadiusBound, inputScalingBound=inputScalingBound, reservoirScalingBound=reservoirScalingBound, leakingRateBound=leakingRateBound) spectralRadiusOptimum, inputScalingOptimum, reservoirScalingOptimum, leakingRateOptimum, inputWeightOptimum, reservoirWeightOptimum = resTuner.getOptimalParameters( ) #Train the reservoir with the optimal parameters res = reservoir.Reservoir(size=size, spectralRadius=spectralRadiusOptimum, inputScaling=inputScalingOptimum, reservoirScaling=reservoirScalingOptimum, leakingRate=leakingRateOptimum, initialTransient=initialTransient, inputData=trainingInputData, outputData=trainingOutputData, inputWeightRandom=inputWeightOptimum, reservoirWeightRandom=reservoirWeightOptimum) res.trainReservoir() # To predict the test data, predict training and valiadation data as a warm up trainingPredictedOutputData = res.predict(trainingInputData) #Now, start predicting the future xAxis = [] predictedOutput = [] lastDayIndex = rawData.shape[0] - 1 lastDay = date(int(availableData[lastDayIndex, 0]),
horizon = 1 tsp = ts.TimeSeriesProcessor(rawData, depth, horizon, 4) processedData = tsp.getProcessedData() inputData = np.hstack((np.ones((processedData.shape[0], 1)), processedData[:processedData.shape[0], :depth])) outputData = processedData[:processedData.shape[0], depth:depth + horizon] # Train inputWeightRandom = np.load("Outputs/inputWeight.npy") reservoirWeightRandom = np.load("Outputs/reservoirWeight.npy") res = reservoir.Reservoir(size=600, spectralRadius=1.25, inputScaling=0.50, reservoirScaling=0.50, leakingRate=0.20, initialTransient=0, inputData=inputData, outputData=outputData, inputWeightRandom=inputWeightRandom, reservoirWeightRandom=reservoirWeightRandom) res.trainReservoir() #Predict for past lastDayIndex = 0 lastDayValue = rawData[lastDayIndex, 4] xAxisPast = [] testPredictedOutputDataPast = [] testActualOutputDataPast = [] numberOfDaysInPast = rawData.shape[0] - 1 for i in range(numberOfDaysInPast):