CoordinateMatrix

pyspark.mllib.linalg.distributed。 CoordinateMatrix ( 條目:pyspark.rdd.RDD(聯盟(元組(int,int,浮動],pyspark.mllib.linalg.distributed.MatrixEntry]],numRows:int=0,numCols:int=0 )

代表一個矩陣坐標格式。

參數
條目 pyspark.RDD

的抽樣MatrixEntry輸入或元組(int, int,浮動)。

numRows int,可選

矩陣的行數。非容積值是未知的,此時的行數將由馬克斯行索引+ 1。

numCols int,可選

矩陣的列數。非容積值是未知的,此時列的數量將取決於最大行索引+ 1。

方法

numCols()

獲取或計算的關口。

numRows()

獲取或計算的行數。

toBlockMatrix([rowsPerBlock colsPerBlock])

這個矩陣轉換為一個BlockMatrix。

toIndexedRowMatrix()

這個矩陣轉換為一個IndexedRowMatrix。

toRowMatrix()

這個矩陣轉換為一個RowMatrix。

轉置()

這個CoordinateMatrix轉置。

屬性

條目

條目的CoordinateMatrix存儲為一個MatrixEntries抽樣。

方法的文檔

numCols ( )→int

獲取或計算的關口。

例子

> > >條目=sc並行化([MatrixEntry(0,0,1.2),MatrixEntry(1,0,2),MatrixEntry(2,1,3.7)))
> > >=CoordinateMatrix(條目)> > >打印(numCols())2
> > >=CoordinateMatrix(條目,7,6)> > >打印(numCols())6
numRows ( )→int

獲取或計算的行數。

例子

> > >條目=sc並行化([MatrixEntry(0,0,1.2),MatrixEntry(1,0,2),MatrixEntry(2,1,3.7)))
> > >=CoordinateMatrix(條目)> > >打印(numRows())3
> > >=CoordinateMatrix(條目,7,6)> > >打印(numRows())7
toBlockMatrix ( rowsPerBlock:int=1024年,colsPerBlock:int=1024年 )pyspark.mllib.linalg.distributed.BlockMatrix

這個矩陣轉換為一個BlockMatrix。

參數
rowsPerBlock int,可選

組成每一塊的行數。塊形成最後一行不需要給定的行數。

colsPerBlock int,可選

列數,每一塊。塊形成最後一列不需要給定的列數。

例子

> > >條目=sc並行化([MatrixEntry(0,0,1.2),MatrixEntry(6,4,2.1)))> > >=CoordinateMatrix(條目)toBlockMatrix()
> > >#這CoordinateMatrix 7有效行,由於> > >6 #最高的行索引,以及隨之而來的> > ># BlockMatrix也會有7行。> > >打印(numRows())7
> > >#這CoordinateMatrix將有5列,由於> > >4 #列指數最高,和隨之而來的> > ># BlockMatrix也會有5列。> > >打印(numCols())5
toIndexedRowMatrix ( )pyspark.mllib.linalg.distributed.IndexedRowMatrix

這個矩陣轉換為一個IndexedRowMatrix。

例子

> > >條目=sc並行化([MatrixEntry(0,0,1.2),MatrixEntry(6,4,2.1)))> > >=CoordinateMatrix(條目)toIndexedRowMatrix()
> > >#這CoordinateMatrix 7有效行,由於> > >6 #最高的行索引,以及隨之而來的> > ># IndexedRowMatrix也會有7行。> > >打印(numRows())7
> > >#這CoordinateMatrix將有5列,由於> > >4 #列指數最高,和隨之而來的> > ># IndexedRowMatrix也會有5列。> > >打印(numCols())5
toRowMatrix ( )pyspark.mllib.linalg.distributed.RowMatrix

這個矩陣轉換為一個RowMatrix。

例子

> > >條目=sc並行化([MatrixEntry(0,0,1.2),MatrixEntry(6,4,2.1)))> > >=CoordinateMatrix(條目)toRowMatrix()
> > >#這CoordinateMatrix 7有效行,由於> > >6 #最高的行索引,但隨後RowMatrix> > >#將隻有2行,因為隻有2項> > >#獨特的行。> > >打印(numRows())2
> > >#這CoordinateMatrix將有5列,由於> > >4 #列指數最高,和隨後的RowMatrix> > >#也會有5列。> > >打印(numCols())5
轉置 ( )pyspark.mllib.linalg.distributed.CoordinateMatrix

這個CoordinateMatrix轉置。

例子

> > >條目=sc並行化([MatrixEntry(0,0,1.2),MatrixEntry(1,0,2),MatrixEntry(2,1,3.7)))> > >=CoordinateMatrix(條目)> > >mat_transposed=轉置()
> > >打印(mat_transposednumRows())2
> > >打印(mat_transposednumCols())3

屬性的文檔

條目

條目的CoordinateMatrix存儲為一個MatrixEntries抽樣。

例子

> > >=CoordinateMatrix(sc並行化([MatrixEntry(0,0,1.2),MatrixEntry(6,4,2.1))))> > >條目=條目> > >條目第一個()MatrixEntry (0, 0, 1.2)