diff options
Diffstat (limited to 'mllib')
11 files changed, 15 insertions, 15 deletions
diff --git a/mllib/src/main/scala/org/apache/spark/ml/ann/Layer.scala b/mllib/src/main/scala/org/apache/spark/ml/ann/Layer.scala index d02806a6ea..f21b623e93 100644 --- a/mllib/src/main/scala/org/apache/spark/ml/ann/Layer.scala +++ b/mllib/src/main/scala/org/apache/spark/ml/ann/Layer.scala @@ -213,8 +213,8 @@ private[ann] object AffineLayerModel { */ def randomWeights(numIn: Int, numOut: Int, seed: Long = 11L): (BDM[Double], BDV[Double]) = { val rand: XORShiftRandom = new XORShiftRandom(seed) - val weights = BDM.fill[Double](numOut, numIn){ (rand.nextDouble * 4.8 - 2.4) / numIn } - val bias = BDV.fill[Double](numOut){ (rand.nextDouble * 4.8 - 2.4) / numIn } + val weights = BDM.fill[Double](numOut, numIn) { (rand.nextDouble * 4.8 - 2.4) / numIn } + val bias = BDV.fill[Double](numOut) { (rand.nextDouble * 4.8 - 2.4) / numIn } (weights, bias) } } @@ -529,7 +529,7 @@ private[ml] object FeedForwardTopology { */ def multiLayerPerceptron(layerSizes: Array[Int], softmax: Boolean = true): FeedForwardTopology = { val layers = new Array[Layer]((layerSizes.length - 1) * 2) - for(i <- 0 until layerSizes.length - 1){ + for(i <- 0 until layerSizes.length - 1) { layers(i * 2) = new AffineLayer(layerSizes(i), layerSizes(i + 1)) layers(i * 2 + 1) = if (softmax && i == layerSizes.length - 2) { @@ -655,7 +655,7 @@ private[ann] object FeedForwardModel { val layers = topology.layers val layerModels = new Array[LayerModel](layers.length) var offset = 0 - for(i <- 0 until layers.length){ + for(i <- 0 until layers.length) { layerModels(i) = layers(i).getInstance(seed) offset += layerModels(i).size } diff --git a/mllib/src/main/scala/org/apache/spark/ml/classification/NaiveBayes.scala b/mllib/src/main/scala/org/apache/spark/ml/classification/NaiveBayes.scala index 718f49d3ae..483ef0d88c 100644 --- a/mllib/src/main/scala/org/apache/spark/ml/classification/NaiveBayes.scala +++ b/mllib/src/main/scala/org/apache/spark/ml/classification/NaiveBayes.scala @@ -145,7 +145,7 @@ class NaiveBayesModel private[ml] ( case Multinomial => (None, None) case Bernoulli => val negTheta = theta.map(value => math.log(1.0 - math.exp(value))) - val ones = new DenseVector(Array.fill(theta.numCols){1.0}) + val ones = new DenseVector(Array.fill(theta.numCols) {1.0}) val thetaMinusNegTheta = theta.map { value => value - math.log(1.0 - math.exp(value)) } diff --git a/mllib/src/main/scala/org/apache/spark/mllib/api/python/PythonMLLibAPI.scala b/mllib/src/main/scala/org/apache/spark/mllib/api/python/PythonMLLibAPI.scala index 886cd60687..132dc174a8 100644 --- a/mllib/src/main/scala/org/apache/spark/mllib/api/python/PythonMLLibAPI.scala +++ b/mllib/src/main/scala/org/apache/spark/mllib/api/python/PythonMLLibAPI.scala @@ -428,7 +428,7 @@ private[python] class PythonMLLibAPI extends Serializable { val weight = wt.toArray val mean = mu.map(_.asInstanceOf[DenseVector]) val sigma = si.map(_.asInstanceOf[DenseMatrix]) - val gaussians = Array.tabulate(weight.length){ + val gaussians = Array.tabulate(weight.length) { i => new MultivariateGaussian(mean(i), sigma(i)) } val model = new GaussianMixtureModel(weight, gaussians) diff --git a/mllib/src/main/scala/org/apache/spark/mllib/classification/NaiveBayes.scala b/mllib/src/main/scala/org/apache/spark/mllib/classification/NaiveBayes.scala index aef9ef2cb0..9026b97f1c 100644 --- a/mllib/src/main/scala/org/apache/spark/mllib/classification/NaiveBayes.scala +++ b/mllib/src/main/scala/org/apache/spark/mllib/classification/NaiveBayes.scala @@ -74,7 +74,7 @@ class NaiveBayesModel private[spark] ( case Multinomial => (None, None) case Bernoulli => val negTheta = thetaMatrix.map(value => math.log(1.0 - math.exp(value))) - val ones = new DenseVector(Array.fill(thetaMatrix.numCols){1.0}) + val ones = new DenseVector(Array.fill(thetaMatrix.numCols) {1.0}) val thetaMinusNegTheta = thetaMatrix.map { value => value - math.log(1.0 - math.exp(value)) } diff --git a/mllib/src/main/scala/org/apache/spark/mllib/evaluation/MultilabelMetrics.scala b/mllib/src/main/scala/org/apache/spark/mllib/evaluation/MultilabelMetrics.scala index 6dd541e5c0..77bd0aa30d 100644 --- a/mllib/src/main/scala/org/apache/spark/mllib/evaluation/MultilabelMetrics.scala +++ b/mllib/src/main/scala/org/apache/spark/mllib/evaluation/MultilabelMetrics.scala @@ -152,7 +152,7 @@ class MultilabelMetrics @Since("1.2.0") (predictionAndLabels: RDD[(Array[Double] */ @Since("1.2.0") lazy val microPrecision: Double = { - val sumFp = fpPerClass.foldLeft(0L){ case(cum, (_, fp)) => cum + fp} + val sumFp = fpPerClass.foldLeft(0L) { case(cum, (_, fp)) => cum + fp} sumTp.toDouble / (sumTp + sumFp) } @@ -162,7 +162,7 @@ class MultilabelMetrics @Since("1.2.0") (predictionAndLabels: RDD[(Array[Double] */ @Since("1.2.0") lazy val microRecall: Double = { - val sumFn = fnPerClass.foldLeft(0.0){ case(cum, (_, fn)) => cum + fn} + val sumFn = fnPerClass.foldLeft(0.0) { case(cum, (_, fn)) => cum + fn} sumTp.toDouble / (sumTp + sumFn) } diff --git a/mllib/src/main/scala/org/apache/spark/mllib/linalg/BLAS.scala b/mllib/src/main/scala/org/apache/spark/mllib/linalg/BLAS.scala index d2687dc11b..27a7380567 100644 --- a/mllib/src/main/scala/org/apache/spark/mllib/linalg/BLAS.scala +++ b/mllib/src/main/scala/org/apache/spark/mllib/linalg/BLAS.scala @@ -420,7 +420,7 @@ private[spark] object BLAS extends Serializable with Logging { val AcolPtrs = A.colPtrs // Slicing is easy in this case. This is the optimal multiplication setting for sparse matrices - if (A.isTransposed){ + if (A.isTransposed) { var colCounterForB = 0 if (!B.isTransposed) { // Expensive to put the check inside the loop while (colCounterForB < nB) { diff --git a/mllib/src/main/scala/org/apache/spark/mllib/regression/IsotonicRegression.scala b/mllib/src/main/scala/org/apache/spark/mllib/regression/IsotonicRegression.scala index f235089873..abdd798197 100644 --- a/mllib/src/main/scala/org/apache/spark/mllib/regression/IsotonicRegression.scala +++ b/mllib/src/main/scala/org/apache/spark/mllib/regression/IsotonicRegression.scala @@ -136,7 +136,7 @@ class IsotonicRegressionModel @Since("1.3.0") ( // higher than all values, in between two values or exact match. if (insertIndex == 0) { predictions.head - } else if (insertIndex == boundaries.length){ + } else if (insertIndex == boundaries.length) { predictions.last } else if (foundIndex < 0) { linearInterpolation( diff --git a/mllib/src/main/scala/org/apache/spark/mllib/util/NumericParser.scala b/mllib/src/main/scala/org/apache/spark/mllib/util/NumericParser.scala index a841c5caf0..2c613348c2 100644 --- a/mllib/src/main/scala/org/apache/spark/mllib/util/NumericParser.scala +++ b/mllib/src/main/scala/org/apache/spark/mllib/util/NumericParser.scala @@ -98,7 +98,7 @@ private[mllib] object NumericParser { } } else if (token == ")") { parsing = false - } else if (token.trim.isEmpty){ + } else if (token.trim.isEmpty) { // ignore whitespaces between delim chars, e.g. ", [" } else { // expecting a number diff --git a/mllib/src/test/scala/org/apache/spark/ml/classification/RandomForestClassifierSuite.scala b/mllib/src/test/scala/org/apache/spark/ml/classification/RandomForestClassifierSuite.scala index 6b810ab9ea..4c7c56782c 100644 --- a/mllib/src/test/scala/org/apache/spark/ml/classification/RandomForestClassifierSuite.scala +++ b/mllib/src/test/scala/org/apache/spark/ml/classification/RandomForestClassifierSuite.scala @@ -105,7 +105,7 @@ class RandomForestClassifierSuite extends SparkFunSuite with MLlibTestSparkConte compareAPIs(rdd, rf, categoricalFeatures, numClasses) } - test("subsampling rate in RandomForest"){ + test("subsampling rate in RandomForest") { val rdd = orderedLabeledPoints5_20 val categoricalFeatures = Map.empty[Int, Int] val numClasses = 2 diff --git a/mllib/src/test/scala/org/apache/spark/mllib/clustering/GaussianMixtureSuite.scala b/mllib/src/test/scala/org/apache/spark/mllib/clustering/GaussianMixtureSuite.scala index fb3bd3f412..67e680be73 100644 --- a/mllib/src/test/scala/org/apache/spark/mllib/clustering/GaussianMixtureSuite.scala +++ b/mllib/src/test/scala/org/apache/spark/mllib/clustering/GaussianMixtureSuite.scala @@ -182,7 +182,7 @@ class GaussianMixtureSuite extends SparkFunSuite with MLlibTestSparkContext { Vectors.dense( 4.5605), Vectors.dense( 5.2043), Vectors.dense( 6.2734) ) - val data2: Array[Vector] = Array.tabulate(25){ i: Int => + val data2: Array[Vector] = Array.tabulate(25) { i: Int => Vectors.dense(Array.tabulate(50)(i + _.toDouble)) } diff --git a/mllib/src/test/scala/org/apache/spark/mllib/tree/RandomForestSuite.scala b/mllib/src/test/scala/org/apache/spark/mllib/tree/RandomForestSuite.scala index e6df5d974b..c72fc9bb4f 100644 --- a/mllib/src/test/scala/org/apache/spark/mllib/tree/RandomForestSuite.scala +++ b/mllib/src/test/scala/org/apache/spark/mllib/tree/RandomForestSuite.scala @@ -197,7 +197,7 @@ class RandomForestSuite extends SparkFunSuite with MLlibTestSparkContext { featureSubsetStrategy = "sqrt", seed = 12345) } - test("subsampling rate in RandomForest"){ + test("subsampling rate in RandomForest") { val arr = EnsembleTestHelper.generateOrderedLabeledPoints(5, 20) val rdd = sc.parallelize(arr) val strategy = new Strategy(algo = Classification, impurity = Gini, maxDepth = 2, |