def report(grid_scores, n_top=3):
    """
    Report top n_top parameters settings, default n_top=3

    :param grid_scores: output from grid or random search
    :param n_top: how many to report, of top models
    :return: top_params: [dict] top parameter settings found in
                  search
    """
    if len(grid_scores["mean_test_score"]) < n_top:
        n_top = len(grid_scores["mean_test_score"])

    top_scores = {"params": [], "mean_test_score": [], "std_test_score": []}
    if "mean_train_score" in grid_scores.keys():
        top_scores["mean_train_score"] = []
        top_scores["std_train_score"] = []

    rank = grid_scores["rank_test_score"].tolist()
    i = 1
    while n_top > 0:
        ii = [ind for ind, val in enumerate(rank) if val == i]
        if n_top < len(ii):
            for k in top_scores.keys():
                for ind in ii[:n_top]:
                    top_scores[k].append(grid_scores[k][ind])
            n_top = 0
        else:
            for k in top_scores.keys():
                for ind in ii:
                    top_scores[k].append(grid_scores[k][ind])
            n_top = n_top - len(ii)
        i = (i + len(ii))

    return top_scores