print Y.shape print X.shape # number of input variables nvar = np.size(X,0) # number of realizations mpts = np.size(X,1) # Select a train size - usually -> int(max(0.8*mpts,10*nvar)) nTrain = 25 # Test points - difference between number of points and training points nTest = mpts - nTrain # Number of observables - only 1 observable at a time kresp = np.size(Y,0) # Retrieve options - either PCARBF or RBF options = saolib.getOptions('PCARBF') # options = saolib.getOptions('RBF') # Train saolib model and compute training time print 'Retrieved saolib options... training model' t0 = time.time() Model = saolib.trainModel(X[:,0:nTrain],Y[:,0:nTrain],options) t1 = time.time() print 'Time to train model: %f' %(t1-t0) # Store saolib model # print Model['pcaModel'] # print Model['pcaModel']['basesInp'] # saolib.saveModel(Model,'MolecularDynamics.model')
ninputs = nvars - 1 # Break down training and testing test - randomly nTest = npts - nTrain # Shuffling the array to make it random np.random.shuffle(training) """ --- RBF model --- """ # Save X (inputs) and Y (outputs) vectors for SAOlib functionality X = training[:, :-1].T.reshape(10, training.shape[0]) Y = training[:, 10].T.reshape(1, training.shape[0]) # Retrieve options - RBF t0 = time.time() options = saolib.getOptions("RBF") Model = saolib.trainModel(X[:, 0:nTrain], Y[:, 0:nTrain], options) Yhat_rbf = saolib.evalModel(Model, X[:, nTrain:npts]) t1 = time.time() print "RBF MODEL TIME: %f" % (t1 - t0) """ --- GPM model --- """ # Getting min and max value for each variable lb = np.min(training, 0) ub = np.max(training, 0) # Creating an information file to be pass to the filter driver (Gaussian process model) fp = open("gppar.dat", "w") fp.write("%d\n" % (ninputs)) # Number of inputs fp.write("%d\n" % (nTrain)) # Number of training points fp.write("%d\n" % (nTest)) # Number of testing points