Trying to train a linear regression on encrypted data

Hi! I am trying to train a linear regression on encrypted data. I don’t understand what i do wrong. I can’t make the R^2 factor rise above 0.4. The best R^2 factor when training on clear data is 0.87. Could someone take a look at my code. I don’t know if it s a problem in the way i am encrypting the data or the code for the linear regression.
Thank you!

PS: I implemented the same code in TenSeal and it worked fine, so i am guessing something about parameters settings in openfhe is the problem.
https://github.com/dariapirvulescu18/openfhe/blob/master/lr_trained_on_encrypted_data.ipynb

@Cesare
@ypolyakov
@andreea.alexandru

I looked at your code. Debugging it would be time-consuming. I noticed that you are using very small plaintext-precision-related parameters, which would likely affect the precision of your computation.

Try the following parameters:
scaleModSize = 50
parameters.SetFirstModSize(60)

If you have a working plaintext implementation, the best way to debug your code is to compare the encrypted version against it, by calling decryption after every step and checking if the results match (or at least very close in value).

Thank you for your suggestions! I will do that!