17
17
18
18
package org .apache .spark .ml .feature
19
19
20
- import org .apache .spark .ml .{ Estimator , Model }
20
+ import org .apache .spark .annotation . AlphaComponent
21
21
import org .apache .spark .ml .param ._
22
+ import org .apache .spark .ml .{Estimator , Model }
22
23
import org .apache .spark .sql .DataFrame
23
24
import org .apache .spark .sql .functions ._
24
25
import org .apache .spark .sql .types .{IntegerType , StringType , StructField , StructType }
25
26
import org .apache .spark .util .collection .OpenHashMap
26
27
28
+ /**
29
+ * Base trait for [[LabelIndexer ]] and [[LabelIndexerModel ]].
30
+ */
27
31
private [feature] trait LabelIndexerBase extends Params with HasLabelCol with HasOutputCol {
28
32
29
- /** Validates and transforms input schema. */
33
+ /** Validates and transforms the input schema. */
30
34
protected def validateAndTransformSchema (schema : StructType , paramMap : ParamMap ): StructType = {
31
35
val map = this .paramMap ++ paramMap
32
36
val labelType = schema(map(labelCol)).dataType
@@ -41,6 +45,13 @@ private[feature] trait LabelIndexerBase extends Params with HasLabelCol with Has
41
45
}
42
46
}
43
47
48
+ /**
49
+ * :: AlphaComponent ::
50
+ * A label indexer that maps a string column of labels to an integer column of label indices.
51
+ * The indices are in [0, numLabels), ordered by label frequencies.
52
+ * The most frequent label gets index 0.
53
+ */
54
+ @ AlphaComponent
44
55
class LabelIndexer extends Estimator [LabelIndexerModel ] with LabelIndexerBase {
45
56
46
57
/** @group setParam */
@@ -65,6 +76,11 @@ class LabelIndexer extends Estimator[LabelIndexerModel] with LabelIndexerBase {
65
76
}
66
77
}
67
78
79
+ /**
80
+ * :: AlphaComponent ::
81
+ * Model fitted by [[LabelIndexer ]].
82
+ */
83
+ @ AlphaComponent
68
84
class LabelIndexerModel private [ml] (
69
85
override val parent : LabelIndexer ,
70
86
override val fittingParamMap : ParamMap ,
0 commit comments