MCPcopy Create free account
hub / github.com/apache/madlib / fill_row

Function fill_row

src/modules/recursive_partitioning/decision_tree.cpp:710–753  ·  view source on GitHub ↗

* Fil a row of the frame matrix using data in tree */

Source from the content-addressed store, hash-verified

708 * Fil a row of the frame matrix using data in tree
709 */
710void fill_row(MutableNativeMatrix &frame, Tree &dt, int me, int i, int n_cats) {
711 frame(i,0) = static_cast<double>(dt.encodeIndex(dt.feature_indices(me),
712 dt.is_categorical(me), n_cats));
713 frame(i,5) = 1; // complexity is not needed in plotting
714 frame(i,6) = 0; // ncompete is not needed in plotting
715
716 // How many surrogate variables have been computed for this split
717 int n_surrogates = 0;
718 for (int ii = 0; ii < dt.max_n_surr; ii ++) {
719 if (dt.surr_indices(me * dt.max_n_surr + ii) >= 0) {
720 n_surrogates ++;
721 }
722 }
723 frame(i,7) = n_surrogates;
724
725 if (dt.is_regression) {
726 frame(i,1) = dt.predictions(me,3); // n
727 frame(i,2) = dt.predictions(me,0); // wt
728 frame(i,3) = dt.computeRisk(me); // weighted variance
729 frame(i,4) = dt.predictions(me, 1) / dt.predictions(me,0); // yval
730 } else {
731 double total_records = dt.nodeWeightedCount(0);
732 double n_records_innode = static_cast<double>(dt.nodeCount(me));
733 double n_records_weighted_innode = dt.nodeWeightedCount(me);
734 int n_dep_levels = static_cast<int>(dt.n_y_labels);
735
736 // FIXME use weight sum as the total number
737 frame(i,1) = n_records_innode;
738 frame(i,2) = n_records_weighted_innode;
739 frame(i,3) = dt.computeMisclassification(me);
740
741 Index max_index;
742 dt.predictions.row(me).head(dt.n_y_labels).maxCoeff(&max_index);
743 // start from 1 to be consistent with R convention
744 frame(i,4) = static_cast<double>(max_index + 1);
745 frame(i,8) = frame(i,4);
746 for (int j = 0; j < n_dep_levels; ++j) {
747 frame(i,9 + j) = dt.predictions(me, j);
748 frame(i,9 + j + n_dep_levels) =
749 dt.predictions(me, j) / n_records_innode;
750 }
751 frame(i,9 + 2 * n_dep_levels) = n_records_innode / total_records;
752 }
753}
754
755
756// ------------------------------------------------------------

Callers 1

transverse_treeFunction · 0.85

Calls 5

encodeIndexMethod · 0.80
computeRiskMethod · 0.80
nodeWeightedCountMethod · 0.80
nodeCountMethod · 0.80

Tested by

no test coverage detected