def binarize(x, values, threshold=None, included_in='<STR_LIT>'):
lower, upper = values<EOL>if threshold is None:<EOL><INDENT>threshold = (lower + upper) / <NUM_LIT><EOL><DEDENT>x = x.copy()<EOL>if included_in == '<STR_LIT>':<EOL><INDENT>x[x <= threshold] = lower<EOL>x[x > threshold] = upper<EOL><DEDENT>elif included_in == '<STR_LIT>':<EOL><INDENT>x[x < threshold] = lower<EOL>x[x >= threshold] = upper<EOL><DEDENT>else:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>return x<EOL>
Binarizes the values of x.

    Parameters
    ----------
    values : tuple of two floats
        The lower and upper value to which the inputs are mapped.
    threshold : float
        The threshold; defaults to (values[0] + values[1]) / 2 if None.
    included_in : str
        Whether the threshold value itself belongs to the lower or
        upper interval.