fix ddpg metrics
This commit is contained in:
parent
a9f1556184
commit
21971e673f
|
@ -152,28 +152,22 @@ def clean_metric_data(metric_matrix, metric_labels, session):
|
||||||
metric_cat = [session.target_objective]
|
metric_cat = [session.target_objective]
|
||||||
for metric_obj in metric_objs:
|
for metric_obj in metric_objs:
|
||||||
metric_cat.append(metric_obj.name)
|
metric_cat.append(metric_obj.name)
|
||||||
matrix = np.array(metric_matrix)
|
|
||||||
missing_columns = sorted(set(metric_cat) - set(metric_labels))
|
missing_columns = sorted(set(metric_cat) - set(metric_labels))
|
||||||
unused_columns = set(metric_labels) - set(metric_cat)
|
unused_columns = set(metric_labels) - set(metric_cat)
|
||||||
LOG.debug("clean_metric_data added %d metrics and removed %d metric.", len(missing_columns),
|
LOG.debug("clean_metric_data added %d metrics and removed %d metric.", len(missing_columns),
|
||||||
len(unused_columns))
|
len(unused_columns))
|
||||||
# If columns are missing from the matrix
|
default_val = 0
|
||||||
if missing_columns:
|
metric_cat_size = len(metric_cat)
|
||||||
for metric in missing_columns:
|
matrix = np.ones((len(metric_matrix), metric_cat_size)) * default_val
|
||||||
# append a missing column after the last column
|
metric_labels_dict = {n: i for i, n in enumerate(metric_labels)}
|
||||||
index = matrix.shape[1] # pylint: disable=unsubscriptable-object
|
# column labels in matrix has the same order as ones in metric catalog
|
||||||
default_val = 0
|
# missing values are filled with default_val
|
||||||
matrix = np.insert(matrix, index, default_val, axis=1)
|
for i, metric_name in enumerate(metric_cat):
|
||||||
metric_labels.append(metric)
|
if metric_name in metric_labels_dict:
|
||||||
|
index = metric_labels_dict[metric_name]
|
||||||
|
matrix[:, i] = metric_matrix[:, index]
|
||||||
LOG.debug(matrix.shape)
|
LOG.debug(matrix.shape)
|
||||||
# If they are useless columns in the matrix
|
return matrix, metric_cat
|
||||||
if unused_columns:
|
|
||||||
indexes = [i for i, n in enumerate(metric_labels) if n in unused_columns]
|
|
||||||
# Delete unused columns
|
|
||||||
matrix = np.delete(matrix, indexes, 1)
|
|
||||||
for i in sorted(indexes, reverse=True):
|
|
||||||
del metric_labels[i]
|
|
||||||
return matrix, metric_labels
|
|
||||||
|
|
||||||
|
|
||||||
def save_execution_time(start_ts, fn, result):
|
def save_execution_time(start_ts, fn, result):
|
||||||
|
|
Loading…
Reference in New Issue