Tianyi commited on
Commit
e702fcc
·
1 Parent(s): 3ac6f7d

minor update on power scheduling eval

Browse files
Files changed (1) hide show
  1. tasks/power_scheduling/eval.py +7 -7
tasks/power_scheduling/eval.py CHANGED
@@ -17,22 +17,22 @@ def task_loss(Y_sched, Y_actual, params):
17
  def load_indexed_json(path):
18
  with open(path) as f:
19
  data = json.load(f)
20
- rows = [data[k] for k in sorted(data.keys(), key=int)]
21
- return np.array(rows, dtype=np.float64)
22
 
23
 
24
  def load_predicted_json(path):
25
  with open(path) as f:
26
  data = json.load(f)
27
  keys = sorted(data.keys(), key=int)
28
- Z = np.array([data[k] for k in keys], dtype=np.float64)
29
- return Z
30
 
31
 
32
  def evaluate(pred_path, actual_path, params=PARAMS):
33
- Z_pred = load_predicted_json(pred_path)
34
- Y_actual = load_indexed_json(actual_path)
35
-
 
36
  assert Z_pred.shape == Y_actual.shape, \
37
  f"z shape mismatch: pred {Z_pred.shape} vs actual {Y_actual.shape}"
38
 
 
17
  def load_indexed_json(path):
18
  with open(path) as f:
19
  data = json.load(f)
20
+ keys = sorted(data.keys(), key=int)
21
+ return np.array([data[k] for k in keys], dtype=np.float64), keys
22
 
23
 
24
  def load_predicted_json(path):
25
  with open(path) as f:
26
  data = json.load(f)
27
  keys = sorted(data.keys(), key=int)
28
+ return np.array([data[k] for k in keys], dtype=np.float64), keys
 
29
 
30
 
31
  def evaluate(pred_path, actual_path, params=PARAMS):
32
+ Z_pred, p_inst = load_predicted_json(pred_path)
33
+ Y_actual, a_inst = load_indexed_json(actual_path)
34
+
35
+ assert p_inst == a_inst, "instance ids mismatch between pred and actual"
36
  assert Z_pred.shape == Y_actual.shape, \
37
  f"z shape mismatch: pred {Z_pred.shape} vs actual {Y_actual.shape}"
38