def teak(d=nasa93(), rows=None, verbose = False): rootNode = launchWhere2(d, rows, verbose) allLeaves = [] for leaf, level in leaves(rootNode): allLeaves.append(leaf) for leaf in allLeaves: if ((leaf.variance > 1.25*leaf._up.variance) or (leaf.variance > 0.75*d.max_variance)): leaf._up._kids.remove(leaf) return rootNode
def teak(d=nasa93(), rows=None, verbose=False): rootNode = launchWhere2(d, rows, verbose) allLeaves = [] for leaf, level in leaves(rootNode): allLeaves.append(leaf) for leaf in allLeaves: if ((leaf.variance > 1.25 * leaf._up.variance) or (leaf.variance > 0.75 * d.max_variance)): leaf._up._kids.remove(leaf) return rootNode
def teakImproved(d=nasa93(), rows=None, verbose=False): rootNode = launchWhere2(d, rows, verbose) truncatedRows = [] allLeaves = [] for leaf, level in leaves(rootNode): allLeaves.append(leaf) for leaf in allLeaves: if ((leaf.variance > 1.25*leaf._up.variance) or (leaf.variance > 0.75*d.max_variance)): truncatedRows += leaf.val newRows = [row for row in rootNode.val if row not in truncatedRows] return launchWhere2(d, newRows, verbose)
def launchTeak(d=nasa93(), settings=None, rows=None, verbose=False): if rows is None: rows = d._rows if settings is None: settings = teakSettings().defaults.update( minSize = int(len(rows)**0.5), prune = False ) root_node = launchWhere2(d, settings, rows, verbose) truncated_rows = [] all_leaves = [] for l, level in leaves(root_node): all_leaves.append(l) if len(all_leaves) > 1: for l in all_leaves: if l.variance > settings.par_var_ftr*l._up.variance \ or l.variance > settings.max_var_ftr*d.max_variance: truncated_rows += l.val new_rows = [row for row in root_node.val if row not in truncated_rows] if len(new_rows) == 0: return root_node return launchWhere2(d, settings, new_rows, verbose)
def _test(): for k in range(1,10): startTime = getTime() extrapolateNTimes(nasa93(), k) print(getTime()-startTime)
def _extrapolate(): extrapolateNTimes(nasa93(), extrapolationCount=2)
def _interpolate(): interpolateNTimes(nasa93(), interpolationCount=2)
def _test(): for k in range(1, 10): startTime = getTime() extrapolateNTimes(nasa93(), k) print(getTime() - startTime)