Github user MechCoder commented on a diff in the pull request:

    https://github.com/apache/spark/pull/7554#discussion_r35253870
  
    --- Diff: 
mllib/src/main/scala/org/apache/spark/mllib/api/python/PythonMLLibAPI.scala ---
    @@ -1105,6 +1108,59 @@ private[python] class PythonMLLibAPI extends 
Serializable {
         Statistics.kolmogorovSmirnovTest(data, distName, paramsSeq: _*)
       }
     
    +  /**
    +   * Wrapper around DistributedMatrices.rowMatrix factory method.
    +   */
    +  def createRowMatrix(rows: JavaRDD[Vector], numRows: Long, numCols: Int): 
RowMatrix = {
    +    DistributedMatrices.rowMatrix(rows.rdd, numRows, numCols)
    +  }
    +
    +  /**
    +   * Wrapper around DistributedMatrices.indexedRowMatrix factory method.
    +   */
    +  def createIndexedRowMatrix(rows: DataFrame, numRows: Long, numCols: 
Int): IndexedRowMatrix = {
    +    // We use DataFrames for serialization of IndexedRows from Python, so 
map each Row in the
    +    // DataFrame back to an IndexedRow.
    +    val indexedRows = rows.map { row =>
    +      val index = row.getLong(0)
    +      val vector = row.getAs[Vector](1)
    +      IndexedRow(index, vector)
    --- End diff --
    
    I am used to writing this in a line like
    
        rows.map { case Row(ind: Long, vec: Vector) => IndexedRow(ind, vec) }
    
    But that might be personal preference


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

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

Reply via email to