-
Notifications
You must be signed in to change notification settings - Fork 28.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SPARK-10573] [ML] IndexToString output schema should be StringType
Fixes bug where IndexToString output schema was DoubleType. Correct me if I'm wrong, but it doesn't seem like the output needs to have any "ML Attribute" metadata. Author: Nick Pritchard <[email protected]> Closes #8751 from pnpritchard/SPARK-10573.
- Loading branch information
Showing
2 changed files
with
10 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,7 +27,7 @@ import org.apache.spark.ml.Transformer | |
import org.apache.spark.ml.util.Identifiable | ||
import org.apache.spark.sql.DataFrame | ||
import org.apache.spark.sql.functions._ | ||
import org.apache.spark.sql.types.{DoubleType, NumericType, StringType, StructType} | ||
import org.apache.spark.sql.types._ | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
pnpritchard
|
||
import org.apache.spark.util.collection.OpenHashMap | ||
|
||
/** | ||
|
@@ -229,8 +229,7 @@ class IndexToString private[ml] ( | |
val outputColName = $(outputCol) | ||
require(inputFields.forall(_.name != outputColName), | ||
s"Output column $outputColName already exists.") | ||
val attr = NominalAttribute.defaultAttr.withName($(outputCol)) | ||
val outputFields = inputFields :+ attr.toStructField() | ||
val outputFields = inputFields :+ StructField($(outputCol), StringType) | ||
StructType(outputFields) | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I'm confused with the change since the corresponding
Suite
in the change got that 4-class import added. What's the proper coding style for import?