def avg_polysemy(polysemy_dict):
    """
    compute average polysemy

    .. doctest::
        >>> avg_polysemy(defaultdict(int, {1: 2, 2: 2}))
        1.5

    :param collections.defaultdict polysemy_dict: mapping from polysemy class
    to number of instances in that class

    :rtype: float
    :return: average polysemy
    """
    numerator = sum([key * value for key, value in polysemy_dict.items()])
    denominator = sum(polysemy_dict.values())

    return numerator / denominator