org.apache.spark.mllib.util.MLUtils 패키지를 사용하여 scala에서 libsvm 파일을 생성했습니다.r : 라이브러리가있는 libsvm 파일 읽기 (e1071)
가m= read.matrix.csr(filename)
아래와 얻어진 matrix.csr의 구조이므로 :
49.0 109:2.0 272:1.0 485:1.0 586:1.0 741:1.0 767:1.0
49.0 109:2.0 224:1.0 317:1.0 334:1.0 450:1.0 473:1.0 592:1.0 625:1.0 647:1.0
681:1.0 794:1.0
17.0 26:1.0 109:1.0 143:1.0 198:2.0 413:1.0 476:1.0 582:1.0 586:1.0 611:1.0
629:1.0 737:1.0
12.0 255:1.0 394:1.0
etc etc
난 다음 e1071 패키지를 사용하여 R로 파일을 읽고 다음과 같이
파일 형식은
$ x:Formal class 'matrix.csr' [package "SparseM"] with 4 slots
.. [email protected] ra : num [1:31033] 2 1 1 1 1 1 2 1 1 1 ...
.. [email protected] ja : int [1:31033] 109 272 485 586 741 767 109 224 317 334 ...
.. [email protected] ia : int [1:2996] 1 7 18 29 31 41 49 65 79 83 ...
.. [email protected] dimension: int [1:2] 2995 796
$ y: Factor w/ 51 levels "0.0","1.0","10.0",..: 45 45 10 5 42 25 23 41 23 25 ...
as.matrix (m)로 밀도가 높은 행렬로 변환하면 하나의 열과 두 행 ea ch 해석 할 수없는 (나에 의하여) 물체와 함께. 나는 단순히 (중간 처리를하지 않고) 파일에 다시 matrix.csr을 저장하려고하면
, 나는 다음과 같은 오류 얻을 :
Error in abs(x) : non-numeric argument to mathematical function
나는 libsvm 포맷이 호환되지 않는 추측 오전하지만 난 ' 정말 모르겠다. 도움을 주시면 감사하겠습니다.