-
Notifications
You must be signed in to change notification settings - Fork 206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Understanding MCMC and n_more_iter #37
Comments
y_pred[y_pred > 5] = 5
y_pred[y_pred < 1] = 1 causes the model to average the clipped predictions. Better use copies in your comparison. y_pred = fm.fit_predict(X_train, y_train, X_test, n_more_iter=10)
y_pred_tmp = np.copy(y_pred)
y_pred_tmp[y_pred_tmp > 5] = 5
y_pred_tmp[y_pred_tmp < 1] = 1
print(i, np.sqrt(mean_squared_error(y_pred_tmp, y_test))) |
Are you saying that the clipping of the predictions actually impacts the underlying model? I tried using the copy as you suggest and I seem to get the same results. Even if this is a potential problem how does this relate to the issue at hand? I don't see how this explains the discrepancy between running the model 100 times with a step of 1 vs running it 10 times with a step of 10. |
Yes, for mcmc the n+1 prediction depends on the n'th prediction. So if you change the n'th prediction by clipping...
Well, the mean over 100 clipped predictions doesn't have to be the same as the mean over 10 clipped predictions, even if the underlying number of iterations is the same. You could simply run the experiment without clipping as a test, then you know if clipping causes differences or not. I can look into this If you narrow the issue down and provide a Short, Self Contained, Correct, Example. |
I am not really seeing much (if any) difference by clipping the copy vs the original predictions. I had assumed the predictions provided by fit_predict were already a copy and not a mutable reference to the internal predictions used by the model. Here is a example I've created. Please let me know if it meets your needs. Thanks! |
Thank's for the example.
|
Could the same reasons that we are unable to separate |
I can reproduce your results. Great, a really small example can even go in the test suite later. Good to know that als works, that narrows things down. Can you compare against restart too?
That's likely. I'll take a closer look later. |
Can you explain in relative layman's terms the differences with mcmc that prevent good results when splitting fit and predict? It seems that if we have enough state to warm-start the algorithm we should have enough state to predict independently of fitting. I'm not quite sure what you mean by "restart". I modified my script to explore the one other variation I see and the results were unremarkable. The slightly modified script and its output illustrating this is at: |
MCMC returns the mean over the prediction at every iteration. The model parameter themselves are too expensive to keep. The mean is calculated on a running basis.
You got it right, it's your "coldstart".
Great, I think I know now what's wrong! See: PR welcome, I won't have time to fix this before the weekend. |
That is great you've narrowed down the issue although I am a bit confused that "the formula for the mean updates is only correct for n_more_iter=1." Isn't n_more_iter=1 is the value that my "hot" example uses to illustrate the problem? Wish I could help on the C side of things but my skills are more than a decade rusty. Definitely happy to help where I can on the Python side of things. |
I have just merge a fix for the bad mcmc performance that you observed when using the |
My initial testing of the OSX Python 3.5 wheel seems to confirm the fix (some random variation but hot, warm and cold all perform similarly). Thanks! One very minor issue is that the filename doesn't quite match up with the Github version tag. |
Great, I have fixed the file names too. |
Can we close this issue? |
MCMC seems to be sensitive to the number of iterations between fit_predict calls. Setting n_more_iter=1 has an optimal RMSE of 0.884 at step 27. With n_more_iter=10, RMSE is at 0.860 and still improving at 10 iterations (equivalent to 100 with a step of 1). The documentation mentions "We can warm_start every fastFM model which allows us to calculate custom statistics during the model fitting process efficiently", which seems to suggest this sensitivity shouldn't be present.
Code excerpts and results below:
The text was updated successfully, but these errors were encountered: