Github user catap commented on the pull request:
https://github.com/apache/spark/pull/6795#issuecomment-118227696
Sure.
I run following script on this branch at spark-shell with `SPARK_MEM=4g` on
my laptop
```scala
import java.util.Random
import org.apache.spark.mllib.feature.{HashingTF, SignificantSelector}
import org.apache.spark.mllib.regression.LabeledPoint
import org.apache.spark.mllib.tree.DecisionTree
import org.apache.spark.rdd.RDD
import scala.concurrent.duration._
import scala.language.implicitConversions
val rnd = new Random
val length = 20
implicit def bool2Double(b:Boolean): Double = if (b) 1d else 0d
val localDocs = (1 to length).map(_ =>
(rnd.nextBoolean().toDouble, (1 to 1000).map(_ =>
rnd.nextDouble().toString)))
val docs = sc.parallelize(localDocs, 2)
val hashingTF = new HashingTF()
val tf: RDD[LabeledPoint] = docs.map { case (label, words) =>
LabeledPoint(label, hashingTF.transform(words)) }
val transformer = new SignificantSelector().fit(tf.map(_.features))
val transformed_tf = tf.map(p => p.copy(features =
transformer.transform(p.features)))
val start = System.currentTimeMillis()
val model = DecisionTree.trainClassifier(tf, 2, Map[Int, Int](), "gini",
30, length)
val end = System.currentTimeMillis()
val transformed_start = System.currentTimeMillis()
val transformed_model = DecisionTree.trainClassifier(transformed_tf, 2,
Map[Int, Int](), "gini", 30, length)
val transformed_end = System.currentTimeMillis()
val elapsed = DurationLong(end - start).millis
val transformed_elapsed = DurationLong(transformed_end -
transformed_start).millis
println("Ok, done.")
println(f"Elapsed time ${elapsed.toMinutes} min, ${elapsed.toSeconds % 60}
sec, ${elapsed.toMillis % 1000} millis (total ${elapsed.toMillis} millis)")
println(f"Elapsed transformed time ${transformed_elapsed.toMinutes} min,
${transformed_elapsed.toSeconds % 60} sec, ${transformed_elapsed.toMillis %
1000} millis (total ${transformed_elapsed.toMillis} millis)")
```
and had result:
```
Elapsed time 2 min, 14 sec, 268 millis (total 134268 millis)
Elapsed transformed time 0 min, 2 sec, 803 millis (total 2803 millis)
```
---
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.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]