Donate. I desperately need donations to survive due to my health

Get paid by answering surveys Click here

Click here to donate

Remote/Work from Home jobs

index 1 is out of bounds for axis 0 with size 0

i am trying to write a function to evaluate my model but throwing some index error when i try to run a function.

function to evaluate and print result summary but got an index 1 is out of bounds for axis 0 with size 0

def evaluate(classifier, test_split='dev', verbose=True):
    test_kbts_by_rel, true_labels_by_rel = build_datasets_for_split(test_split)
    results = {}
    if verbose:
        print_statistics_header()
    for rel in all_relations:
        pred_labels = classifier(test_kbts_by_rel[rel])
        stats = precision_recall_fscore_support(true_labels_by_rel[rel], pred_labels, beta=0.5)
        stats = [stat[1]for stat in stats]  # stats[1] is the stat for label True
        stats.append(len(pred_labels)) # number of examples
        results[rel] = stats
        if verbose:
            print_statistics_row(rel, results[rel])
    avg_result = macro_average_results(results)
    if verbose:
        print_statistics_footer(avg_result)
    return avg_result[2]
-----------------------------
evaluate(make_random_classifier())

---> 29  stats = [stat[1]for stat in stats]  # stats[1] is the stat for label True

IndexError: index 1 is out of bounds for axis 0 with size 0

Comments