Skip to content

Commit

Permalink
remove ;this from setters
Browse files Browse the repository at this point in the history
  • Loading branch information
mengxr committed Nov 11, 2014
1 parent fa21d9b commit 0435076
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 28 deletions.
4 changes: 2 additions & 2 deletions mllib/src/main/scala/org/apache/spark/ml/Transformer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ abstract class Transformer extends PipelineStage with Params {
abstract class UnaryTransformer[IN, OUT: TypeTag, T <: UnaryTransformer[IN, OUT, T]]
extends Transformer with HasInputCol with HasOutputCol with Logging {

def setInputCol(value: String): T = { set(inputCol, value); this.asInstanceOf[T] }
def setOutputCol(value: String): T = { set(outputCol, value); this.asInstanceOf[T] }
def setInputCol(value: String): T = set(inputCol, value).asInstanceOf[T]
def setOutputCol(value: String): T = set(outputCol, value).asInstanceOf[T]

/**
* Creates the transform function using the given param map. The input param map already takes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,13 @@ class LogisticRegression extends Estimator[LogisticRegressionModel] with Logisti
setMaxIter(100)
setThreshold(0.5)

def setRegParam(value: Double): this.type = { set(regParam, value); this }
def setMaxIter(value: Int): this.type = { set(maxIter, value); this }
def setLabelCol(value: String): this.type = { set(labelCol, value); this }
def setThreshold(value: Double): this.type = { set(threshold, value); this }
def setFeaturesCol(value: String): this.type = { set(featuresCol, value); this }
def setScoreCol(value: String): this.type = { set(scoreCol, value); this }
def setPredictionCol(value: String): this.type = { set(predictionCol, value); this }
def setRegParam(value: Double): this.type = set(regParam, value)
def setMaxIter(value: Int): this.type = set(maxIter, value)
def setLabelCol(value: String): this.type = set(labelCol, value)
def setThreshold(value: Double): this.type = set(threshold, value)
def setFeaturesCol(value: String): this.type = set(featuresCol, value)
def setScoreCol(value: String): this.type = set(scoreCol, value)
def setPredictionCol(value: String): this.type = set(predictionCol, value)

override def fit(dataset: SchemaRDD, paramMap: ParamMap): LogisticRegressionModel = {
transform(dataset.schema, paramMap, logging = true)
Expand Down Expand Up @@ -116,10 +116,10 @@ class LogisticRegressionModel private[ml] (
val weights: Vector)
extends Model[LogisticRegressionModel] with LogisticRegressionParams {

def setThreshold(value: Double): this.type = { set(threshold, value); this }
def setFeaturesCol(value: String): this.type = { set(featuresCol, value); this }
def setScoreCol(value: String): this.type = { set(scoreCol, value); this }
def setPredictionCol(value: String): this.type = { set(predictionCol, value); this }
def setThreshold(value: Double): this.type = set(threshold, value)
def setFeaturesCol(value: String): this.type = set(featuresCol, value)
def setScoreCol(value: String): this.type = set(scoreCol, value)
def setPredictionCol(value: String): this.type = set(predictionCol, value)

override def transform(schema: StructType, paramMap: ParamMap): StructType = {
transformSchema(schema, paramMap, fitting = false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ class BinaryClassificationEvaluator extends Evaluator with Params
val metricName: Param[String] = new Param(this, "metricName",
"metric name in evaluation (areaUnderROC|areaUnderPR)", Some("areaUnderROC"))
def getMetricName: String = get(metricName)
def setMetricName(value: String): this.type = { set(metricName, value); this }
def setMetricName(value: String): this.type = set(metricName, value)

def setScoreCol(value: String): this.type = { set(scoreCol, value); this }
def setLabelCol(value: String): this.type = { set(labelCol, value); this }
def setScoreCol(value: String): this.type = set(scoreCol, value)
def setLabelCol(value: String): this.type = set(labelCol, value)

override def evaluate(dataset: SchemaRDD, paramMap: ParamMap): Double = {
val map = this.paramMap ++ paramMap
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class HashingTF extends UnaryTransformer[Iterable[_], Vector, HashingTF] {

/** number of features */
val numFeatures = new IntParam(this, "numFeatures", "number of features", Some(1 << 18))
def setNumFeatures(value: Int) = { set(numFeatures, value); this }
def setNumFeatures(value: Int) = set(numFeatures, value)
def getNumFeatures: Int = get(numFeatures)

override protected def createTransformFunc(paramMap: ParamMap): Iterable[_] => Vector = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ private[feature] trait StandardScalerParams extends Params with HasInputCol with
*/
class StandardScaler extends Estimator[StandardScalerModel] with StandardScalerParams {

def setInputCol(value: String): this.type = { set(inputCol, value); this }
def setOutputCol(value: String): this.type = { set(outputCol, value); this }
def setInputCol(value: String): this.type = set(inputCol, value)
def setOutputCol(value: String): this.type = set(outputCol, value)

override def fit(dataset: SchemaRDD, paramMap: ParamMap): StandardScalerModel = {
transform(dataset.schema, paramMap, logging = true)
Expand Down Expand Up @@ -74,8 +74,8 @@ class StandardScalerModel private[ml] (
scaler: feature.StandardScalerModel)
extends Model[StandardScalerModel] with StandardScalerParams {

def setInputCol(value: String): this.type = { set(inputCol, value); this }
def setOutputCol(value: String): this.type = { set(outputCol, value); this }
def setInputCol(value: String): this.type = set(inputCol, value)
def setOutputCol(value: String): this.type = set(outputCol, value)

override def transform(dataset: SchemaRDD, paramMap: ParamMap): SchemaRDD = {
transform(dataset.schema, paramMap, logging = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,10 @@ class CrossValidator extends Estimator[CrossValidatorModel] with CrossValidatorP

private val f2jBLAS = new F2jBLAS

def setEstimator(value: Estimator[_]): this.type = { set(estimator, value); this }
def setEstimatorParamMaps(value: Array[ParamMap]): this.type = {
set(estimatorParamMaps, value)
this
}
def setEvaluator(value: Evaluator): this.type = { set(evaluator, value); this }
def setNumFolds(value: Int): this.type = { set(numFolds, value); this }
def setEstimator(value: Estimator[_]): this.type = set(estimator, value)
def setEstimatorParamMaps(value: Array[ParamMap]): this.type = set(estimatorParamMaps, value)
def setEvaluator(value: Evaluator): this.type = set(evaluator, value)
def setNumFolds(value: Int): this.type = set(numFolds, value)

override def fit(dataset: SchemaRDD, paramMap: ParamMap): CrossValidatorModel = {
val map = this.paramMap ++ paramMap
Expand Down

0 comments on commit 0435076

Please sign in to comment.