Wonder what is wrong with the MCMC model? train and test process looks fine
cmd: ../bin/libFM -task c -train ../data/spcz_train.txt -test ../data/spcz_test.txt -dim '1,1,8' -verbosity 1 -out ../data/spcz.predict -save_model ../model/spcz.mdl
#Iter= 96 Train=0.933577 Test=0.882 Test(ll)=0.14724
#Iter= 97 Train=0.933921 Test=0.882 Test(ll)=0.146699
#Iter= 98 Train=0.93274 Test=0.882 Test(ll)=0.146124
#Iter= 99 Train=0.932643 Test=0.883 Test(ll)=0.145564
model file looks like this:
#global bias W0
-6.38154
#unary interactions Wj
0.416005
-0.175864
-1.92583
-0.111393
0.00136478
3.04672
0.731291
2.621
-0.739681
-2.36962
-6.19163
-1.01834
0.161435
-5.00533
2.09333
3.73539
0.616305
0.203633
-8.45758
-3.0175
-2.10704
0.284601
...
When inference using below code written in Scala, I get variable pred equals to 1000 or more, which sigmoid(pred)=1.0
def predict(testData: Vector): Double = {
require(testData.size == numFeatures)
var pred = intercept
if (weightVector.isDefined) {
testData.foreachActive {
case (i, v) =>
pred += weightVector.get(i) * v
}
}
for (f <- 0 until numFactors) {
var sum = 0.0
var sumSqr = 0.0
testData.foreachActive {
case (i, v) =>
val d = factorMatrix(f, i) * v
sum += d
sumSqr += d * d
}
pred += (sum * sum - sumSqr) * 0.5
}
task match {
case 0 =>
Math.min(Math.max(pred, min), max)
case 1 =>
1.0 / (1.0 + Math.exp(-pred))
}
}
BTW, spcz.predict is good. Scores are distributed between [0, 1]
Please can you advise what is wrong with my procedure...
Thanks in advance!!!