A binary variable has two possible values, commonly coded 0 and 1. In a classification dataset, it records which of two categories an observation belongs to. In an optimization model, a binary decision variable instead records a choice the model must make. The coding is similar, but an observed class and a chosen action have different roles. section 5.2 section 8.2
Classifying raisins
A dataset of 900 raisins has seven numeric measurements and a Class column identifying Kecimen or Besni. Map Kecimen to 0 and Besni to 1 before using Class as the dependent variable in logistic regression. Grouping measurements by Class then helps reveal differences between the varieties; the codes identify categories, not measured quantities. section 5.2 section 5.2.1
For feature selection, define one decision variable per candidate feature: 1 means selected and 0 means not selected. A linear objective can combine each selection with its priority score, while budget and strategic constraints limit feasible combinations. section 8.2
>>> x_bounds = [(0, 1) for _ in features]
The Python list comprehension creates a (0, 1) bound tuple for every feature. These bounds specify the range supplied to the solver; the intended decisions are discrete yes-or-no selections. section 8.2.5


