2016-10-28 229 views
0

使用MLlib功能ALS我已經從文件中讀取這樣的:錯誤在星火

val ratingText = sc.textFile("/home/cloudera/rec_data/processed_data/ratings/000000_0") 

使用下面的函數來分析這樣的數據:

def parseRating(str: String): Rating= { 
     val fields = str.split(",") 
     Rating(fields(0).toInt, fields(1).trim.toInt, fields(2).trim.toDouble) 
} 

而且創造了一個RDD,這是然後分裂成不同的RDDS

val ratingsRDD = ratingText.map(x=>parseRating(x)).cache() 

val splits = ratingsRDD.randomSplit(Array(0.8, 0.2), 0L) 

val trainingRatingsRDD = splits(0).cache() 

使用的訓練RDD創建模型如下:

val model = (new ALS().setRank(20).setIterations(10) .run(trainingRatingsRDD)) 

我得到以下錯誤在最後的命令

16/10/28 01:03:44 WARN BLAS: Failed to load implementation from: com.github.fommil.netlib.NativeSystemBLAS 
16/10/28 01:03:44 WARN BLAS: Failed to load implementation from: com.github.fommil.netlib.NativeRefBLAS 
16/10/28 01:03:46 WARN LAPACK: Failed to load implementation from: com.github.fommil.netlib.NativeSystemLAPACK 
16/10/28 01:03:46 WARN LAPACK: Failed to load implementation from: com.github.fommil.netlib.NativeRefLAPACK 

編輯:T. Gaweda的建議,幫助在消除錯誤,但我仍然得到以下警告:

16/10/28 01:53:59 WARN Executor: 1 block locks were not released by TID = 60: 
[rdd_420_0] 
16/10/28 01:54:00 WARN Executor: 1 block locks were not released by TID = 61: 
[rdd_421_0] 

我認爲這導致了一個空的模型,因爲下一步導致以下錯誤:

VAL topRecsForUser = model.recommendProducts(4276736,3)

錯誤是:

java.util.NoSuchElementException: next on empty iterator at scala.collection.Iterator$$anon$2.next(Iterator.scala:39) 

請幫幫忙!

回答

1

這只是一個警告。 Spark使用BLAS來執行計算。 BLAS具有本機實現和JVM實現,本機實現更加優化/更快。但是,您必須單獨安裝本機庫。

如果沒有此配置,將出現警告消息,Spark將使用BLAS的JVM實現。結果應該是一樣的,也許計算得相當慢。

Here你得說明什麼是BLAS以及如何配置它,例如分上的操作系統是應該只有:yum install openblas lapack

+0

感謝@T。 Gaweda,在刪除警告方面效果很好,但以下錯誤持續存在。你可以請看一看::val model =(new ALS()。setRank(20).setIterations(10).run(trainingRatingsRDD)) 16/10/28 01:53:59 WARN Executor:1 block locks were不是由TID = 60發佈: [rdd_420_0] 16/10/28 01:54:00警告執行程序:1個塊鎖不是由TID = 61發佈的: [rdd_421_0] model:org.apache.spark.mllib .recommendation.MatrixFactorizationModel = [email protected]a853a7d – Kuwali

+0

另外,在此之後,當我使用val topRecsForUser = model.recommendProducts(4276736,3)時,我得到一個錯誤,說java.util.NoSuchElementException:next在空迭代器 在scala.collection.Iterator $$ anon $ 2.next(Iterator.scala:39) 這是否意味着該模型是空的?請幫忙! – Kuwali

+0

這是你的代碼有問題 - 你試圖用用戶標識預測模型中不存在 - http://stackoverflow.com/questions/32488328/mllib-matrixfactorizationmodel-recommendproductsuser-num-failing-on-some-user –