1

In below code snippet I am trying to do a very simple linear regression using cvxpy and mosek solver

weight = df2['weight'].to_numpy()
A = df2[ regressors ].to_numpy()
x = cp.Variable(len(regressors ));
R = df2['y'].to_numpy()
cost = cp.sum_squares( A @ x - R)
print(A.shape, x.shape, R.shape)          # here it prints (134882, 8) (8,) (134882,)
prob = cp.Problem(cp.Minimize(cost), 
           [x >= 0])

but I keep getting below error.

Error: rescode.err_lower_bound_is_a_nan(1390): The lower bound specified is not a number (nan).

I have checked the manual: https://docs.mosek.com/latest/pythonapi/response-codes.html#mosek.rescode.err_lower_bound_is_a_nan but what exactly am I missing?

Matt Frank
  • 177
  • 6

1 Answers1

0

it's hard to answer this question without having a reproducible example with your data.

Your python code seems fine, so I believe the problem is in your data: if I must take a guess, I assume you have NaNs somewhere in your data which causes the failure.

I'm not sure if cvxpy and mosek handle nans at all, so it's a good idea to verify your data integrity before using them.

Roim
  • 2,986
  • 2
  • 10
  • 25