Hello Thomas,
Yeah, it's all with the same python and hddm versions. I'll post my code for it:
self.data=hddm.load_csv(os.path.join(self.pth,'Master.csv'))
self.LogFile.write('loaded master data\n')
try:
self.LogFile.write('trying to load model...\n')
print('trying to load model...')
# self.model=hddm.load(os.path.join(self.pth,'model_'+self.File_end+'.db'))
if self.Info['Info']=='False':
self.model=hddm.HDDM(self.data,depends_on=self.dependancies,p_outlier=0.05,include=RemovableKeys,informative=False,trace_subjs=False)
elif self.Info['Info']!='False':
self.model=hddm.HDDM(self.data,depends_on=self.dependancies,p_outlier=0.05,include=RemovableKeys,informative=True,trace_subjs=False)
self.model.load_db(os.path.join(self.pth,'model_'+self.File_end+'_2.pickle'))
# with open(os.path.join(self.pth,'model_'+self.File_end+'.pickle'),'r') as f:
# self.model=pickle.load(f)
# try:
# self.model.gen_stats()
# except:
# print traceback.format_exc()
try:
self.model.gen_stats()
except:
print traceback.format_exc()
self.LogFile.write('got model\n')
print('got model')
except:
self.LogFile.write('%s\n' %(traceback.format_exc()))
print('%s\n' %(traceback.format_exc()))
self.LogFile.write('new model\n')
print('new model')
if self.Info['Info']=='False':
self.model=hddm.HDDM(self.data,depends_on=self.dependancies,p_outlier=0.05,include=RemovableKeys,informative=False,trace_subjs=False)
elif self.Info['Info']!='False':
self.model=hddm.HDDM(self.data,depends_on=self.dependancies,p_outlier=0.05,include=RemovableKeys,informative=True,trace_subjs=False)
self.LogFile.write('Made the model\n')
print('Made the model')
# self.model.find_starting_values()
# print 'got starting vals',timer.getTime()
if self.Info['Debug?'] in ['no','No']:
self.model.sample(10000,burn=1000,thin=5,db='pickle', dbname=os.path.join(self.pth,'model_'+self.File_end+'.db')) #was 5000, need reference
else:
self.model.sample(200,burn=10,db='pickle', dbname=os.path.join(self.pth,'model_'+self.File_end+'.db'))
self.LogFile.write('Sampled model fully\n')
print('Sampled model fully')
try:
self.LogFile.write('Saving model to pickle...\n')
print('Saving model to pickle...')
self.model.save(os.path.join(self.pth,'model_'+self.File_end+'_2.pickle'))
# self.model.db.commit()
# with open(os.path.join(self.pth,'model_'+self.File_end+'.pickle'),'wb') as f:
# pickle.dump(self.model,f)
self.LogFile.write('Saving complete!\n')
print('Saving complete!')
except:
self.LogFile.write('%s\n' %(traceback.format_exc()))
print('%s' %(traceback.format_exc()))
self.s=self.model.gen_stats()
self.LogFile.write('Generated stats\n')
print('Generated stats')
self.s.to_csv(os.path.join(self.pth,'Everything_'+self.File_end+'.csv'))
self.LogFile.write('Wrote stats to file\n')
print('Wrote stats to file')
self.DIC=self.model.dic
self.LogFile.write('Obtained DIC\n')
print('Obtained DIC')
As a note, this is all part of a function within a class, hence the use of self. This may not work as-is, since there are several other parts to the code, but with a random data set and pared down a bit it'll run.
Best,
Akos Szekely