ValueError: shapes (1,10) and (2,) not aligned: 10 (dim 1) != 2 (dim 0) I am running a multiple linear regression using backward elimination. Below is the code

import statsmodels.formula.api as sm
X = np.append(arr = np.ones((50, 1)).astype(int), values = X, axis = 
1)
X_opt = X[:,[0,1,2,3,4,5]]
regressor_OLS = sm.OLS(endog= y, exog = X_opt).fit()
regressor_OLS.summary()
X_opt = X[:,[0,1,3,4,5]]
regressor_OLS = sm.OLS(endog= y, exog = X_opt).fit()
regressor_OLS.summary()
X_opt = X[:,[0,3,4,5]]
regressor_OLS = sm.OLS(endog= y, exog = X_opt).fit()
regressor_OLS.summary()
X_opt = X[:,[0,3,5]]
regressor_OLS = sm.OLS(endog= y, exog = X_opt).fit()
regressor_OLS.summary()
X_opt = X[:,[0,3]]
regressor_OLS = sm.OLS(endog= y, exog = X_opt).fit()
regressor_OLS.summary()


But when I am predicting using the above regressor_OLS model,

X_new = X[:, 3]
y_pred2 = regressor_OLS.predict(X_new)


I am getting the below error:

    y_pred2 = regressor_OLS.predict(X_new)
    Traceback (most recent call last):

  File "&lt;ipython-input-18-263dee38fc26&gt;", line 1, in &lt;module&gt;
    y_pred2 = regressor_OLS.predict(X_new)

  File "/Users/ritesh.satapathy/anaconda/lib/python3.6/site-packages/statsmodels/base/model.py", line 749, in predict
    return self.model.predict(self.params, exog, *args, **kwargs)

  File "/Users/ritesh.satapathy/anaconda/lib/python3.6/site-packages/statsmodels/regression/linear_model.py", line 359, in predict
    return np.dot(exog, params)

ValueError: shapes (1,50) and (2,) not aligned: 50 (dim 1) != 2 (dim 0)


I tried X_new = X_test[:,3] but still same error.

Traceback (most recent call last):

  File "&lt;ipython-input-19-5020d55a4448&gt;", line 1, in &lt;module&gt;
    y_pred2 = regressor_OLS.predict(X_ne1)

  File "/Users/ritesh.satapathy/anaconda/lib/python3.6/site-packages/statsmodels/base/model.py", line 749, in predict
    return self.model.predict(self.params, exog, *args, **kwargs)

  File "/Users/ritesh.satapathy/anaconda/lib/python3.6/site-packages/statsmodels/regression/linear_model.py", line 359, in predict
    return np.dot(exog, params)

ValueError: shapes (1,10) and (2,) not aligned: 10 (dim 1) != 2 (dim 0)
X_ne1 = X_test[:,3]
y_pred2 = regressor_OLS.predict(X_ne1)