赞
踩
#参数的值 test_value=[np.arange(0.001,0.01,0.001),np.arange(0.01, 0.1, 0.01),np.arange(0.1, 1, 0.1),np.arange(1, 10,1),np.arange(10, 100, 10),np.arange(100, 1000, 100)] for j in np.arange(0, len(test_value), 1): for k in test_value[j]: result = [] prior = { 'zeta':k,#测试zeta这个参数 'u':0.07, 'v':0.5, 'gamma': 300, 'max_iter' :100, 'mix_threshold':0.1, 'v_test':0.06, 'model_zeta':0.004, 'model_u': 60, 'model_v':8, } args.prior = prior result = [] #每个参数跑五次,结果存入result for n in range(0,5): trainer = Trainer(args) pred, _ = trainer.train(train_x[np.newaxis,:,:]) print(set(pred)) acc = cluster_acc(train_y, pred)[0] print("acc",acc) result.append(acc) #求五轮的平均值 average=np.average(np.array(result)) print("--------------------------------------average:",average) # 将平均值到max中 max.append(np.array([average,k])) # 找到max中最大 t1=np.max(np.array(max)[:,0]) max_index=np.where(np.array(max)[:,0]==t1)[0] print("max_result:",t1,np.array(max)[max_index,:])
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。