如何绘制alpha_list
值的对数?
alpha_list = np.log(alpha_list)
仍然有一些重叠,但至少这些值分布得更均匀:
import matplotlib.pyplot as plt
import numpy as np
alpha_list=[1e-11,1e-10,1e-10,5*1e-10,8*1e-10,1e-8,1e-8,5*1e-8,8*1e-6,1e-6,1e-6,5*1e-6,8*1e-6,1e-4,1e-4,5*1e-4,8*1e-4,1e-3,1e-3,5*1e-3,6*1e-3,8*1e-3]
alpha_list = np.log(alpha_list)
eigRange = np.linspace(0,19,20)
eigenvalues,alphaa = np.meshgrid(eigRange,alpha_list )
normCostTrain = np.random.random((len(alpha_list),len(eigRange)))
fig = plt.figure()
DatavmaxTrain = np.max(normCostTrain)
DatavminTrain = np.min(normCostTrain)
plt.scatter(eigenvalues,alphaa,s = 130, c=normCostTrain,cmap=plt.get_cmap('PuOr'),
vmin=DatavminTrain, vmax=DatavmaxTrain, alpha=0.70) #-----for train
cb1=plt.colorbar()
cb1.set_label("normalized square error")
plt.title("Train ")
plt.xlabel("No. of Eigenvalues")
plt.ylabel("Log(Regularization parameter)")
plt.show()
产量
这是相同数据的 3D 散点图示例,z 轴(和颜色)都用于表示“归一化平方误差”。
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.cm as cm
import numpy as np
fig = plt.figure()
ax = fig.add_subplot(111, projection = '3d')
alpha_list = [1e-11, 1e-10, 1e-10, 5*1e-10, 8*1e-10, 1e-8, 1e-8, 5*1e-8, 8*1e-6,
1e-6, 1e-6, 5*1e-6, 8*1e-6, 1e-4, 1e-4, 5*1e-4, 8*1e-4, 1e-3, 1e-3,
5*1e-3, 6*1e-3, 8*1e-3]
alpha_list = np.log(alpha_list)
eigRange = np.linspace(0, 19, 20)
eigenvalues, alphaa = np.meshgrid(eigRange, alpha_list )
eigenvalues = eigenvalues.ravel()
alphaa = alphaa.ravel()
normCostTrain = np.random.random((len(alpha_list), len(eigRange))).ravel()
DatavmaxTrain = np.max(normCostTrain)
DatavminTrain = np.min(normCostTrain)
PuOr = plt.get_cmap('PuOr')
ax.scatter(eigenvalues, alphaa, normCostTrain,
c = normCostTrain.ravel(),
s = 30,
cmap = PuOr,
vmin = DatavminTrain,
vmax = DatavmaxTrain,
alpha = 0.70
) #-----for train
m = cm.ScalarMappable(cmap = PuOr)
m.set_array(normCostTrain)
cb1 = plt.colorbar(m)
cb1.set_label("normalized square error")
plt.title("Train ")
ax.set_xlabel("No. of Eigenvalues")
ax.set_ylabel("Log(Regularization parameter)")
ax.set_zlabel("normalized square error")
plt.show()
我不确定这是否是一种改进。这些点有点混杂在一起,但如果您拖动鼠标旋转绘图,则可以区分。