Skip to content

Commit

Permalink
Update default params, fixed style cop
Browse files Browse the repository at this point in the history
  • Loading branch information
imatiach-msft authored and mhamilton723 committed Apr 13, 2018
1 parent b4cc756 commit a51d736
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
3 changes: 2 additions & 1 deletion src/lightgbm/src/main/scala/LightGBMClassifier.scala
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ class LightGBMClassifier(override val uid: String)
val encoder = Encoders.kryo[LightGBMBooster]
log.info(s"Nodes used for LightGBM: $nodes")
val trainParams = ClassifierTrainParams(getParallelism, getNumIterations, getLearningRate, getNumLeaves,
getMaxBin, getBaggingFraction, getBaggingFreq, getBaggingSeed, getFeatureFraction, getMaxDepth, getMinSumHessianInLeaf)
getMaxBin, getBaggingFraction, getBaggingFreq, getBaggingSeed, getFeatureFraction,
getMaxDepth, getMinSumHessianInLeaf)
val lightGBMBooster = df
.mapPartitions(TrainUtils.trainLightGBM(nodes, numNodes, getLabelCol, getFeaturesCol,
getDefaultListenPort, log, trainParams))(encoder)
Expand Down
14 changes: 7 additions & 7 deletions src/lightgbm/src/main/scala/LightGBMParams.scala
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ trait LightGBMParams extends MMLParams {
def getNumLeaves: Int = $(numLeaves)
def setNumLeaves(value: Int): this.type = set(numLeaves, value)

val maxBin = IntParam(this, "maxBin", "Max bin", 256)
val maxBin = IntParam(this, "maxBin", "Max bin", 255)

def getMaxBin: Int = $(maxBin)
def setMaxBin(value: Int): this.type = set(maxBin, value)
Expand All @@ -46,12 +46,12 @@ trait LightGBMParams extends MMLParams {
def getBaggingFraction: Double = $(baggingFraction)
def setBaggingFraction(value: Double): this.type = set(baggingFraction, value)

val baggingFreq = IntParam(this, "baggingFreq", "Bagging frequence", 1)
val baggingFreq = IntParam(this, "baggingFreq", "Bagging frequence", 0)

def getBaggingFreq: Int = $(baggingFreq)
def setBaggingFreq(value: Int): this.type = set(baggingFreq, value)

val baggingSeed = IntParam(this, "baggingSeed", "Bagging seed", 1)
val baggingSeed = IntParam(this, "baggingSeed", "Bagging seed", 3)

def getBaggingSeed: Int = $(baggingSeed)
def setBaggingSeed(value: Int): this.type = set(baggingSeed, value)
Expand All @@ -61,13 +61,13 @@ trait LightGBMParams extends MMLParams {
def getFeatureFraction: Double = $(featureFraction)
def setFeatureFraction(value: Double): this.type = set(featureFraction, value)

val maxDepth = IntParam(this, "maxDepth", "Max depth", 1)
val maxDepth = IntParam(this, "maxDepth", "Max depth", -1)

def getMaxDepth: Int = $(maxDepth)
def setMaxDepth(value: Int): this.type = set(maxDepth, value)

val minSumHessianInLeaf = IntParam(this, "minSumHessianInLeaf", "minimal sum hessian in one leaf", 1)
val minSumHessianInLeaf = DoubleParam(this, "minSumHessianInLeaf", "minimal sum hessian in one leaf", 1e-3)

def getMinSumHessianInLeaf: Int = $(minSumHessianInLeaf)
def setMinSumHessianInLeaf(value: Int): this.type = set(minSumHessianInLeaf, value)
def getMinSumHessianInLeaf: Double = $(minSumHessianInLeaf)
def setMinSumHessianInLeaf(value: Double): this.type = set(minSumHessianInLeaf, value)
}
12 changes: 7 additions & 5 deletions src/lightgbm/src/main/scala/TrainParams.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ abstract class TrainParams extends Serializable {
def baggingSeed: Int
def featureFraction: Double
def maxDepth: Int
def minSumHessianInLeaf: Int
def minSumHessianInLeaf: Double

override def toString(): String = {
s"is_pre_partition=True boosting_type=gbdt tree_learner=$parallelism num_iterations=$numIterations " +
s"learning_rate=$learningRate num_leaves=$numLeaves" +
s"max_bin=$maxBin bagging_fraction=$baggingFraction bagging_freq=$baggingFreq bagging_seed=$baggingSeed" +
s"learning_rate=$learningRate num_leaves=$numLeaves " +
s"max_bin=$maxBin bagging_fraction=$baggingFraction bagging_freq=$baggingFreq bagging_seed=$baggingSeed " +
s"feature_fraction=$featureFraction max_depth=$maxDepth min_sum_hessian_in_leaf=$minSumHessianInLeaf"
}
}
Expand All @@ -30,7 +30,8 @@ abstract class TrainParams extends Serializable {
*/
case class ClassifierTrainParams(val parallelism: String, val numIterations: Int, val learningRate: Double,
val numLeaves: Int, val maxBin: Int, val baggingFraction: Double, val baggingFreq: Int,
val baggingSeed: Int, val featureFraction: Double, val maxDepth: Int, val minSumHessianInLeaf: Int)
val baggingSeed: Int, val featureFraction: Double, val maxDepth: Int,
val minSumHessianInLeaf: Double)
extends TrainParams {
override def toString(): String = {
s"objective=binary metric=binary_logloss,auc ${super.toString()}"
Expand All @@ -42,7 +43,8 @@ case class ClassifierTrainParams(val parallelism: String, val numIterations: Int
case class RegressorTrainParams(val parallelism: String, val numIterations: Int, val learningRate: Double,
val numLeaves: Int, val application: String, val alpha: Double, val maxBin: Int,
val baggingFraction: Double, val baggingFreq: Int,
val baggingSeed: Int, val featureFraction: Double, val maxDepth: Int, val minSumHessianInLeaf: Int)
val baggingSeed: Int, val featureFraction: Double,
val maxDepth: Int, val minSumHessianInLeaf: Double)
extends TrainParams {
override def toString(): String = {
s"objective=$application alpha=$alpha ${super.toString()}"
Expand Down

0 comments on commit a51d736

Please sign in to comment.