VinceShieh / spark-ffm

FFM (Field-Awared Factorization Machine) on Spark
Apache License 2.0
105 stars 44 forks source link

Feature indices do not conincide #9

Closed xiaoxuqi-ms closed 6 years ago

xiaoxuqi-ms commented 6 years ago

As per the weights array, feature index should coincide with each. Let's say a feature j1 = data(i)._2 - 1 gets its weight for field f2 as following: j1 align1 + f2 align0 For FFMModel in FieldAwaredFactorizationMachine.scala, line 122 and line 131, index for datai is data(i)_2 -1, however, for dataii is data(ii). Should these conform with each other? val j1 = data(i)._2 - 1 [line 122] val f1 = data(i)._1 val v1 = data(i)._3 ...... while (ii < valueSize) { val j2 = data(ii)._2 [line 131] val f2 = data(ii)._1 ......

Likelihoood commented 6 years ago

I have found the same question. ffm_question

VinceShieh commented 6 years ago

guys, sorry for late reply. it seems vague to me now, but I think you are right. The reason behind is the feature index is [0, n-1], and I made a guard on j2 that's why the problem didnt expose. Can you guys submit a PR to fix this issue? If not, I will fix it sometime later. :) Thanks

xiaoxuqi-ms commented 6 years ago

And I think this should also be fixed in intel mllib.

VinceShieh commented 6 years ago

thanks. please make sure that you've built and tested the PR. :)

xiaoxuqi-ms commented 6 years ago

Yes, PR is tested

Likelihoood commented 6 years ago

Thank you for reply and fixing this issue.

Likelihoood commented 6 years ago

One more question: in a9a_ffm , all index start from 1, need it minus one when load the data in TestFFM.scala?

xiaoxuqi-ms commented 6 years ago

I donot think it's necessary though.