I want to train a linear model Y = M_1*X_1 + M_2*X_2
using sklearn
with multidimensional input and output samples (e.g. vectors). I tried the following code:
from sklearn import linear_model
from pandas import DataFrame
x1 = [[1,2],[2,3],[3,4]]
x2 = [[1,1],[3,2],[3,5]]
y = [[1,0],[1,2],[2,3]]
model = {
'vec1': x1,
'vec2': x2,
'compound_vec': y}
df = DataFrame(model, columns=['vec1','vec2','compound_vec'])
x = df[['vec1','vec2']].astype(object)
y = df['compound_vec'].astype(object)
regr = linear_model.LinearRegression()
regr.fit(x,y)
But I get the following error:
regr.fit(x,y)
...
array = array.astype(np.float64)
ValueError: setting an array element with a sequence.
Does anyone know what is wrong with the code? and if this is a right way to train Y = M_1*X_1 + M_2*X_2
?