|
25 | 25 | # .. codeauthor:: jhkwakkel <j.h.kwakkel (at) tudelft (dot) nl> |
26 | 26 |
|
27 | 27 |
|
28 | | -__all__ = ["CART", "setup_cart"] |
| 28 | +__all__ = ["CART"] |
29 | 29 | _logger = get_module_logger(__name__) |
30 | 30 |
|
31 | 31 |
|
32 | | -def setup_cart(results, classify, incl_unc=None, mass_min=0.05): |
33 | | - """Helper function for performing cart in combination with data generated by the workbench. |
34 | | -
|
35 | | - Parameters |
36 | | - ---------- |
37 | | - results : tuple of DataFrame and dict with numpy arrays |
38 | | - the return from :meth:`perform_experiments`. |
39 | | - classify : string, function or callable |
40 | | - either a string denoting the outcome of interest to |
41 | | - use or a function. |
42 | | - incl_unc : list of strings, optional |
43 | | - mass_min : float, optional |
44 | | -
|
45 | | -
|
46 | | - Raises: |
47 | | - ------ |
48 | | - TypeError |
49 | | - if classify is not a string or a callable. |
50 | | -
|
51 | | - """ |
52 | | - x, outcomes = results |
53 | | - |
54 | | - if incl_unc is not None: |
55 | | - drop_names = set(x.columns.values.tolist()) - set(incl_unc) |
56 | | - x = x.drop(drop_names, axis=1) |
57 | | - |
58 | | - if isinstance(classify, str): |
59 | | - y = outcomes[classify] |
60 | | - mode = sdutil.RuleInductionType.REGRESSION |
61 | | - elif callable(classify): |
62 | | - y = classify(outcomes) |
63 | | - mode = sdutil.RuleInductionType.BINARY |
64 | | - else: |
65 | | - raise TypeError(f"Unknown type for classify: {type(classify)}") |
66 | | - |
67 | | - return CART(x, y, mass_min, mode=mode) |
68 | | - |
69 | | - |
70 | 32 | class CART(sdutil.OutputFormatterMixin): |
71 | 33 | """CART algorithm. |
72 | 34 |
|
|
0 commit comments