目的: 为探讨在同一个样本点集下,cma-es算法对$f(x)$拟合效果与分段数的关系,实验记录每个分段方案下cma-es过程的迭代时间,关系矩阵变化过程,计算结果,cpu计算时间等进行对比。
函数:
import makeData as md
%pylab inline
plt.rc('figure', figsize=(16, 9))
X=md.loadData('result.tl')
import numpy as np
import pandas as pd
b=[]
for i in range(5,35,5):
temp=[]
for j in range(3):
temp.append(X[i][j]['iter'])
b.append(temp)
bs=np.array(b).T
ind=range(5,35,5)
d={'M1':pd.Series(bs[0],index=ind),
'M2':pd.Series(bs[1],index=ind),
'M3':pd.Series(bs[2],index=ind)}
df = pd.DataFrame(d)
df.columns.name='function'
df.index.name='partition'
df
df.plot(kind='bar',fontsize=20)
leg = plt.gca().get_legend()
ltext = leg.get_texts()
plt.setp(ltext, fontsize='20')
plt.title("iteration counts",fontsize=16)
df.plot()
leg = plt.gca().get_legend()
ltext = leg.get_texts()
plt.setp(ltext, fontsize='20')
plt.title("iteration counts",fontsize=16)
b=[]
for i in range(5,35,5):
temp=[]
for j in range(3):
temp.append(X[i][j]['time'])
b.append(temp)
bs=np.array(b).T
ind=range(5,35,5)
d={'M1':pd.Series(bs[0],index=ind),
'M2':pd.Series(bs[1],index=ind),
'M3':pd.Series(bs[2],index=ind)}
df = pd.DataFrame(d)
df.columns.name='function'
df.index.name='partition'
df
df.plot(kind='bar',fontsize=20)
leg = plt.gca().get_legend()
ltext = leg.get_texts()
plt.setp(ltext, fontsize='20')
plt.title("CPU time ",fontsize=16)
df.plot()
leg = plt.gca().get_legend()
ltext = leg.get_texts()
plt.setp(ltext, fontsize='20')
plt.title("CPU time",fontsize=16)