I am trying to make multiple linear regression with sklearn.
features_2 = ['chronic_disease_binary', 'outcome']
X = df.loc[:, features_2].values
Y = df.loc[:, ['age']].values
# X = pd.get_dummies(X,drop_first=True)
#
X_train_lm, X_test_lm, y_train_lm, y_test_lm = create_dataset_test(X, Y)
X_train_lm = X_train_lm.reshape((2596, -1))
lm = linear_model.LinearRegression()
model = lm.fit(X_train_lm, y_train_lm)
y_pred_lm = lm.predict(X_test_lm)
I have this issue when I am trying tp make prediction on X_test :
ValueError: matmul: Input operand 1 has a mismatch in its core dimension 0, with gufunc signature (n?,k),(k,m?)->(n?,m?) (size 2 is different from 1)
- My X_train has this form :
[[-0.77046461 1.29791815]
[-0.77046461 -0.77046461]
[-0.77046461 1.29791815]
...
[-0.77046461 -0.77046461]
[-0.77046461 1.29791815]
[-0.77046461 -0.77046461]]
- And my y_train is like this :
[[59.]
[54.]
[40.]
...
[24.]
[33.]
[41.]]
- The data where I make my prediction has this form :
[[-0.76666002]
[ 1.30435914]
[-0.76666002]
...
[-0.76666002]
[-0.76666002]
[-0.76666002]]
X_test_lm.shape
give you? – Ami Tavory