| 55 | } // namespace |
| 56 | |
| 57 | bool TensorDataSet::Decide(const decision_trees::BinaryNode& node, |
| 58 | int example) const { |
| 59 | // TODO(gilberth): Support missing values. |
| 60 | float val = 0; |
| 61 | const auto& test = node.inequality_left_child_test(); |
| 62 | |
| 63 | if (test.has_oblique()) { |
| 64 | for (int i = 0; i < test.oblique().features_size(); ++i) { |
| 65 | val += test.oblique().weights(i) * |
| 66 | GetExampleValue(example, test.oblique().features(i)); |
| 67 | } |
| 68 | } else { |
| 69 | val = GetExampleValue(example, test.feature_id()); |
| 70 | } |
| 71 | |
| 72 | if (node.has_inequality_left_child_test()) { |
| 73 | return DecideInequalityTest(node.inequality_left_child_test(), val); |
| 74 | } else { |
| 75 | decision_trees::MatchingValuesTest test; |
| 76 | if (node.custom_left_child_test().UnpackTo(&test)) { |
| 77 | return DecideMatchingValuesTest(test, val); |
| 78 | } else { |
| 79 | return false; |
| 80 | } |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | float TensorDataSet::GetExampleValue( |
| 85 | int example, const decision_trees::FeatureId& feature_id) const { |