1
1
import argparse
2
- # from .foofah_libs.generate_prog import create_python_prog
3
2
import contextlib
4
3
import csv
5
4
import json
6
5
import os
7
6
import queue
8
7
from timeit import default_timer as timer
9
8
10
- # from . import foofah_libs.operators as Operations
11
9
import numpy as np
12
10
from Foofah .foofah_libs .foofah_node import FoofahNode
13
11
from Foofah .foofah_libs .generate_prog import create_python_prog
14
- # from .foofah_libs.foofah_node import FoofahNode
15
12
from Foofah .foofah_libs .operators import *
16
13
from tabulate import tabulate
17
14
@@ -476,24 +473,16 @@ def main(
476
473
raw_data = [list (map (str , x )) for x in test_data ["InputTable" ]]
477
474
target = [list (map (str , x )) for x in test_data ["OutputTable" ]]
478
475
479
- # print(target)
480
-
481
476
if if_auto_read :
482
477
raw_data = extract_table (raw_data )
483
478
484
479
start = timer ()
485
- # a = lambda x, p1, s: f_split_first(x, p1, s)
486
- # print(a(raw_data, 0, ' '))
487
- # exit()
488
480
search_space = None
489
- # print(what_to_explain)
490
481
if what_to_explain == "columns" :
491
482
if target_type == "TEXTUAL" :
492
483
search_space = add_ops_column ()
493
484
elif target_type == "BINARY_CLASSIFICATION" :
494
485
search_space = add_ops_column_text_to_class ()
495
- # elif target_type == 'MULTICLASS_CLASSIFICATION':
496
- # search_space = add_ops_column_text_to_class()
497
486
else :
498
487
search_space = add_ops_column_text_to_numeric ()
499
488
elif what_to_explain == "row" :
@@ -524,32 +513,8 @@ def main(
524
513
p3 = not p3off ,
525
514
)
526
515
527
- # if search_algo == ALGO_BFS:
528
- # final_node, open_nodes, closed_nodes = a_star_search(raw_data, target, add_ops(), debug_level,
529
- # timeout, batch=if_batch, algo=search_algo,
530
- # p1=not p1off, p2=not p2off, p3=not p3off)
531
- #
532
- # # elif search_algo == ALGO_A_STAR:
533
- # # final_node, open_nodes, closed_nodes = a_star_search(raw_data, target, add_ops(), debug_level,
534
- # # timeout = 5, batch=if_batch, epsilon=epsilon,
535
- # # bound=bound, algo=search_algo, p1=not p1off,
536
- # # p2=not p2off,
537
- # # p3=not p3off)
538
- # elif search_algo == ALGO_A_STAR:
539
- # final_node, open_nodes, closed_nodes = a_star_search(raw_data, target, add_ops_column(), debug_level,
540
- # timeout = ext_time_limit, batch=if_batch, epsilon=epsilon,
541
- # bound=bound, algo=search_algo, p1=not p1off,
542
- # p2=not p2off,
543
- # p3=not p3off)
544
- # elif search_algo == ALGO_A_STAR_NAIVE:
545
- # final_node, open_nodes, closed_nodes = a_star_search(raw_data, target, add_ops(), debug_level,
546
- # timeout, batch=if_batch, epsilon=epsilon,
547
- # bound=bound, algo=search_algo, p1=not p1off,
548
- # p2=not p2off,
549
- # p3=not p3off)
550
-
551
516
end = timer ()
552
- # if_detail = ext_if_detail
517
+
553
518
if final_node :
554
519
path = reconstruct_path (final_node )
555
520
# Some statistics
@@ -560,25 +525,6 @@ def main(
560
525
branch_factor = max (np .real (np .roots (poly )))
561
526
create_python_prog (path , raw_data , True )
562
527
563
- # if not if_detail:
564
- # return
565
- # program = create_python_prog(path, raw_data, True)
566
- #
567
- # print("# A Program Has Been Successfully Synthesized")
568
- # print("#")
569
- # print(("# Input file:", test_file))
570
- # print(("# Total operations:", len(path) - 1))
571
- # print(("# Time elapsed: %.3f s Nodes visited: %d Nodes created: %d" % (
572
- # (end - start), num_visited, nodes_created)))
573
- # print(("# Naive branching factor: %d Effective branching factor: %.2f" % (
574
- # len(add_ops()), branch_factor)))
575
- # print(("# Make child time: %.2f s Heuristic time: %.2f s" % (
576
- # sum(final_node.times['children']), sum(final_node.times['scores']))))
577
- # print(("#", "-" * 50))
578
- # print()
579
- # print(program)
580
-
581
- # else:
582
528
with open ("foofah_log" , "w" ) as o :
583
529
with contextlib .redirect_stdout (o ):
584
530
print (("-" * 50 ))
@@ -729,7 +675,6 @@ def main(
729
675
json .dump (test_data , outfile )
730
676
731
677
else :
732
- # print("*** Solution Not Found ***")
733
678
return False
734
679
return True
735
680
0 commit comments