0

I've created some mixed integer linear programming models for feature selection in classification based on support vector machines. Now I should do cross validation on these models, but I can't figure out how to use the scikit learn library to apply it to a model created with the docplex library.

For example, if I wanted to cross validate a simple integer linear programming problem, how should I do it?

from docplex.mp.model import Model

mdl = Model(name='model')

# Decision variables
x = mdl.integer_var(name='x')
y = mdl.integer_var(name='y')

# Costraints
mdl.add_constraint(-3 * x + y <= 6)
mdl.add_constraint(x + 2 * y <= 4)

# Objective function
mdl.minimize(-x + 4 * y)

# Solve the model
sol = mdl.solve()

# Print the solution
print(f'Optimum: {sol.objective_value:.2f}')
print(f'x, y: {sol.get_value(x)}, {sol.get_value(y)}')

I was expecting to be able to use the scikit learn library's fit() and pred() methods, but I can't figure out how to do that. Thanks and sorry if I wasn't clear in the explanation.

Frax22
  • 1
  • 2

0 Answers0