def encode_classes(df):
    """
    Categorical encoding
    :param df: pandas data frame with non-encoded class labels
    :return: the encoded data frame
    """
    class_dict = {
        'speedlimit': 0,
        'stop': 1,
        'crosswalk': 2,
        'trafficlight': 3
    }
    df['class'] = df['class'].apply(lambda x: class_dict[x])
    return df