henrydavidge commented on a change in pull request #24953:
[SPARK-28140][MLLIB][PYTHON] Accept DataFrames in RowMatrix and
IndexedRowMatrix constructors
URL: https://github.com/apache/spark/pull/24953#discussion_r296945212
##########
File path:
mllib/src/main/scala/org/apache/spark/mllib/api/python/PythonMLLibAPI.scala
##########
@@ -1142,12 +1141,21 @@ private[python] class PythonMLLibAPI extends
Serializable {
new RowMatrix(rows.rdd, numRows, numCols)
}
+ def createRowMatrix(df: DataFrame, numRows: Long, numCols: Int): RowMatrix =
{
+ require(df.schema.length == 1 && df.schema.head.dataType.getClass ==
classOf[VectorUDT],
+ "DataFrame must have a single vector type column")
+ new RowMatrix(df.rdd.map { case Row(vector: Vector) => vector }, numRows,
numCols)
Review comment:
I'm not sure I follow what you mean by "doesn't save much". Could you
elaborate?
From Python, you don't need to specify the number of rows / columns. They're
0 by default, which will cause `RowMatrix` to infer the dimensions.
----------------------------------------------------------------
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]