I am still quite new to code and I am hoping this is a quick fix. So far I have been able to use linear regression to find the x centroid and y centroid position of 5 sided shapes separately. As found out, the x and y centroids vary with each other so I need to use some form of linear regression to use both x and y in the same regression algorithm.
I have 2 shapes (more shapes will be used when algorithm is running) that have x and y coordinates. These are given in 'a' below. Values from 'b' are the centroid positions of these shapes.
#a = [[[ax1,ay1],[ax2,ay2],[ax3,ay3],[ax4,ay4],[ax5,ay5]],[[bx1,by1],[bx2,by2],[bx3,by3],[bx4,by4],[bx5,by5]]]
a = [[[6,4],[0,5],[0,4],[4,-5],[7,-3]],[[7,5],[1,6],[1,5],[5,-4],[8,-2]]]
#b = [[a_cx,a_cy],[b_cx,b_cy]]
b = [[3.88,0.59],[4.88,1.59]]
LR = LinearRegression()
LR.fit(a,b)
new_shape = [[[9,12],[2,8],[1,4],[16,2],[14,8]]]
centroid = LR.predict(new_shape)
print("results = ",centroid)
I get the error:
'ValueError: Found array with dim 3. Estimator expected <= 2.'
I am unsure how to get passed this error and would appreciate any help or tips!