0

您好,当我尝试在终端中运行Apache-Spark中的支持向量机时,我收到以下错误消息。./run-example org.apache.spark.mllib.classification.SVM local <path-to-dir>/sample_svm_data.txt 2 2.0 2

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 SocketConnector@0.0.0.0: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 SocketConnector@0.0.0.0: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 SelectChannelConnector@0.0.0.0: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-Spark 已将“sample_svm_data.txt”与机器学习库的软件包一起提供 [,这意味着数据应该不是问题]?

4

1 回答 1

0

问题是数据有空格作为分隔符,默认情况下 mahout(SVM) 无法解析相同的数据。我只是用逗号替换了空格,中提琴它起作用了!

于 2014-04-22T08:34:36.180 回答