Source code for metrics.writer

"""Writes the given metrics in a csv."""

import numpy as np
import os
import pandas as pd
import sys

models_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.append(models_dir)

from baseline_constants import CLIENT_ID_KEY, NUM_ROUND_KEY, NUM_SAMPLES_KEY


COLUMN_NAMES = [
    CLIENT_ID_KEY, NUM_ROUND_KEY, 'hierarchy', NUM_SAMPLES_KEY]








[docs]def get_metrics_names(metrics): """Gets the names of the metrics. Args: metrics: Dict keyed by client id. Each element is a dict of metrics for that client in the specified round. The dicts for all clients are expected to have the same set of keys.""" if len(metrics) == 0: return [] metrics_dict = next(iter(metrics.values())) return list(metrics_dict.keys())