Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions docs/mllib-data-types.md
Original file line number Diff line number Diff line change
Expand Up @@ -379,14 +379,14 @@ A [`RowMatrix`](api/python/pyspark.mllib.html#pyspark.mllib.linalg.RowMatrix) ca
an `RDD` of Vectors.

{% highlight python %}
from pyspark.mllib.linalg import DistributedMatrices, Vectors
from pyspark.mllib.linalg import RowMatrix, Vectors

# Create an RDD of Vectors.
rows = sc.parallelize([Vectors.dense([1, 2, 3]), Vectors.dense([4, 5, 6]),
Vectors.dense([7, 8, 9]), Vectors.dense([10, 11, 12])])

# Create a RowMatrix from an RDD[Vector].
mat = DistributedMatrices.rowMatrix(rows)
mat = RowMatrix(rows)

# Get its size.
m = mat.numRows() # 4
Expand Down Expand Up @@ -468,7 +468,7 @@ created from an `RDD` of IndexedRows, where
indices.

{% highlight python %}
from pyspark.mllib.linalg import Vectors, DistributedMatrices, IndexedRow, IndexedRowMatrix
from pyspark.mllib.linalg import Vectors, IndexedRow, IndexedRowMatrix

# Create an RDD of indexed rows.
# - This can be done explicitly with the IndexedRow class:
Expand All @@ -481,7 +481,7 @@ indexedRows = sc.parallelize([(0, Vectors.dense([1, 2, 3])), (1, Vectors.dense([
(2, Vectors.dense([7, 8, 9])), (3, Vectors.dense([10, 11, 12]))])

# Create an IndexedRowMatrix from an RDD[IndexedRow].
mat = DistributedMatrices.indexedRowMatrix(indexedRows)
mat = IndexedRowMatrix(indexedRows)

# Get its size.
m = mat.numRows() # 4
Expand Down Expand Up @@ -572,7 +572,7 @@ created from a `RDD` of MatrixEntry entries, where
`toRowMatrix`, or to an `IndexedRowMatrix` with sparse rows by calling `toIndexedRowMatrix`.

{% highlight python %}
from pyspark.mllib.linalg import DistributedMatrices, MatrixEntry, CoordinateMatrix
from pyspark.mllib.linalg import MatrixEntry, CoordinateMatrix

# Create an RDD of coordinate entries.
# - This can be done explicitly with the MatrixEntry class:
Expand All @@ -581,7 +581,7 @@ entries = sc.parallelize([MatrixEntry(0, 0, 1.2), MatrixEntry(1, 0, 2.1), Matrix
entries = sc.parallelize([(0, 0, 1.2), (1, 0, 2.1), (2, 1, 3.7)])

# Create an CoordinateMatrix from an RDD[MatrixEntry].
mat = DistributedMatrices.coordinateMatrix(entries)
mat = CoordinateMatrix(entries)

# Get its size.
m = mat.numRows() # 3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import java.io.OutputStream
import java.nio.{ByteBuffer, ByteOrder}
import java.util.{ArrayList => JArrayList, List => JList, Map => JMap}

import org.apache.spark.mllib.linalg.distributed.{DistributedMatrices, RowMatrix, IndexedRowMatrix, IndexedRow,
import org.apache.spark.mllib.linalg.distributed.{RowMatrix, IndexedRowMatrix, IndexedRow,
MatrixEntry, CoordinateMatrix}

import scala.collection.JavaConverters._
Expand Down Expand Up @@ -1109,22 +1109,22 @@ private[python] class PythonMLLibAPI extends Serializable {
}

/**
* Wrapper around DistributedMatrices.rowMatrix factory method.
* Wrapper around RowMatrix.
*/
def createRowMatrix(rows: JavaRDD[Vector], numRows: Long, numCols: Int): RowMatrix = {
DistributedMatrices.rowMatrix(rows.rdd, numRows, numCols)
new RowMatrix(rows.rdd, numRows, numCols)
}

/**
* Wrapper around DistributedMatrices.indexedRowMatrix factory method.
* Wrapper around IndexedRowMatrix.
*/
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 {
case Row(index: Long, vector: Vector) => IndexedRow(index, vector)
}
DistributedMatrices.indexedRowMatrix(indexedRows, numRows, numCols)
new IndexedRowMatrix(indexedRows, numRows, numCols)
}

/**
Expand All @@ -1137,15 +1137,15 @@ private[python] class PythonMLLibAPI extends Serializable {
}

/**
* Wrapper around DistributedMatrices.coordinateMatrix factory method.
* Wrapper around CoordinateMatrix.
*/
def createCoordinateMatrix(rows: DataFrame, numRows: Long, numCols: Long): CoordinateMatrix = {
// We use DataFrames for serialization of MatrixEntry entries from Python, so map each Row in
// the DataFrame back to a MatrixEntry.
val entries = rows.map {
case Row(i: Long, j: Long, value: Double) => MatrixEntry(i, j, value)
}
DistributedMatrices.coordinateMatrix(entries, numRows, numCols)
new CoordinateMatrix(entries, numRows, numCols)
}

/**
Expand Down

This file was deleted.

Loading