woletee commited on
Commit
da4a91c
·
1 Parent(s): bd39949

modified the visualization for the test input and for the test output as well

Browse files
Files changed (2) hide show
  1. app.py +10 -6
  2. templates/results.html +30 -25
app.py CHANGED
@@ -55,9 +55,15 @@ def upload():
55
  predicted_HLCs=predicted_HLCs
56
  )
57
 
58
- # Prepare final grids for evaluation section
59
- last_input = tolist_safe(input_output_pairs[-1][0])
60
- last_ground_truth = tolist_safe(input_output_pairs[-1][1])
 
 
 
 
 
 
61
 
62
  try:
63
  predicted_output = tolist_safe(best_program.evaluate(last_input))
@@ -65,12 +71,10 @@ def upload():
65
  print("Error during best_program evaluation:", e)
66
  predicted_output = [["ERROR"]]
67
 
68
- # Convert all pairs to lists (in case of NumPy values)
69
- input_output_pairs = [(tolist_safe(i), tolist_safe(o)) for i, o in input_output_pairs]
70
-
71
  return render_template("results.html",
72
  hlcs=predicted_HLCs,
73
  input_output_pairs=input_output_pairs,
 
74
  best_program=str(best_program),
75
  last_input=last_input,
76
  last_ground_truth=last_ground_truth,
 
55
  predicted_HLCs=predicted_HLCs
56
  )
57
 
58
+ # Convert train pairs to plain lists
59
+ input_output_pairs = [(tolist_safe(i), tolist_safe(o)) for i, o in input_output_pairs]
60
+
61
+ # Prepare test pairs as well
62
+ test_pairs = [(tolist_safe(sample["input"]), tolist_safe(sample["output"])) for sample in data.get("test", [])]
63
+
64
+ # Prepare final program evaluation display
65
+ last_input = input_output_pairs[-1][0] if input_output_pairs else []
66
+ last_ground_truth = input_output_pairs[-1][1] if input_output_pairs else []
67
 
68
  try:
69
  predicted_output = tolist_safe(best_program.evaluate(last_input))
 
71
  print("Error during best_program evaluation:", e)
72
  predicted_output = [["ERROR"]]
73
 
 
 
 
74
  return render_template("results.html",
75
  hlcs=predicted_HLCs,
76
  input_output_pairs=input_output_pairs,
77
+ test_pairs=test_pairs,
78
  best_program=str(best_program),
79
  last_input=last_input,
80
  last_ground_truth=last_ground_truth,
templates/results.html CHANGED
@@ -71,36 +71,21 @@
71
 
72
  <div id="pairs-container"></div>
73
 
 
 
 
74
  <h2>Best Program</h2>
75
  <pre>{{ best_program }}</pre>
76
 
77
- <h2>Best Program Evaluation (Last Grid)</h2>
78
- <div class="grid-container">
79
- <div>
80
- <div class="grid-title">Last Input Grid</div>
81
- <div id="last-input-grid" class="grid-box"></div>
82
- </div>
83
- <div>
84
- <div class="grid-title">Ground Truth Output</div>
85
- <div id="last-ground-truth-grid" class="grid-box"></div>
86
- </div>
87
- <div>
88
- <div class="grid-title">Predicted Output by Best Program</div>
89
- <div id="predicted-output-grid" class="grid-box"></div>
90
- </div>
91
- </div>
92
-
93
  <script>
94
  const inputOutputPairs = {{ input_output_pairs | tojson | safe }};
95
  const hlcs = {{ hlcs | tojson | safe }};
96
- const lastInput = {{ last_input | tojson | safe }};
97
- const lastGroundTruth = {{ last_ground_truth | tojson | safe }};
98
- const predictedOutput = {{ predicted_output | tojson | safe }};
99
 
100
  const colorMap = {
101
- 0: "#FFFFFF", 1: "#0074D9", 2: "#FF4136", 3: "#2ECC40",
102
- 4: "#FFDC00", 5: "#B10DC9", 6: "#FF851B", 7: "#7FDBFF",
103
- 8: "#F012BE", 9: "#111111"
104
  };
105
 
106
  function drawGrid(container, gridData) {
@@ -154,9 +139,29 @@
154
  pairsContainer.appendChild(container);
155
  });
156
 
157
- drawGrid(document.getElementById("last-input-grid"), lastInput);
158
- drawGrid(document.getElementById("last-ground-truth-grid"), lastGroundTruth);
159
- drawGrid(document.getElementById("predicted-output-grid"), predictedOutput);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
160
  </script>
161
 
162
  </body>
 
71
 
72
  <div id="pairs-container"></div>
73
 
74
+ <h2>Test Pairs</h2>
75
+ <div id="test-pairs-container"></div>
76
+
77
  <h2>Best Program</h2>
78
  <pre>{{ best_program }}</pre>
79
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
80
  <script>
81
  const inputOutputPairs = {{ input_output_pairs | tojson | safe }};
82
  const hlcs = {{ hlcs | tojson | safe }};
83
+ const testPairs = {{ test_pairs | tojson | safe }};
 
 
84
 
85
  const colorMap = {
86
+ 0: "#000000", 1: "#0074D9", 2: "#FF4136", 3: "#2ECC40",
87
+ 4: "#FFDC00", 5: "#AAAAAA", 6: "#F012BE", 7: "#FF851B",
88
+ 8: "#7FDBFF", 9: "#870C25"
89
  };
90
 
91
  function drawGrid(container, gridData) {
 
139
  pairsContainer.appendChild(container);
140
  });
141
 
142
+ const testContainer = document.getElementById("test-pairs-container");
143
+ testPairs.forEach((pair, index) => {
144
+ const container = document.createElement("div");
145
+ container.className = "grid-container";
146
+
147
+ const inputDiv = document.createElement("div");
148
+ inputDiv.innerHTML = `<div class="grid-title">Test Input Grid</div>`;
149
+ const inputGridBox = document.createElement("div");
150
+ inputGridBox.className = "grid-box";
151
+ inputDiv.appendChild(inputGridBox);
152
+ drawGrid(inputGridBox, pair[0]);
153
+
154
+ const outputDiv = document.createElement("div");
155
+ outputDiv.innerHTML = `<div class="grid-title">Test Ground Truth Output Grid</div>`;
156
+ const outputGridBox = document.createElement("div");
157
+ outputGridBox.className = "grid-box";
158
+ outputDiv.appendChild(outputGridBox);
159
+ drawGrid(outputGridBox, pair[1]);
160
+
161
+ container.appendChild(inputDiv);
162
+ container.appendChild(outputDiv);
163
+ testContainer.appendChild(container);
164
+ });
165
  </script>
166
 
167
  </body>