def main(): # MH algorithm sampling IDs in the complete space (complete, Hs, Ms)=complete_dataset(16) prob=compute_boltz_weights(Hs) print prob train_res=mh.get_MH_samples(complete) #train_labels=mh.gen_train_labels(complete, Hs, Ms) #train=[] #for i in range(len(complete)): # row2=complete[i] # train.append(np.hstack((row2,train_labels[i]))) #np.reshape(train,(len(train),17)) #train2=sorted(train,key=itemgetter(-1)) #train_classes=np.arange(0,len(levels),1) #temp=40.0 #train_res=get_MH_sampled_IDs(train2,train_classes,temp) H=[] for i in range(len(train_res)): H.append(train_res[i][-2]) histogr(H)
from sklearn.decomposition import PCA from sklearn.preprocessing import scale nr=input('Enter the dimension N of the square lattice -->') reps=nr*nr # number of lattice sites # generate complete dataset (training_data,training_H,training_M)=mh.complete_dataset(reps) train_labels=mh.gen_train_labels(training_data, training_H, training_M) [train,test]=mh.partition(training_data,train_labels) train_set=train[0] train_y=train[1] test_set=test[0] test_y=test[1] train_data=mh.get_MH_samples(train_set) print "... Computed training dataset" test_data=mh.get_MH_samples(test_set) print "... Computed testing dataset" expr=input('Enter "H" for Hamiltonian energy estimation and "M" for magnetization -->') if expr=="H": train_labels=train_data[:,-2] # Hamiltonian test_labels=test_data[:,-2] else: train_labels=train_data[:,-1] test_labels=test_data[:,-1] # map Hamiltonian data into classes train_dat=train_data[:,:-2]