zhengruifeng commented on issue #27003: [SPARK-30347][ML] LibSVMDataSource 
attach AttributeGroup
URL: https://github.com/apache/spark/pull/27003#issuecomment-568722282
 
 
   After this PR, `LibSVMDataSource` will attach `AttributeGroup` for ML impls, 
while keep current metata.
   ```scala
   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
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to