spark-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hirakendu <>
Subject [GitHub] spark pull request: MLI-1 Decision Trees
Date Wed, 02 Apr 2014 21:36:20 GMT
Github user hirakendu commented on a diff in the pull request:
    --- Diff: mllib/src/main/scala/org/apache/spark/mllib/tree/model/Node.scala ---
    @@ -0,0 +1,90 @@
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +package org.apache.spark.mllib.tree.model
    +import org.apache.spark.Logging
    +import org.apache.spark.mllib.tree.configuration.FeatureType._
    + * Node in a decision tree
    + * @param id integer node id
    + * @param predict predicted value at the node
    + * @param isLeaf whether the leaf is a node
    + * @param split split to calculate left and right nodes
    + * @param leftNode  left child
    + * @param rightNode right child
    + * @param stats information gain stats
    + */
    +class Node (
    --- End diff --
    `Node` should be a recursive/linked structure with references to child nodes and parent
node (the latter allows for easy traversal), so I don't see the need for `nodes: Array[Node]`
as the model and the `build` method in `Node`. The `DecisionTreeModel` should essentially
be the root `Node` with methods like `predict` etc. involving a recursive traversal on child
    The method `predictIfleaf` in `Node` should be renamed to simply `predict`. It predicts
regardless of whether it's a leaf and does recursive traversal until it hits a leaf child.
The prediction value should be renamed to `prediction` instead of `predict`, which would clean
up the ambiguity with this `predict` method.
    Putting things together: `Node` should be simple with a `prediction` and should be a recursive
structure. `DecisionTreeModel` should be a wrapper around a root `Node` member and contain
methods like `predict`, `save`, `explain`, `load` etc. based on recursive traversal.

If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at or file a JIRA ticket
with INFRA.

View raw message