Github user mengxr commented on a diff in the pull request:
https://github.com/apache/spark/pull/643#discussion_r12333196
--- Diff:
examples/src/main/scala/org/apache/spark/examples/mllib/BinaryClassification.scala
---
@@ -90,55 +135,104 @@ object BinaryClassification {
}
}
+ def parseModel(strModel: Seq[(String, Double)]): (Vector, Double) = {
+ val numFeatures = strModel(0)._2.toInt
+ val intercept = strModel(1)._2
+ val weights = Array.fill(numFeatures) { 0.0d }
+ strModel.slice(2, strModel.length).foreach { kv =>
+ weights(kv._1.toInt) = kv._2
+ }
+ (Vectors.dense(weights), intercept)
+ }
+
def run(params: Params) {
- val conf = new SparkConf().setAppName(s"BinaryClassification with
$params")
+ val conf = new SparkConf().setMaster(params.master)
+ .setAppName(s"BinaryClassification with $params")
val sc = new SparkContext(conf)
Logger.getRootLogger.setLevel(Level.WARN)
val examples = MLUtils.loadLibSVMData(sc, params.input).cache()
- val splits = examples.randomSplit(Array(0.8, 0.2))
- val training = splits(0).cache()
- val test = splits(1).cache()
+ val (training, test) = params.mode match {
+ case TRAIN => (examples, sc.emptyRDD[LabeledPoint])
+ case TEST => (sc.emptyRDD[LabeledPoint], examples)
+ case SPLIT =>
+ val splits = examples.randomSplit(Array(0.8, 0.2))
+ val training = splits(0).cache()
+ val test = splits(1).cache()
+ examples.unpersist(blocking = false)
--- End diff --
You need to materialize `training` and `test` before removing `examples`
from cache.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---