I have a project, I need to do something very similar. You can implement dynamic resizing in your loop, but the python list type is actually implemented as a dynamic array, so you can also use the existing tools. You can do something like this:
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 = [] for i in range(N): t = Ridge(Xtrain, ytrain, .3) theta_Matrix.append(t) theta_Matrix = np.array(theta_Matrix)
It should be noted that if you already know the size expected for theta_Matrix , you will get maximum performance by doing something like:
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((N, 8)) for i in range(N): t = Ridge(Xtrain, ytrain, .3) theta_Matrix[i] = t
source share