我有一个返回numpy数组的方法。我要做的是在每次迭代中使用这个数组并将其连接到另一个数组数组中,这样在循环结束时我就有了一个矩阵
到目前为止这是我的代码,但它在给定的行上崩溃了程序delta_Array = np.array([0.01,0.02,0.03, 0.04, 0.05, 0.06,0.07, 0.08, 0.09, 0.10])
theta_Matrix = np.zeros(8)
t = Ridge(Xtrain, ytrain, .3) # This method returns an array of 8 elements
np.append(theta_Matrix,t, axis=0)
print delta_Array
print theta_Matrix
用这种方法,我的电流输出是[ 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 ] # delta_Array
[ 0. 0. 0. 0. 0. 0. 0. 0.] # theta_Matrix
经过两次迭代后,输出Id应该如下所示。另外,我不知道lop要经过的迭代次数,所以在方法运行后可以生成任意数量的数组。但不管怎样,所有的数组都应该形成theta矩阵:theta_Matrix:
[[ 0.65 0.65565 0.19181 0.923 0.51561 0.846 0.6464 0.6464]
[ 0.9879 0.31213 0.68464 0.611 0.6161 0.61651 0.29858 0.1811]]
谢谢