Getting No loop matching the specified signature and casting error

As suggested previously, you need to ensure X_opt is a float type. For example in your code, it would look like this:

X_opt = X[:, [0,1,2]]
X_opt = X_opt.astype(float)
regressor_OLS = sm.OLS(endog=y, exog=X_opt).fit()
regressor_OLS.summary()

Faced the similar problem. Solved the problem my mentioning dtype and flatten the array.

numpy version: 1.17.3

a = np.array(a, dtype=np.float)
a = a.flatten()

try specifiying the

dtype = 'float'

When the matrix is created. Example:

a=np.matrix([[1,2],[3,4]], dtype='float')

Hope this works!