import math


def _epochs_from_trainset_size(trainset_size):
    """Returns a sensible number of epochs for a given trainset_size

    Args:
       trainset_size the size of the training set (i.e. examples in 1 epoch)

    Returns:
       integer number of suggested epochs to train for
    """
    log10 = math.log10(trainset_size/2)
    order = round(log10 - 1)
    inv_order = 5 - order
    factor = math.pow(2, inv_order)
    base = 3
    return round(factor * base)