Skip to content

Commit 834ca44

Browse files
committed
reordered the import accordingly to the guidelines
1 parent 349a76b commit 834ca44

File tree

1 file changed

+23
-22
lines changed

1 file changed

+23
-22
lines changed

mllib/src/main/scala/org/apache/spark/mllib/export/pmml/KMeansPMMLModelExport.scala

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -17,30 +17,31 @@
1717

1818
package org.apache.spark.mllib.export.pmml
1919

20-
import org.apache.spark.mllib.clustering.KMeansModel
20+
import org.dmg.pmml.Array.Type
21+
import org.dmg.pmml.Cluster
22+
import org.dmg.pmml.ClusteringField
23+
import org.dmg.pmml.ClusteringModel
24+
import org.dmg.pmml.ClusteringModel.ModelClass
25+
import org.dmg.pmml.CompareFunctionType
26+
import org.dmg.pmml.ComparisonMeasure
27+
import org.dmg.pmml.ComparisonMeasure.Kind
2128
import org.dmg.pmml.DataDictionary
22-
import org.dmg.pmml.FieldName
2329
import org.dmg.pmml.DataField
24-
import org.dmg.pmml.OpType
2530
import org.dmg.pmml.DataType
26-
import org.dmg.pmml.MiningSchema
27-
import org.dmg.pmml.MiningField
31+
import org.dmg.pmml.FieldName
2832
import org.dmg.pmml.FieldUsageType
29-
import org.dmg.pmml.ComparisonMeasure
30-
import org.dmg.pmml.ComparisonMeasure.Kind
31-
import org.dmg.pmml.SquaredEuclidean
32-
import org.dmg.pmml.ClusteringModel
33+
import org.dmg.pmml.MiningField
3334
import org.dmg.pmml.MiningFunctionType
34-
import org.dmg.pmml.ClusteringModel.ModelClass
35-
import org.dmg.pmml.ClusteringField
36-
import org.dmg.pmml.CompareFunctionType
37-
import org.dmg.pmml.Cluster
38-
import org.dmg.pmml.Array.Type
35+
import org.dmg.pmml.MiningSchema
36+
import org.dmg.pmml.OpType
37+
import org.dmg.pmml.SquaredEuclidean
38+
39+
import org.apache.spark.mllib.clustering.KMeansModel
3940

4041
/**
4142
* PMML Model Export for KMeansModel class
4243
*/
43-
class KMeansPMMLModelExport(model : KMeansModel) extends PMMLModelExport{
44+
private[mllib] class KMeansPMMLModelExport(model : KMeansModel) extends PMMLModelExport{
4445

4546
/**
4647
* Export the input KMeansModel model to PMML format
@@ -55,18 +56,18 @@ class KMeansPMMLModelExport(model : KMeansModel) extends PMMLModelExport{
5556

5657
val clusterCenter = model.clusterCenters(0)
5758

58-
var fields = new Array[FieldName](clusterCenter.size)
59+
val fields = new Array[FieldName](clusterCenter.size)
5960

60-
var dataDictionary = new DataDictionary()
61+
val dataDictionary = new DataDictionary()
6162

62-
var miningSchema = new MiningSchema()
63+
val miningSchema = new MiningSchema()
6364

64-
var comparisonMeasure = new ComparisonMeasure()
65+
val comparisonMeasure = new ComparisonMeasure()
6566
.withKind(Kind.DISTANCE)
6667
.withMeasure(new SquaredEuclidean()
6768
);
6869

69-
var clusteringModel = new ClusteringModel(miningSchema, comparisonMeasure,
70+
val clusteringModel = new ClusteringModel(miningSchema, comparisonMeasure,
7071
MiningFunctionType.CLUSTERING, ModelClass.CENTER_BASED, model.clusterCenters.length)
7172
.withModelName("k-means");
7273

@@ -84,8 +85,8 @@ class KMeansPMMLModelExport(model : KMeansModel) extends PMMLModelExport{
8485

8586
dataDictionary.withNumberOfFields((dataDictionary.getDataFields()).size());
8687

87-
for ( i <- 0 to (model.clusterCenters.size - 1)) {
88-
var cluster = new Cluster()
88+
for ( i <- 0 until model.clusterCenters.size ) {
89+
val cluster = new Cluster()
8990
.withName("cluster_" + i)
9091
.withArray(new org.dmg.pmml.Array()
9192
.withType(Type.REAL)

0 commit comments

Comments
 (0)