purijatin commented on a change in pull request #23549: [SPARK-26616][MLlib]
Expose document frequency in IDFModel
URL: https://github.com/apache/spark/pull/23549#discussion_r248322707
##########
File path: mllib/src/main/scala/org/apache/spark/ml/feature/IDF.scala
##########
@@ -175,13 +185,25 @@ object IDFModel extends MLReadable[IDFModel] {
private val className = classOf[IDFModel].getName
override def load(path: String): IDFModel = {
+ import org.json4s.DefaultFormats
+ implicit val format = DefaultFormats
val metadata = DefaultParamsReader.loadMetadata(path, sc, className)
+
val dataPath = new Path(path, "data").toString
val data = sparkSession.read.parquet(dataPath)
- val Row(idf: Vector) = MLUtils.convertVectorColumnsToML(data, "idf")
- .select("idf")
- .head()
- val model = new IDFModel(metadata.uid, new
feature.IDFModel(OldVectors.fromML(idf)))
+ val model = if (majorVersion(metadata.sparkVersion) >= 3) {
+ val Row(idf: Vector, df: Seq[_], numDocs: Long) =
Review comment:
Yes.
> [error] [warn]
/home/jatin/IdeaProjects/spark/mllib/src/main/scala/org/apache/spark/ml/feature/IDF.scala:195:
non-variable type argument Long in type pattern Seq[Long] (the underlying of
Seq[Long]) is unchecked since it is eliminated by erasure
> [error] [warn] val Row(idf: Vector, df: Seq[Long], numDocs: Long) =
> [error] [warn]
> [trace] Stack trace suppressed: run last mllib/compile:compile for the
full output.
> [error] (mllib/compile:compile) 1 fatal warnings
> [error] Total time: 17 s, completed 16 Jan, 2019 8:46:42 PM
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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]