[SPARK-30347][ML] LibSVMDataSource attach AttributeGroup#27003
Closed
zhengruifeng wants to merge 1 commit intoapache:masterfrom
Closed
[SPARK-30347][ML] LibSVMDataSource attach AttributeGroup#27003zhengruifeng wants to merge 1 commit intoapache:masterfrom
zhengruifeng wants to merge 1 commit intoapache:masterfrom
Conversation
Contributor
Author
|
After this PR, scala> import org.apache.spark.ml.attribute._
import org.apache.spark.ml.attribute._
scala> val data = spark.read.format("libsvm").load("/data0/Dev/Opensource/spark/data/mllib/sample_multiclass_classification_data.txt")
19/12/24 18:47:35 WARN LibSVMFileFormat: 'numFeatures' option not specified, determining the number of features by going though the input. If you know the number in advance, please specify it via 'numFeatures' option to avoid the extra scan.
data: org.apache.spark.sql.DataFrame = [label: double, features: vector]
scala> data.schema("features").metadata
res0: org.apache.spark.sql.types.Metadata = {"ml_attr":{"num_attrs":4},"numFeatures":4}
scala> AttributeGroup.fromStructField(data.schema("features")).size
res1: Int = 4 |
|
Test build #115733 has finished for PR 27003 at commit
|
srowen
reviewed
Dec 24, 2019
Member
srowen
left a comment
There was a problem hiding this comment.
Looks OK pending tests if it's just attaching known metadata
Contributor
Author
|
Merged to master, thanks @srowen for reviewing! |
fqaiser94
pushed a commit
to fqaiser94/spark
that referenced
this pull request
Mar 30, 2020
### What changes were proposed in this pull request?
LibSVMDataSource attach AttributeGroup
### Why are the changes needed?
LibSVMDataSource will attach a special metadata to indicate numFeatures:
```scala
scala> val data = spark.read.format("libsvm").load("/data0/Dev/Opensource/spark/data/mllib/sample_multiclass_classification_data.txt")
scala> data.schema("features").metadata
res0: org.apache.spark.sql.types.Metadata = {"numFeatures":4}
```
However, all ML impls will try to obtain vector size via AttributeGroup, which can not use this metadata:
```scala
scala> import org.apache.spark.ml.attribute._
import org.apache.spark.ml.attribute._
scala> AttributeGroup.fromStructField(data.schema("features")).size
res1: Int = -1
```
### Does this PR introduce any user-facing change?
No
### How was this patch tested?
added tests
Closes apache#27003 from zhengruifeng/libsvm_attr_group.
Authored-by: zhengruifeng <ruifengz@foxmail.com>
Signed-off-by: zhengruifeng <ruifengz@foxmail.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What changes were proposed in this pull request?
LibSVMDataSource attach AttributeGroup
Why are the changes needed?
LibSVMDataSource will attach a special metadata to indicate numFeatures:
However, all ML impls will try to obtain vector size via AttributeGroup, which can not use this metadata:
Does this PR introduce any user-facing change?
No
How was this patch tested?
added tests