Skip to content
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

Evaluation #26

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion dsm/dsm_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
from dsm.dsm_torch import DeepRecurrentSurvivalMachinesTorch
from dsm.losses import predict_cdf
import dsm.losses as losses
from dsm.utilities import train_dsm, _get_padded_features, _get_padded_targets
from dsm.utilities import train_dsm, _get_padded_features, _get_padded_targets, _reshape_tensor_with_nans
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

break into multiple lines this line is too long


import torch
import numpy as np
Expand Down Expand Up @@ -118,6 +118,18 @@ def fit(self, x, t, e, vsize=0.15,
self.fitted = True

return self

def eval(self, x, t, e):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this ... can we instead call this function _log_likelihood? or _negative_log_likelihood or something like that ? preferably with an underscore at the start to show that it isn't typically supposed to be used directly ?

"""
Evaluates models with conditional loss
"""
processed_data = self._prepocess_training_data(x, t, e, 0, 0)
_, _, _, x_val, t_val, e_val = processed_data
x_val, t_val, e_val = x_val,\
_reshape_tensor_with_nans(t_val),\
_reshape_tensor_with_nans(e_val)
return losses.conditional_loss(self.torch_model, x_val, t_val, e_val,
elbo=False).detach().numpy()

def _prepocess_test_data(self, x):
return torch.from_numpy(x)
Expand Down