pyspark tf-idf 함수를 적용하고 다음 결과를 얻었습니다.TF-IDF에서 SVD를 적용하는 방법 pyspark의 데이터 프레임
| features |
|----------|
| (35,[7,9,11,12,19,26,33],[1.2039728043259361,1.2039728043259361,1.2039728043259361,1.6094379124341003,1.6094379124341003,1.6094379124341003,1.6094379124341003]) |
| (35,[0,2,4,5,6,11,22],[0.9162907318741551,0.9162907318741551,1.2039728043259361,1.2039728043259361,1.2039728043259361,1.2039728043259361,1.6094379124341003]) |
그래서 SparseVectors를 행으로 포함하는 1 열 (피처)을 갖는 데이터 프레임입니다.
mat = RowMatrix(tfidfData.rdd.map(lambda x: x.features))
TypeError: Cannot convert type <class 'pyspark.ml.linalg.SparseVector'> into Vector
:
지금 나는 내가이 있지만 작동하지 않았다 다음 시도 https://spark.apache.org/docs/latest/api/python/pyspark.mllib.html?highlight=svd#pyspark.mllib.linalg.distributed.IndexedRowMatrix.computeSVD
여기에 설명되어있는 SVD 기능을 실행할 수 있도록이 dataframe에서 IndexRowMatrix을 구축하고자 RowMatrix는 튜플을 제공 할 필요가 없지만 RowMatrix를 빌드 할 수 없기 때문에 사용했습니다. IndexedRowMatrix는 나를 위해 더 어려울 것입니다.
그래서 어떻게 ppppark에서 tf-idf 데이터 프레임을 출력 할 때 IndexedRowMatrix를 실행합니까?