I am trying to add new columns using the average of old columns, but I don't know how to loop through the columns from the weights array and append them to the class2 array.
class1 = weights[:,sort[popsize-1]]
for x in range(1,avgmating+1):
new = (class1 + np.array(weights[:,sort[popsize - 1 -x]]))/2
class2 = np.hstack((class2,new))
NameError: name 'class2' is not defined
How can I define Class2 and then add the "new" array to it in each iteration?
class2before the loop with any of the array creation routines.