Uh oh!
There was an error while loading. Please reload this page.
SPARK-1668: Add implicit preference as an option to examples/MovieLensALS - #597
SPARK-1668: Add implicit preference as an option to examples/MovieLensALS#597techaddict wants to merge 7 commits into
Conversation
…sALS Add --implicitPrefs as an command-line option to the example app MovieLensALS under examples/
AmplabJenkins
commented
Apr 30, 2014
Merged build triggered. |
AmplabJenkins
commented
Apr 30, 2014
Merged build started. |
AmplabJenkins
commented
Apr 30, 2014
Merged build finished. All automated tests passed. |
AmplabJenkins
commented
Apr 30, 2014
All automated tests passed. |
mengxr
commented
Apr 30, 2014
@techaddict Thanks for working on this JIRA. You also need to change the evaluation code. Implicit ALS predicts 0/1 instead of the original rating. So you need some mapping before computing RMSE. |
techaddict
commented
May 2, 2014
Mapping rating in case of ImplicitPref to |
MLnick
commented
May 4, 2014
It is true that implicit prefs predict 0/1 (ie a "preference" matrix rather than a "rating" matrix), but the ratings are taken as confidence levels indicating preference (or in the case of negative ratings, lack of preference). So already there is an implicit mapping of 1 if r > 0, 0 if r == 0, with the actual rating being a confidence value in the case of r > 0. So keeping ratings input as is, is a reasonable approach. Even better would be to map low ratings to zero or perhaps even negative scores, as a low rating would indicate a lack of preference certainly. |
srowen
commented
May 4, 2014
On this note, recall there was a change a while back to handle the case of negative confidence levels. 0 still means "don't know" and positive values mean "confident that the prediction should be 1". Negative values means "confident that the prediction should be 0". I have in this case used some kind of weighted RMSE. The weight is the absolute value of the confidence. The error is the difference between prediction and either 1 or 0, depending on whether r is positive or negative. |
mengxr
commented
May 6, 2014
MovieLens ratings are on a scale of 1-5: So we should not recommend a movie if the predicted rating is less than For evaluation, the mapping should be |
AmplabJenkins
commented
May 6, 2014
Merged build triggered. |
AmplabJenkins
commented
May 6, 2014
Merged build started. |
AmplabJenkins
commented
May 6, 2014
Merged build finished. All automated tests passed. |
AmplabJenkins
commented
May 6, 2014
All automated tests passed. |
srowen
commented
May 6, 2014
Can I make a tiny suggestion to map from ratings to weights with something like "rating - 2.5" instead of "rating - 3"? So that 3 becomes a small positive value like 0.5? There is an argument that even neutral ratings are weak positive interactions; to have even consumed the item to be able to rate it means you had an interest. But more than that, the semantics of 0 in this expanded world of non-positive weights are "the same as never having interacted at all" -- which doesn't quite fit. I don't know if the intermediate sparse representations do this internally, at the moment, but it's possible that 0 values are ignored when constructing the sparse representation, because the 0s are implicit. This would be a problem, at least, a theoretical one. |
mengxr
commented
May 6, 2014
+1 on @srowen 's suggestion. |
techaddict
commented
May 6, 2014
AmplabJenkins
commented
May 6, 2014
Merged build triggered. |
AmplabJenkins
commented
May 6, 2014
Merged build started. |
mengxr
commented
May 6, 2014
@techaddict For training, we should keep the |
AmplabJenkins
commented
May 6, 2014
Merged build finished. All automated tests passed. |
AmplabJenkins
commented
May 6, 2014
All automated tests passed. |
techaddict
commented
May 6, 2014
@mengxr i'm bit confused. defcomputeRmse(model: MatrixFactorizationModel, data: RDD[Rating], n: Long) = {
valpredictions:RDD[Rating] = model.predict(data.map(x => (x.user, x.product)))
valpredictionsAndRatings= predictions.map(x => ((x.user, x.product), (x.rating +2.5) /5.0))
.join(data.map(x => ((x.user, x.product), x.rating)))
.values
math.sqrt(predictionsAndRatings.map(x => (x._1 - x._2) * (x._1 - x._2)).mean())
} |
mengxr
commented
May 6, 2014
|
AmplabJenkins
commented
May 6, 2014
Merged build triggered. |
AmplabJenkins
commented
May 6, 2014
Merged build started. |
AmplabJenkins
commented
May 7, 2014
Merged build triggered. |
AmplabJenkins
commented
May 7, 2014
Merged build started. |
AmplabJenkins
commented
May 7, 2014
Merged build finished. All automated tests passed. |
AmplabJenkins
commented
May 7, 2014
All automated tests passed. |
There was a problem hiding this comment.
Can we change it to the following:
if (implicitPrefs) math.max(math.min(r, 1.0), 0.0) else r
AmplabJenkins
commented
May 8, 2014
Merged build triggered. |
AmplabJenkins
commented
May 8, 2014
Merged build started. |
AmplabJenkins
commented
May 8, 2014
Merged build finished. All automated tests passed. |
AmplabJenkins
commented
May 8, 2014
All automated tests passed. |
techaddict
commented
May 8, 2014
@mengxr done |
mengxr
commented
May 8, 2014
LGTM. Thanks! |
rxin
commented
May 8, 2014
Merged. Thanks! |
…sALS Add --implicitPrefs as an command-line option to the example app MovieLensALS under examples/ Author: Sandeep <sandeep@techaddict.me> Closes#597 from techaddict/SPARK-1668 and squashes the following commits: 8b371dc [Sandeep] Second Pass on reviews by mengxr eca9d37 [Sandeep] based on mengxr's suggestions 937e54c [Sandeep] Changes 5149d40 [Sandeep] Changes based on review 1dd7657 [Sandeep] use mean() 42444d7 [Sandeep] Based on Suggestions by mengxr e3082fa [Sandeep] SPARK-1668: Add implicit preference as an option to examples/MovieLensALS Add --implicitPrefs as an command-line option to the example app MovieLensALS under examples/ (cherry picked from commit 108c4c1) Signed-off-by: Reynold Xin <rxin@apache.org>
invkrh
commented
Jun 6, 2014
Just a question on the result. Here, 0.57 is the error we will make when we predict 0/1, but is that too much ? In the paper on which the implicit ALS is based on, we see that it used expected percentile rank. Thank you. =) |
srowen
commented
Jun 6, 2014
Simple RMSE is not a great metric for this model, because it treats all errors equally when the model itself does not at all. 1s are much more important than 0s. The predictions are not rating-like. See my comment above. I usually try to look at metrics that measure how good the top of the ranking is, since this is far more like what the user experiences. MAP or something like area under the curve are about as good as you can hope for, but still somewhat flawed. It's hard to eval recommenders since you have such incomplete information on what the "right" or "relevant" items are. |
invkrh
commented
Jun 10, 2014
I have recently tested expected percentile rank(EPR) evaluation method proposed in the paper on the Movielens data set and a real world data set. However, I got a expected rank about 50% in both set, according to the paper, that means implicit ALS actually does not predict anything. I am not sure if any evaluation has been done like this. How can we make sure that implicit ALS is implemented correctly in MLlib without checking code? |
srowen
commented
Jun 10, 2014
The results depend a whole lot on the choice of parameters. Did you try some degree of search for the best lambda / # features? it's quite possible to make a model that can't predict anything. I have generally found ALS works fine on the Movielens data set. |
invkrh
commented
Jun 11, 2014
I have tried different lamdba and # features. But nothing has changed. To be clear, initially, the Movielens dataset it is divided into training set(80%) and test set(20%). The ratings are re-interpreted as |
srowen
commented
Jun 11, 2014
You mentioned trying lots of values but what did you try? What about other test metrics -- to rule out some problem in the evaluation? Maybe you can share some of how you ran the test in a gist. |
invkrh
commented
Jun 12, 2014
Here is the values I have tried: seed is set to 42 in & out means in sample (training set) out-of-sample (test set) #factor = 12, lamda = 1, alpha = 1#factor = 50, alpha = 1, iter = 30I have not tried other metrics, as said before, RMSE is not that good. I listed some code snippets here. There are 2 evaluation methods and the main |
invkrh
commented
Jun 12, 2014
Ok, I have found the error in my metric. This line is for creating a item-factor matrix, the problem is that item factors are not ordered by item id when collecting them, which leads to a wrong matrix, that's y the result is non sense. Adding a sortBy(_._1), like give a EPR like 9%(in sample), 10%(out of sample) Implicit ALS works. Thanks. |
…sALS Add --implicitPrefs as an command-line option to the example app MovieLensALS under examples/ Author: Sandeep <sandeep@techaddict.me> Closesapache#597 from techaddict/SPARK-1668 and squashes the following commits: 8b371dc [Sandeep] Second Pass on reviews by mengxr eca9d37 [Sandeep] based on mengxr's suggestions 937e54c [Sandeep] Changes 5149d40 [Sandeep] Changes based on review 1dd7657 [Sandeep] use mean() 42444d7 [Sandeep] Based on Suggestions by mengxr e3082fa [Sandeep] SPARK-1668: Add implicit preference as an option to examples/MovieLensALS Add --implicitPrefs as an command-line option to the example app MovieLensALS under examples/
…pache#597) * Avoids adding duplicated secret volumes when init-container is used Cherry-picked from apache#20148. * Added the missing commit from upstream
we use project_domain_name instead of project_domain_id for citynetwork provider
Add --implicitPrefs as an command-line option to the example app MovieLensALS under examples/