Skip to content

Commit

Permalink
fixing formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
manishamde committed Oct 20, 2014
1 parent 823691b commit 6a11c02
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ class GradientBoosting (
* @return GradientBoostingModel that can be used for prediction
*/
def train(input: RDD[LabeledPoint]): GradientBoostingModel = {
val strategy = boostingStrategy.strategy
val algo = boostingStrategy.algo
algo match {
case Regression => GradientBoosting.boost(input, boostingStrategy)
Expand Down Expand Up @@ -177,6 +176,7 @@ object GradientBoosting extends Logging {
numClassesForClassification, categoricalFeaturesInfo = categoricalFeaturesInfo)
new GradientBoosting(boostingStrategy).train(input)
}

/**
* Java-friendly API for [[org.apache.spark.mllib.tree.GradientBoosting#trainRegressor]]
*
Expand Down Expand Up @@ -223,7 +223,6 @@ object GradientBoosting extends Logging {
new GradientBoosting(boostingStrategy).train(input)
}


/**
* Java-friendly API for [[org.apache.spark.mllib.tree.GradientBoosting#trainClassifier]]
*
Expand Down Expand Up @@ -274,7 +273,6 @@ object GradientBoosting extends Logging {
new GradientBoosting(boostingStrategy).train(input)
}


/**
* Method to train a gradient boosting regression model.
*
Expand Down Expand Up @@ -310,7 +308,6 @@ object GradientBoosting extends Logging {
new GradientBoosting(boostingStrategy).train(input)
}


/**
* Method to train a gradient boosting binary classification model.
*
Expand Down Expand Up @@ -346,7 +343,6 @@ object GradientBoosting extends Logging {
new GradientBoosting(boostingStrategy).train(input)
}


/**
* Method to train a gradient boosting regression model.
*
Expand All @@ -373,16 +369,14 @@ object GradientBoosting extends Logging {
* @param boostingStrategy Configuration options for the boosting algorithm.
* @return GradientBoostingModel that can be used for prediction
*/
def trainClassification(
def trainClassifier(
input: RDD[LabeledPoint],
boostingStrategy: BoostingStrategy): GradientBoostingModel = {
val algo = boostingStrategy.algo
require(algo == Classification, s"Only Classification algo supported. Provided algo is $algo.")
new GradientBoosting(boostingStrategy).train(input)
}



/**
* Internal method for performing regression using trees as base learners.
* @param input training dataset
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ private[tree] object BaggedPoint {
* @param withReplacement Sampling with/without replacement.
* @return BaggedPoint dataset representation
*/
def convertToBaggedRDD[Datum](
def convertToBaggedRDD[Datum] (
input: RDD[Datum],
subsample: Double,
numSubsamples: Int,
Expand All @@ -71,7 +71,7 @@ private[tree] object BaggedPoint {
}
}

private[tree] def convertToBaggedRDDSamplingWithoutReplacement[Datum](
private[tree] def convertToBaggedRDDSamplingWithoutReplacement[Datum] (
input: RDD[Datum],
subsample: Double,
numSubsamples: Int): RDD[BaggedPoint[Datum]] = {
Expand All @@ -95,7 +95,7 @@ private[tree] object BaggedPoint {
}
}

private[tree] def convertToBaggedRDDSamplingWithReplacement[Datum](
private[tree] def convertToBaggedRDDSamplingWithReplacement[Datum] (
input: RDD[Datum],
subsample: Double,
numSubsamples: Int): RDD[BaggedPoint[Datum]] = {
Expand All @@ -115,8 +115,8 @@ private[tree] object BaggedPoint {
}
}

private[tree] def convertToBaggedRDDWithoutSampling[Datum]
(input: RDD[Datum]): RDD[BaggedPoint[Datum]] = {
private[tree] def convertToBaggedRDDWithoutSampling[Datum] (
input: RDD[Datum]): RDD[BaggedPoint[Datum]] = {
input.map(datum => new BaggedPoint(datum, Array(1.0)))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ object LogLoss extends Loss {
*/
@DeveloperApi
override def lossGradient(
model: DecisionTreeModel,
point: LabeledPoint,
learningRate: Double): Double = {
model: DecisionTreeModel,
point: LabeledPoint,
learningRate: Double): Double = {
val prediction = model.predict(point.features)
val logLoss = 1.0 / (1.0 + math.exp(-prediction))
point.label - logLoss * learningRate
Expand Down

0 comments on commit 6a11c02

Please sign in to comment.