# Path: scorpion/learners/cn2sd/rule.py
# def fill_in_rules(rules, table, cols=None, cont_dists=None):
#     # compute bounds for columns in self.cols
#     if cols is None:
#         cols = [attr.name for attr in table.domain]
# 
#     nparr = None
#     ref_bounds = {}
#     for col in cols:
#         attr = table.domain[col]
#         if attr.var_type == Orange.feature.Type.Discrete:
#             ref_bounds[col] = None
#             continue
# 
#         if cont_dists:
#           bound = cont_dists[attr.name].min, cont_dists[attr.name].max
#         else:
#           if nparr is None:
#             nparr = table.to_numpyMA('ac')[0]
#           pos = table.domain.index(attr)
#           arr = nparr[:,pos]
#           bound = (arr.min(), arr.max())
# 
#         ref_bounds[col] = bound
# 
# 
#     for rule in rules:
#         rule.fill_in_rule(table, ref_bounds)


import time
import pdb
import sys
import orngTree
import Orange
import orange
import heapq
import numpy as np
        import orngTree
from itertools import chain
from sklearn import tree as sktree
from ..learners.cn2sd.rule import fill_in_rules
from ..learners.cn2sd.refiner import *
from ..bottomup.bounding_box import *
from ..bottomup.cluster import *
from ..util import *
from ..settings import *
from basic import Basic
from merger import Merger
                "INFCLASS",
                vals=['0', '1'])

        start = time.time()
        self.compute_perrow_influences(self.bad_tables, self.bad_err_funcs)
        self.compute_perrow_influences(self.good_tables, self.good_err_funcs)
        self.cost_compute_inf = time.time() - start



        start = time.time()
        if self.tree_alg == 'c45':
          table, rules = self.c45_rules()
        elif self.tree_alg == 'or':
          table, rules = self.orange_dt_rules()
        elif self.tree_alg == 'dt':
          table, rules = self.sk_dt_rules(max_depth=12)
        elif self.tree_alg == 'rt':
          table, rules = self.sk_rt_rules(max_depth=12)
        else:
          _logger.warn("unknown NDT algorithm %s.  Defaulting to regression tree", self.tree_alg)
          table, rules = self.sk_rt_rules(max_depth=12)
        self.cost_learn = time.time() - start


        #
        # ok now convert rules to clusters
        #

        _logger.debug( "got %d rules", len(rules))

# Path: scorpion/learners/cn2sd/rule.py
# def fill_in_rules(rules, table, cols=None, cont_dists=None):
#     # compute bounds for columns in self.cols
#     if cols is None:
#         cols = [attr.name for attr in table.domain]
# 
#     nparr = None
#     ref_bounds = {}
#     for col in cols:
#         attr = table.domain[col]
#         if attr.var_type == Orange.feature.Type.Discrete:
#             ref_bounds[col] = None
#             continue
# 
#         if cont_dists:
#           bound = cont_dists[attr.name].min, cont_dists[attr.name].max
#         else:
#           if nparr is None:
#             nparr = table.to_numpyMA('ac')[0]
#           pos = table.domain.index(attr)
#           arr = nparr[:,pos]
#           bound = (arr.min(), arr.max())
# 
#         ref_bounds[col] = bound
# 
# 
#     for rule in rules:
#         rule.fill_in_rule(table, ref_bounds)


# Path: scorpion/sigmod/ndt.py
import time
import pdb
import sys
import orngTree
import Orange
import orange
import heapq
import numpy as np
        import orngTree
from itertools import chain
from sklearn import tree as sktree
from ..learners.cn2sd.rule import fill_in_rules
from ..learners.cn2sd.refiner import *
from ..bottomup.bounding_box import *
from ..bottomup.cluster import *
from ..util import *
from ..settings import *
from basic import Basic
from merger import Merger

                "INFCLASS",
                vals=['0', '1'])

        start = time.time()
        self.compute_perrow_influences(self.bad_tables, self.bad_err_funcs)
        self.compute_perrow_influences(self.good_tables, self.good_err_funcs)
        self.cost_compute_inf = time.time() - start



        start = time.time()
        if self.tree_alg == 'c45':
          table, rules = self.c45_rules()
        elif self.tree_alg == 'or':
          table, rules = self.orange_dt_rules()
        elif self.tree_alg == 'dt':
          table, rules = self.sk_dt_rules(max_depth=12)
        elif self.tree_alg == 'rt':
          table, rules = self.sk_rt_rules(max_depth=12)
        else:
          _logger.warn("unknown NDT algorithm %s.  Defaulting to regression tree", self.tree_alg)
          table, rules = self.sk_rt_rules(max_depth=12)
        self.cost_learn = time.time() - start


        #
        # ok now convert rules to clusters
        #

        _logger.debug( "got %d rules", len(rules))

        fill_in_rules(rules, table, cols=self.cols)