你好,當我試圖運行支持向量機在Apache-Spark與./run-example org.apache.spark.mllib.classification.SVM local <path-to-dir>/sample_svm_data.txt 2 2.0 2
在終端我得到以下錯誤信息。Apache-Spark支持向量機
Exception in thread "main" java.lang.NumberFormatException: For input string: "1 0 2.52078447201548 0 0 0 2.004684436494304 2.000347299268466 0 2.228387042742021 2.228387042742023 0 0 0 0 0 0"
at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:1241)
at java.lang.Double.parseDouble(Double.java:540)
at scala.collection.immutable.StringLike$class.toDouble(StringLike.scala:234)
at scala.collection.immutable.StringOps.toDouble(StringOps.scala:31)
at org.apache.spark.mllib.util.MLUtils$$anonfun$loadLabeledData$1.apply(MLUtils.scala:45)
at org.apache.spark.mllib.util.MLUtils$$anonfun$loadLabeledData$1.apply(MLUtils.scala:43)
at scala.collection.Iterator$$anon$19.next(Iterator.scala:401)
at scala.collection.Iterator$$anon$18.next(Iterator.scala:385)
at scala.collection.Iterator$class.foreach(Iterator.scala:772)
at scala.collection.Iterator$$anon$18.foreach(Iterator.scala:379)
at scala.collection.generic.Growable$class.$plus$plus$eq(Growable.scala:48)
at scala.collection.mutable.ArrayBuffer.$plus$plus$eq(ArrayBuffer.scala:102)
at scala.collection.TraversableOnce$class.toBuffer(TraversableOnce.scala:250)
at scala.collection.Iterator$$anon$18.toBuffer(Iterator.scala:379)
at scala.collection.TraversableOnce$class.toArray(TraversableOnce.scala:237)
at scala.collection.Iterator$$anon$18.toArray(Iterator.scala:379)
at org.apache.spark.rdd.RDD$$anonfun$12.apply(RDD.scala:768)
at org.apache.spark.rdd.RDD$$anonfun$12.apply(RDD.scala:768)
at org.apache.spark.SparkContext$$anonfun$runJob$4.apply(SparkContext.scala:758)
at org.apache.spark.SparkContext$$anonfun$runJob$4.apply(SparkContext.scala:758)
at org.apache.spark.scheduler.DAGScheduler.runLocallyWithinThread(DAGScheduler.scala:484)
at org.apache.spark.scheduler.DAGScheduler$$anon$2.run(DAGScheduler.scala:470)
將添加完整轉儲以用於進一步診斷。
13/12/13 12:26:54 INFO slf4j.Slf4jEventHandler: Slf4jEventHandler started
13/12/13 12:26:54 INFO spark.SparkEnv: Registering BlockManagerMaster
13/12/13 12:26:54 INFO storage.MemoryStore: MemoryStore started with capacity 9.2 GB.
13/12/13 12:26:54 INFO storage.DiskStore: Created local directory at /tmp/spark-local-20131213122654-abb2
13/12/13 12:26:54 INFO network.ConnectionManager: Bound socket to port 36563 with id = ConnectionManagerId(<master>,36563)
13/12/13 12:26:54 INFO storage.BlockManagerMaster: Trying to register BlockManager
13/12/13 12:26:54 INFO storage.BlockManagerMasterActor$BlockManagerInfo: Registering block manager <master>:36563 with 9.2 GB RAM
13/12/13 12:26:54 INFO storage.BlockManagerMaster: Registered BlockManager
13/12/13 12:26:54 INFO server.Server: jetty-7.x.y-SNAPSHOT
13/12/13 12:26:54 INFO server.AbstractConnector: Started [email protected]:56637
13/12/13 12:26:54 INFO broadcast.HttpBroadcast: Broadcast server started at http://10.232.5.169:56637
13/12/13 12:26:54 INFO spark.SparkEnv: Registering MapOutputTracker
13/12/13 12:26:54 INFO spark.HttpFileServer: HTTP File server directory is /tmp/spark-986ccc2b-5a40-48ae-8801-566b0f32895b
13/12/13 12:26:54 INFO server.Server: jetty-7.x.y-SNAPSHOT
13/12/13 12:26:54 INFO server.AbstractConnector: Started [email protected]:59613
13/12/13 12:26:54 INFO server.Server: jetty-7.x.y-SNAPSHOT
13/12/13 12:26:54 INFO handler.ContextHandler: started o.e.j.s.h.ContextHandler{/storage/rdd,null}
13/12/13 12:26:54 INFO handler.ContextHandler: started o.e.j.s.h.ContextHandler{/storage,null}
13/12/13 12:26:54 INFO handler.ContextHandler: started o.e.j.s.h.ContextHandler{/stages/stage,null}
13/12/13 12:26:54 INFO handler.ContextHandler: started o.e.j.s.h.ContextHandler{/stages/pool,null}
13/12/13 12:26:54 INFO handler.ContextHandler: started o.e.j.s.h.ContextHandler{/stages,null}
13/12/13 12:26:54 INFO handler.ContextHandler: started o.e.j.s.h.ContextHandler{/environment,null}
13/12/13 12:26:54 INFO handler.ContextHandler: started o.e.j.s.h.ContextHandler{/executors,null}
13/12/13 12:26:54 INFO handler.ContextHandler: started o.e.j.s.h.ContextHandler{/metrics/json,null}
13/12/13 12:26:54 INFO handler.ContextHandler: started o.e.j.s.h.ContextHandler{/static,null}
13/12/13 12:26:54 INFO handler.ContextHandler: started o.e.j.s.h.ContextHandler{/,null}
13/12/13 12:26:54 INFO server.AbstractConnector: Started [email protected]:4040
13/12/13 12:26:54 INFO ui.SparkUI: Started Spark Web UI at http://<master>:4040
13/12/13 12:26:54 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
13/12/13 12:26:55 INFO storage.MemoryStore: ensureFreeSpace(121635) called with curMem=0, maxMem=9907879280
13/12/13 12:26:55 INFO storage.MemoryStore: Block broadcast_0 stored as values to memory (estimated size 118.8 KB, free 9.2 GB)
13/12/13 12:26:55 INFO mapred.FileInputFormat: Total input paths to process : 1
13/12/13 12:26:55 INFO spark.SparkContext: Starting job: first at GeneralizedLinearAlgorithm.scala:121
13/12/13 12:26:55 INFO scheduler.DAGScheduler: Got job 0 (first at GeneralizedLinearAlgorithm.scala:121) with 1 output partitions (allowLocal=true)
13/12/13 12:26:55 INFO scheduler.DAGScheduler: Final stage: Stage 0 (first at GeneralizedLinearAlgorithm.scala:121)
13/12/13 12:26:55 INFO scheduler.DAGScheduler: Parents of final stage: List()
13/12/13 12:26:55 INFO scheduler.DAGScheduler: Missing parents: List()
13/12/13 12:26:55 INFO scheduler.DAGScheduler: Computing the requested partition locally
13/12/13 12:26:55 INFO rdd.HadoopRDD: Input split: file:/data/tanmay/tmp/sample_svm_data.txt:0+39474
13/12/13 12:26:55 INFO scheduler.DAGScheduler: Failed to run first at GeneralizedLinearAlgorithm.scala:121
Exception in thread "main" java.lang.NumberFormatException: For input string: "1 0 2.52078447201548 0 0 0 2.004684436494304 2.000347299268466 0 2.228387042742021 2.228387042742023 0 0 0 0 0 0"
at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:1241)
at java.lang.Double.parseDouble(Double.java:540)
at scala.collection.immutable.StringLike$class.toDouble(StringLike.scala:234)
at scala.collection.immutable.StringOps.toDouble(StringOps.scala:31)
at org.apache.spark.mllib.util.MLUtils$$anonfun$loadLabeledData$1.apply(MLUtils.scala:45)
at org.apache.spark.mllib.util.MLUtils$$anonfun$loadLabeledData$1.apply(MLUtils.scala:43)
at scala.collection.Iterator$$anon$19.next(Iterator.scala:401)
at scala.collection.Iterator$$anon$18.next(Iterator.scala:385)
at scala.collection.Iterator$class.foreach(Iterator.scala:772)
at scala.collection.Iterator$$anon$18.foreach(Iterator.scala:379)
at scala.collection.generic.Growable$class.$plus$plus$eq(Growable.scala:48)
at scala.collection.mutable.ArrayBuffer.$plus$plus$eq(ArrayBuffer.scala:102)
at scala.collection.TraversableOnce$class.toBuffer(TraversableOnce.scala:250)
at scala.collection.Iterator$$anon$18.toBuffer(Iterator.scala:379)
at scala.collection.TraversableOnce$class.toArray(TraversableOnce.scala:237)
at scala.collection.Iterator$$anon$18.toArray(Iterator.scala:379)
at org.apache.spark.rdd.RDD$$anonfun$12.apply(RDD.scala:768)
at org.apache.spark.rdd.RDD$$anonfun$12.apply(RDD.scala:768)
at org.apache.spark.SparkContext$$anonfun$runJob$4.apply(SparkContext.scala:758)
at org.apache.spark.SparkContext$$anonfun$runJob$4.apply(SparkContext.scala:758)
at org.apache.spark.scheduler.DAGScheduler.runLocallyWithinThread(DAGScheduler.scala:484)
at org.apache.spark.scheduler.DAGScheduler$$anon$2.run(DAGScheduler.scala:470)
任何人都可以請幫我在這個數據(/輸入參數)搞清楚這個問題,在考慮到Apache的星火已與包裝機器學習庫附帶的「sample_svm_data.txt」一起[這意味着數據不應該成爲問題]?
與您的功能分離有關的東西?你使用製表符或空格嗎?或者也許使用「。」代替 」,」 ?另外,你是否檢查過你所有的樣本長度相等? – Anoyz
@Anoyz:嘿,謝謝,實際上這些功能是用空格分隔的,我只是用逗號代替它們,它工作。 :) – Tanny
@Tanny請分享您應用SVM實施的代碼),因爲我擁有相同的以逗號分隔的功能數據。這將是非常有幫助:) – wadhwasahil