# Form feature vectors for training data trainingInputData, trainingOutputData = util.formFeatureVectors(trainingData) actualOutputData = minMax.inverse_transform(testingData)[:, 0] # Initial seed initialSeedForValidation = trainingData[-1] networkSize = 500 populationSize = 10 noOfBest = int(populationSize / 2) noOfGenerations = 10 predictedOutputData, bestPopulation = utilityGA.tuneTrainPredictConnectivityGA( trainingInputData=trainingInputData, trainingOutputData=trainingOutputData, validationOutputData=validationData, initialInputSeedForValidation=initialSeedForValidation, horizon=nTesting, noOfBest=noOfBest, resTopology=utilityGA.Topology.ErdosRenyi, size=networkSize, popSize=populationSize, maxGeneration=noOfGenerations, ) predictedOutputData = minMax.inverse_transform(predictedOutputData) # Plotting of the prediction output and error outputFolderName = "Outputs/Erdos_Renyi_Outputs" + datetime.now().strftime("%Y_%m_%d_%H_%M_%S") os.mkdir(outputFolderName) outplot = outputPlot.OutputPlot( outputFolderName + "/Prediction.html", "Mackey-Glass Time Series - GA Optimization)", "Prediction on Testing data",
from reservoir import GAUtility as utilityGA from plotting import ScatterPlot as plot import numpy as np import os from datetime import datetime # File name for folderName = "Outputs/GAResults_Small_World_Graphs_" + datetime.now().strftime( "%Y_%m_%d_%H_%M_%S") os.mkdir(folderName) # Load the best population from the file bestPopulation = utilityGA.loadBestPopulation("population.pkl") # Iterate over all the elements and get the network properties networkSize = 500 meanDegreeList = [] betaList = [] errorList = [] averageDegreeList = [] averagePathLengthList = [] averageDiameterList = [] averageClusteringCoefficientList = [] for item in bestPopulation: # Fitness meanDegree = item[0][0, 0] beta = item[0][0, 1] error = item[1] # Network properties averageDegree = item[2]['averageDegree'] averagePathLength = item[2]['averagePathLength']
# Split the data into training, validation and testing trainingData, validationData, testingData = util.splitData(data, 0.5, 0.25, 0.25) nValidation = validationData.shape[0] nTesting = testingData.shape[0] # Form feature vectors for training data trainingInputData, trainingOutputData = util.formFeatureVectors(trainingData) actualOutputData = minMax.inverse_transform(testingData)[:,0] # Initial seed initialSeedForValidation = trainingData[-1] predictedOutputData = utilGA.tuneTrainPredictGA(trainingInputData=trainingInputData, trainingOutputData=trainingOutputData, validationOutputData=validationData, initialInputSeedForValidation=initialSeedForValidation, testingData=actualOutputData ) predictedOutputData = minMax.inverse_transform(predictedOutputData) #Plotting of the prediction output and error outputFolderName = "Outputs/Outputs" + datetime.now().strftime("%Y_%m_%d_%H_%M_%S") os.mkdir(outputFolderName) outplot = outputPlot.OutputPlot(outputFolderName + "/Prediction.html", "Mackey-Glass Time Series - GA Optimization", "Predicted vs Actual", "Time", "Output") outplot.setXSeries(np.arange(1, nTesting + 1)) outplot.setYSeries('Actual Output', actualOutputData) outplot.setYSeries('Predicted Output', predictedOutputData) outplot.createOutput()
# Form feature vectors for training data trainingInputData, trainingOutputData = util.formFeatureVectors(trainingData) actualOutputData = minMax.inverse_transform(testingData)[:, 0] # Initial seed initialSeedForValidation = trainingData[-1] networkSize = 500 populationSize = 200 noOfBest = int(populationSize / 2) noOfGenerations = 100 predictedOutputData, bestPopulation = utilityGA.tuneTrainPredictConnectivityGA( trainingInputData=trainingInputData, trainingOutputData=trainingOutputData, validationOutputData=validationData, initialInputSeedForValidation=initialSeedForValidation, horizon=nTesting, noOfBest=noOfBest, resTopology=utilityGA.Topology.Random, size=networkSize, popSize=populationSize, maxGeneration=noOfGenerations) predictedOutputData = minMax.inverse_transform(predictedOutputData) #Plotting of the prediction output and error outputFolderName = "Outputs/Random_Graph_Outputs" + datetime.now().strftime( "%Y_%m_%d_%H_%M_%S") os.mkdir(outputFolderName) outplot = outputPlot.OutputPlot(outputFolderName + "/Prediction.html", "Mackey-Glass Time Series - GA Optimization)", "Prediction on Testing data", "Time", "Output")
# Split the data into training, validation and testing trainingData, validationData, testingData = util.splitData( data, 0.5, 0.25, 0.25) nValidation = validationData.shape[0] nTesting = testingData.shape[0] # Form feature vectors for training data trainingInputData, trainingOutputData = util.formFeatureVectors(trainingData) actualOutputData = minMax.inverse_transform(testingData)[:, 0] # Initial seed initialSeedForValidation = trainingData[-1] predictedOutputData = utilGA.tuneTrainPredictGA( trainingInputData=trainingInputData, trainingOutputData=trainingOutputData, validationOutputData=validationData, initialInputSeedForValidation=initialSeedForValidation, testingData=actualOutputData) predictedOutputData = minMax.inverse_transform(predictedOutputData) #Plotting of the prediction output and error outputFolderName = "Outputs/Outputs" + datetime.now().strftime( "%Y_%m_%d_%H_%M_%S") os.mkdir(outputFolderName) outplot = outputPlot.OutputPlot(outputFolderName + "/Prediction.html", "Mackey-Glass Time Series - GA Optimization", "Predicted vs Actual", "Time", "Output") outplot.setXSeries(np.arange(1, nTesting + 1)) outplot.setYSeries('Actual Output', actualOutputData) outplot.setYSeries('Predicted Output', predictedOutputData)
from reservoir import GAUtility as utilityGA from plotting import ScatterPlot as plot import numpy as np import os from datetime import datetime # File name for folderName = "Outputs/GAResults_Combined_" + datetime.now().strftime( "%Y_%m_%d_%H_%M_%S") os.mkdir(folderName) # Load the best population from the file bestPopulationErdos = utilityGA.loadBestPopulation("erdos.pkl") bestPopulationScaleFree = utilityGA.loadBestPopulation("scalefree.pkl") bestPopulationSmallWorld = utilityGA.loadBestPopulation("smallworld.pkl") bestPopulationList = [ bestPopulationErdos, bestPopulationScaleFree, bestPopulationSmallWorld ] # Iterate over all the elements and get the network properties networkSize = 500 errorList = [] averageDegreeList = [] averagePathLengthList = [] averageDiameterList = [] averageClusteringCoefficientList = [] for bestPopulation in bestPopulationList: for item in bestPopulation: # Fitness
from reservoir import GAUtility as utilityGA from plotting import ScatterPlot as plot import numpy as np import os from datetime import datetime # File name for folderName = "Outputs/GAResults_Random_Graphs_" + datetime.now().strftime( "%Y_%m_%d_%H_%M_%S") os.mkdir(folderName) # Load the best population from the file bestPopulation = utilityGA.loadBestPopulation("population.pkl") # Iterate over all the elements and get the network properties networkSize = 500 connectivityList = [] errorList = [] averageDegreeList = [] averagePathLengthList = [] averageDiameterList = [] averageClusteringCoefficientList = [] for item in bestPopulation: # Fitness connectivity = item[0][0, 0] error = item[1] # Network properties averageDegree = item[2]['averageDegree'] averagePathLength = item[2]['averagePathLength'] averageDiameter = item[2]['averageDiameter'] averageClusteringCoefficient = item[2]['averageClusteringCoefficient'] * 500
# Form feature vectors for training data trainingInputData, trainingOutputData = util.formFeatureVectors(trainingData) actualOutputData = minMax.inverse_transform(testingData)[:, 0] # Initial seed initialSeedForValidation = trainingData[-1] networkSize = 500 populationSize = 10 noOfBest = int(populationSize / 2) noOfGenerations = 10 predictedOutputData, bestPopulation = utilityGA.tuneTrainPredictConnectivityGA( trainingInputData=trainingInputData, trainingOutputData=trainingOutputData, validationOutputData=validationData, initialInputSeedForValidation=initialSeedForValidation, horizon=nTesting, noOfBest=noOfBest, resTopology=utilityGA.Topology.SmallWorldGraphs, size=networkSize, popSize=populationSize, maxGeneration=noOfGenerations) predictedOutputData = minMax.inverse_transform(predictedOutputData) #Plotting of the prediction output and error outputFolderName = "Outputs/Small_World_Graphs" + datetime.now().strftime( "%Y_%m_%d_%H_%M_%S") os.mkdir(outputFolderName) outplot = outputPlot.OutputPlot(outputFolderName + "/Prediction.html", "Mackey-Glass Time Series - GA Optimization)", "Prediction on Testing data", "Time", "Output")
from reservoir import GAUtility as utilityGA from plotting import ScatterPlot as plot import numpy as np import os from datetime import datetime # File name for folderName = "Outputs/GAResults_Small_World_Graphs_" + datetime.now().strftime("%Y_%m_%d_%H_%M_%S") os.mkdir(folderName) # Load the best population from the file bestPopulation = utilityGA.loadBestPopulation("population.pkl") # Iterate over all the elements and get the network properties networkSize = 500 meanDegreeList = [] betaList = [] errorList = [] averageDegreeList = [] averagePathLengthList = [] averageDiameterList = [] averageClusteringCoefficientList = [] for item in bestPopulation: # Fitness meanDegree = item[0][0,0] beta = item[0][0,1] error = item[1] # Network properties averageDegree = item[2]['averageDegree']
from reservoir import GAUtility as utilityGA from plotting import ScatterPlot as plot import numpy as np import os from datetime import datetime # File name for folderName = "Outputs/GAResults_Combined_" + datetime.now().strftime("%Y_%m_%d_%H_%M_%S") os.mkdir(folderName) # Load the best population from the file bestPopulationErdos = utilityGA.loadBestPopulation("erdos.pkl") bestPopulationScaleFree = utilityGA.loadBestPopulation("scalefree.pkl") bestPopulationSmallWorld = utilityGA.loadBestPopulation("smallworld.pkl") bestPopulationList = [bestPopulationErdos, bestPopulationScaleFree, bestPopulationSmallWorld] # Iterate over all the elements and get the network properties networkSize = 500 errorList = [] averageDegreeList = [] averagePathLengthList = [] averageDiameterList = [] averageClusteringCoefficientList = [] for bestPopulation in bestPopulationList: for item in bestPopulation: # Fitness attachment = item[0][0,0]/networkSize