Permalink
Browse files

added boost from average parameter to LightGBM

  • Loading branch information...
imatiach-msft authored and mhamilton723 committed Jan 15, 2019
1 parent bf2bb0f commit 833003c8a765403aa8477965a629dc1f2b62534e
@@ -75,7 +75,7 @@ class LightGBMClassifier(override val uid: String)
val trainParams = ClassifierTrainParams(getParallelism, getNumIterations, getLearningRate, getNumLeaves,
getMaxBin, getBaggingFraction, getBaggingFreq, getBaggingSeed, getEarlyStoppingRound,
getFeatureFraction, getMaxDepth, getMinSumHessianInLeaf, numWorkers, getObjective, getModelString,
getIsUnbalance, getVerbosity, categoricalIndexes, classes, metric)
getIsUnbalance, getVerbosity, categoricalIndexes, classes, metric, getBoostFromAverage)
log.info(s"LightGBMClassifier parameters: ${trainParams.toString}")
val networkParams = NetworkParams(getDefaultListenPort, inetAddress, port)

@@ -130,4 +130,11 @@ trait LightGBMParams extends Wrappable with DefaultParamsWritable with HasWeight

def getCategoricalSlotNames: Array[String] = $(categoricalSlotNames)
def setCategoricalSlotNames(value: Array[String]): this.type = set(categoricalSlotNames, value)

val boostFromAverage = new BooleanParam(this, "boostFromAverage",
"Adjusts initial score to the mean of labels for faster convergence")
setDefault(boostFromAverage -> true)

def getBoostFromAverage: Boolean = $(boostFromAverage)
def setBoostFromAverage(value: Boolean): this.type = set(boostFromAverage, value)
}
@@ -82,7 +82,7 @@ class LightGBMRegressor(override val uid: String)
val trainParams = RegressorTrainParams(getParallelism, getNumIterations, getLearningRate, getNumLeaves,
getObjective, getAlpha, getTweedieVariancePower, getMaxBin, getBaggingFraction, getBaggingFreq, getBaggingSeed,
getEarlyStoppingRound, getFeatureFraction, getMaxDepth, getMinSumHessianInLeaf, numWorkers, getModelString,
getVerbosity, categoricalIndexes)
getVerbosity, categoricalIndexes, getBoostFromAverage)
log.info(s"LightGBMRegressor parameters: ${trainParams.toString}")
val networkParams = NetworkParams(getDefaultListenPort, inetAddress, port)

@@ -23,6 +23,7 @@ abstract class TrainParams extends Serializable {
def modelString: String
def verbosity: Int
def categoricalFeatures: Array[Int]
def boostFromAverage: Boolean

override def toString(): String = {
s"is_pre_partition=True boosting_type=gbdt tree_learner=$parallelism num_iterations=$numIterations " +
@@ -31,6 +32,7 @@ abstract class TrainParams extends Serializable {
s"bagging_seed=$baggingSeed early_stopping_round=$earlyStoppingRound " +
s"feature_fraction=$featureFraction max_depth=$maxDepth min_sum_hessian_in_leaf=$minSumHessianInLeaf " +
s"num_machines=$numMachines objective=$objective verbosity=$verbosity " +
s"boost_from_average=${boostFromAverage.toString} " +
(if (categoricalFeatures.isEmpty) "" else s"categorical_feature=${categoricalFeatures.mkString(",")}")
}
}
@@ -43,7 +45,7 @@ case class ClassifierTrainParams(val parallelism: String, val numIterations: Int
val maxDepth: Int, val minSumHessianInLeaf: Double,
val numMachines: Int, val objective: String, val modelString: String,
val isUnbalance: Boolean, val verbosity: Int, val categoricalFeatures: Array[Int],
val numClass: Option[Int], val metric: String)
val numClass: Option[Int], val metric: String, val boostFromAverage: Boolean)
extends TrainParams {
override def toString(): String = {
val extraStr =
@@ -61,7 +63,8 @@ case class RegressorTrainParams(val parallelism: String, val numIterations: Int,
val baggingFraction: Double, val baggingFreq: Int,
val baggingSeed: Int, val earlyStoppingRound: Int, val featureFraction: Double,
val maxDepth: Int, val minSumHessianInLeaf: Double, val numMachines: Int,
val modelString: String, val verbosity: Int, val categoricalFeatures: Array[Int])
val modelString: String, val verbosity: Int, val categoricalFeatures: Array[Int],
val boostFromAverage: Boolean)
extends TrainParams {
override def toString(): String = {
s"alpha=$alpha tweedie_variance_power=$tweedieVariancePower ${super.toString}"

0 comments on commit 833003c

Please sign in to comment.