------------------------------------------------------------ functions ------------------------------------------------------------
| 48 | // functions |
| 49 | // ------------------------------------------------------------ |
| 50 | AnyType |
| 51 | initialize_decision_tree::run(AnyType & args){ |
| 52 | DecisionTree<MutableRootContainer> dt = DecisionTree<MutableRootContainer>(); |
| 53 | bool is_regression_tree = args[0].getAs<bool>(); |
| 54 | std::string impurity_func_str = args[1].getAs<std::string>(); |
| 55 | uint16_t n_y_labels = args[2].getAs<uint16_t>(); |
| 56 | uint16_t max_n_surr = args[3].getAs<uint16_t>(); |
| 57 | |
| 58 | if (is_regression_tree) |
| 59 | n_y_labels = REGRESS_N_STATS; |
| 60 | dt.rebind(1u, n_y_labels, max_n_surr, is_regression_tree); |
| 61 | dt.feature_indices(0) = dt.IN_PROCESS_LEAF; |
| 62 | dt.feature_thresholds(0) = 0; |
| 63 | dt.is_categorical(0) = 0; |
| 64 | if (max_n_surr > 0){ |
| 65 | dt.surr_indices.setConstant(dt.SURR_NON_EXISTING); |
| 66 | dt.surr_thresholds.setConstant(0); |
| 67 | dt.surr_status.setConstant(0); |
| 68 | } |
| 69 | dt.predictions.row(0).setConstant(0); |
| 70 | |
| 71 | dt.is_regression = is_regression_tree; |
| 72 | if (dt.is_regression){ |
| 73 | dt.impurity_type = dt.MSE; // only MSE defined for regression |
| 74 | } else { |
| 75 | if ((impurity_func_str.compare("misclassification") == 0) || |
| 76 | (impurity_func_str.compare("misclass") == 0)) |
| 77 | dt.impurity_type = dt.MISCLASS; |
| 78 | else if ((impurity_func_str.compare("entropy") == 0) || |
| 79 | (impurity_func_str.compare("cross-entropy") == 0)) |
| 80 | dt.impurity_type = dt.ENTROPY; |
| 81 | else |
| 82 | dt.impurity_type = dt.GINI; // default impurity for classification |
| 83 | } |
| 84 | |
| 85 | return dt.storage(); |
| 86 | } // initialize_decision_tree |
| 87 | // ------------------------------------------------------------ |
| 88 | |
| 89 | //////////////////////////////////////////////////////////////// |
nothing calls this directly
no test coverage detected