csinva / imodels

Interpretable ML package šŸ” for concise, transparent, and accurate predictive modeling (sklearn-compatible).
https://csinva.io/imodels
MIT License
1.39k stars 122 forks source link

SLIMRegressor error #17

Closed ukamath closed 3 years ago

ukamath commented 3 years ago

Running SLIMRegressor on the Regression dataset https://www.kaggle.com/mirichoi0218/insurance with the handling of categorical values, the error I get is


SolverError Traceback (most recent call last)

in 1 from imodels import SLIMRegressor 2 rf = SLIMRegressor() ----> 3 rf.fit(X, y) ~/opt/anaconda3/lib/python3.7/site-packages/imodels/algebraic/slim.py in fit(self, X, y, lambda_reg, sample_weight) 49 50 # solve the problem using an appropriate solver ---> 51 prob.solve() 52 self.model.coef_ = w.value.astype(np.int) 53 self.model.intercept_ = 0 ~/opt/anaconda3/lib/python3.7/site-packages/cvxpy/problems/problem.py in solve(self, *args, **kwargs) 394 else: 395 solve_func = Problem._solve --> 396 return solve_func(self, *args, **kwargs) 397 398 @classmethod ~/opt/anaconda3/lib/python3.7/site-packages/cvxpy/problems/problem.py in _solve(self, solver, warm_start, verbose, gp, qcp, requires_grad, enforce_dpp, **kwargs) 749 750 data, solving_chain, inverse_data = self.get_problem_data( --> 751 solver, gp, enforce_dpp) 752 solution = solving_chain.solve_via_data( 753 self, data, warm_start, verbose, kwargs) ~/opt/anaconda3/lib/python3.7/site-packages/cvxpy/problems/problem.py in get_problem_data(self, solver, gp, enforce_dpp) 498 self._cache.invalidate() 499 solving_chain = self._construct_chain( --> 500 solver=solver, gp=gp, enforce_dpp=enforce_dpp) 501 self._cache.key = key 502 self._cache.solving_chain = solving_chain ~/opt/anaconda3/lib/python3.7/site-packages/cvxpy/problems/problem.py in _construct_chain(self, solver, gp, enforce_dpp) 655 A solving chain 656 """ --> 657 candidate_solvers = self._find_candidate_solvers(solver=solver, gp=gp) 658 return construct_solving_chain(self, candidate_solvers, gp=gp, 659 enforce_dpp=enforce_dpp) ~/opt/anaconda3/lib/python3.7/site-packages/cvxpy/problems/problem.py in _find_candidate_solvers(self, solver, gp) 614 in incorrect solutions and is not recommended. 615 """ --> 616 raise error.SolverError(msg) 617 candidates['qp_solvers'] = [ 618 s for s in candidates['qp_solvers'] SolverError: You need a mixed-integer solver for this model. Refer to the documentation https://www.cvxpy.org/tutorial/advanced/index.html#mixed-integer-programs for discussion on this topic. Quick fix 1: if you install the python package CVXOPT (pip install cvxopt), then CVXPY can use the open-source mixed-integer solver `GLPK`. Quick fix 2: you can explicitly specify solver='ECOS_BB'. This may result in incorrect solutions and is not recommended.
csinva commented 3 years ago

Hello, thanks for your interest šŸ˜Š! Sorry about this - we seem to have forgotten cvxopt as a dependency. You should be able to fix this issue with pip install cvxopt. We've also added it to our dependencies going forward!