I want to pass 2D array to linear regression:
x = [[1, 0, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 3, 1, 1, 0, 0, 0, 0, 1, 0, 0, 1],
[0, 0, 0, 0, 0, 0, 0, 0, 1, 0],
[0, 0, 0, 0, 0, 1, 1, 0, 0, 3]]
y = [3.9857, 3.6877, 3.6877]
x = numpy.array(x)
y = numpy.array(y)
model = LinearRegression(z,y).fit(z,y)
I am not using reshape (-1,1) as it makes the 2D array to 3D
But I am getting error:
ValueError: setting an array element with a sequence
TypeError: float() argument must be a string or a number, not 'list'
How can I correctly pass a two dimensional array to linear regression?
See Question&Answers more detail:
os