Skip to content

Commit

Permalink
added logic to handle leaf nodes
Browse files Browse the repository at this point in the history
Signed-off-by: Manish Amde <[email protected]>
  • Loading branch information
manishamde committed Feb 28, 2014
1 parent 80e8c66 commit b0eb866
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,11 @@ object DecisionTree extends Serializable {
*/
def isSampleValid(parentFilters: List[Filter], labeledPoint: LabeledPoint): Boolean = {

//Leaf
if (parentFilters.length == 0 ){
return false
}

for (filter <- parentFilters) {
val features = labeledPoint.features
val featureIndex = filter.split.feature
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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

class InformationGainStats(val gain : Double,
val impurity: Double,
val leftImpurity : Double,
val leftSamples : Long,
val rightImpurity : Double,
val rightSamples : Long) {

override def toString =
"gain = " + gain + ", impurity = " + impurity + ", left impurity = "
+ leftImpurity + ", leftSamples = " + leftSamples + ", right impurity = "
+ rightImpurity + ", rightSamples = " + rightSamples


}

0 comments on commit b0eb866

Please sign in to comment.