A binary feature represents exactly two categories or values, commonly encoded as 0 and 1. In modeling, it can capture a meaningful condition such as whether a day is a weekday. section 9.2.1
Use binary features to simplify categorical information when the distinction supports the modeling question.
- Dummy-code categorical variables by creating indicator features whose value is 1 when a category is present and 0 otherwise. section 9.2.1
- Replace several day-of-week indicators with one weekday feature when weekdays show similar behavior and weekends form the useful contrast. section 9.2.1
- Check correlations and weigh predictive value against added model complexity before keeping a derived feature. section 9.2.1
rats_weather["weekday"] = (rats_weather["dow"]<5).astype(int) #1
rats_weather[
["high_temp", "wind_speed", "weekday", "rat_sightings"]
].corr().round(2) #2
Inspect the binary weekday calculation and its correlations with temperature, wind speed, and rat sightings. section 9.2.1

