import collections


def _get_infrequent_phrases(features_set, threshold_rate=0.03):
    """Get infrequent phrases on given dataset

    Args:
        features_set (iter): list of feature's dict
        threshold_rate (float, optional): Defaults to 0.03.

    Returns:
        set: set of infrequent phrase features
    """
    phrases = [f for fs in features_set for f in fs if f.startswith('C:kp__')]
    phrases = collections.Counter(phrases).most_common()
    n_cut = int(len(phrases) * threshold_rate)
    return set([p for p, _ in phrases[-n_cut:]])