def filtered_dict(dictionary: dict, threshold, invert: bool = False):
    """
    Removes all keys from a dictionary whose value is less than a given threshold

    :param dictionary: The dictionary to filter
    :param threshold: The threshold below which to remove elements
    :param invert: Whether to invert the threshold (remove elements above threshold)
    :return: The filtered dictionary
    """
    return {key: value for (key, value) in dictionary.items() if (value < threshold) == invert}