geffy / tffm

TensorFlow implementation of an arbitrary order Factorization Machine
MIT License
780 stars 176 forks source link

Custom Loss Function #35

Closed peterewills closed 6 years ago

peterewills commented 6 years ago

Is there a reason that custom loss functions are not enabled for TFFMClassifier and TFFMRegressor? In particular, it would be helpful to be able to use weighted log-loss, so that there is a class_weight keyword argument a la sklearn.linear_model.LogisticRegression.

If appropriate, I'd be happy to implement this.

geffy commented 6 years ago

Hi! Sorry for a long response -- I'm on vacation now.

In fact, Classifier and Regressor are just TFFMBase with hardcoded losses. About weights -- there are some attempts to implement it (you can find it in branches). Generally, it's quite easy to implement weights for losses.

From my point of view, if you want to implement some custom loss -- right way to do this is to use TFFMBase (similar as it done for TFFMClassifier). If you only need weights for classification -- it's OK to make them as parameter in TFFMClassifier.fit() method.