Github user MLnick commented on a diff in the pull request:
https://github.com/apache/spark/pull/12660#discussion_r61144699
--- Diff:
mllib/src/test/scala/org/apache/spark/ml/recommendation/ALSSuite.scala ---
@@ -512,6 +514,55 @@ class ALSSuite
assert(getFactors(model.userFactors) ===
getFactors(model2.userFactors))
assert(getFactors(model.itemFactors) ===
getFactors(model2.itemFactors))
}
+
+ test("StorageLevel param") {
+ // test invalid param values
+ intercept[IllegalArgumentException] {
+ new ALS().setIntermediateRDDStorageLevel("foo")
+ }
+ intercept[IllegalArgumentException] {
+ new ALS().setIntermediateRDDStorageLevel("NONE")
+ }
+ intercept[IllegalArgumentException] {
+ new ALS().setFinalRDDStorageLevel("foo")
+ }
+ // test StorageLevels
+ val sqlContext = this.sqlContext
+ import sqlContext.implicits._
+ val (ratings, _) = genExplicitTestData(numUsers = 2, numItems = 2,
rank = 1)
+ val data = ratings.toDF
+ val als = new ALS().setMaxIter(1)
+ als.fit(data)
+ val factorRDD = sc.getPersistentRDDs.collect {
--- End diff --
Pretty much yeah. There is no public API on `Dataset` for getting the
storage level it's cached with (yet). This was the easiest way I found to get
the RDD storage levels (there are ways directly on the DF but require
`private[sql]` stuff).
The caching does work a little differently, but AFAIK there is little
difference in practice between caching the DF and caching the RDD the DF is
created from in this case as the DF is just a projection, except perhaps for
storage. The factor DFs here are not in fact cached (but the underlying RDDs
are).
(it may be worth as a follow up looking at, for the ML API, setting the
storage level for the final factors to `NONE` and caching the DFs, to see if
there is any albeit small efficiency gain).
---
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]