-
Notifications
You must be signed in to change notification settings - Fork 28.9k
[SPARK-10258] [DOCUMENTATION, ML] Adding Since() Annotations to ml/feature #8505
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
c33fbf6
@Since() annotations for spark/ml/feature
a4b1703
annotating constructor and constructor public variables
e69acd4
fixing stylecheck errors (lines >100 chars)
b0881a3
Missing import of custom Since(..) annotation
b2cc944
correcting version for default constructors
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -17,7 +17,7 @@ | |
|
|
||
| package org.apache.spark.ml.feature | ||
|
|
||
| import org.apache.spark.annotation.Experimental | ||
| import org.apache.spark.annotation.{Experimental, Since} | ||
| import org.apache.spark.ml.Transformer | ||
| import org.apache.spark.ml.attribute.AttributeGroup | ||
| import org.apache.spark.ml.param.{IntParam, ParamMap, ParamValidators} | ||
|
|
@@ -32,15 +32,20 @@ import org.apache.spark.sql.types.{ArrayType, StructType} | |
| * :: Experimental :: | ||
| * Maps a sequence of terms to their term frequencies using the hashing trick. | ||
| */ | ||
| @Since("1.2.0") | ||
| @Experimental | ||
| class HashingTF(override val uid: String) extends Transformer with HasInputCol with HasOutputCol { | ||
| class HashingTF @Since("1.2.0") (@Since("1.4.0") override val uid: String) extends Transformer | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The constructor with |
||
| with HasInputCol with HasOutputCol { | ||
|
|
||
| @Since("1.2.0") | ||
| def this() = this(Identifiable.randomUID("hashingTF")) | ||
|
|
||
| /** @group setParam */ | ||
| @Since("1.4.0") | ||
| def setInputCol(value: String): this.type = set(inputCol, value) | ||
|
|
||
| /** @group setParam */ | ||
| @Since("1.4.0") | ||
| def setOutputCol(value: String): this.type = set(outputCol, value) | ||
|
|
||
| /** | ||
|
|
@@ -54,11 +59,14 @@ class HashingTF(override val uid: String) extends Transformer with HasInputCol w | |
| setDefault(numFeatures -> (1 << 18)) | ||
|
|
||
| /** @group getParam */ | ||
| @Since("1.2.0") | ||
| def getNumFeatures: Int = $(numFeatures) | ||
|
|
||
| /** @group setParam */ | ||
| @Since("1.2.0") | ||
| def setNumFeatures(value: Int): this.type = set(numFeatures, value) | ||
|
|
||
| @Since("1.4.0") | ||
| override def transform(dataset: DataFrame): DataFrame = { | ||
| val outputSchema = transformSchema(dataset.schema) | ||
| val hashingTF = new feature.HashingTF($(numFeatures)) | ||
|
|
@@ -67,6 +75,7 @@ class HashingTF(override val uid: String) extends Transformer with HasInputCol w | |
| dataset.select(col("*"), t(col($(inputCol))).as($(outputCol), metadata)) | ||
| } | ||
|
|
||
| @Since("1.4.0") | ||
| override def transformSchema(schema: StructType): StructType = { | ||
| val inputType = schema($(inputCol)).dataType | ||
| require(inputType.isInstanceOf[ArrayType], | ||
|
|
@@ -75,5 +84,6 @@ class HashingTF(override val uid: String) extends Transformer with HasInputCol w | |
| SchemaUtils.appendColumn(schema, attrGroup.toStructField()) | ||
| } | ||
|
|
||
| @Since("1.4.1") | ||
| override def copy(extra: ParamMap): HashingTF = defaultCopy(extra) | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default constructor should be since 1.2.0. Please check others as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @mengxr I'm a little confused here because Binarizer wasn't added until 1.4.0. I did correct the default constructor to 1.2.0 for the original classes from that version (HashingTF, StandardScaler, Tokenizer).