A derived variable is a new variable created from existing variables through a calculation, rule, or transformation. In predictive modeling, it can encode a categorical target that the original data does not contain. section 6.2.2
Create a derived variable by following these practical steps:
- Identify the existing fields that contain the required inputs. section 6.2.2
- State the rule that converts those inputs into the new value. section 6.2.2
- Assign the result to the data frame and inspect its type and values. section 6.2.2
- Check edge cases and assumptions, such as missing values or nonnumeric source fields, before modeling or testing. section 6.2.2
Binary conversion target
For fourth-down plays, compare YARDS_GAINED with TO_GO: assign CONVERT = 0 when fewer yards are gained than required, and 1 otherwise. In NumPy, this rule is implemented with np.where and appended to the pandas data frame. section 6.2.2
Expected counts
For a chi-square goodness-of-fit test, multiply each expected proportion by the total count to create Expected_Counts, then compare observed Counts with the derived values. section 12.5.1

