TensorFlow-Survival-Analysis icon indicating copy to clipboard operation
TensorFlow-Survival-Analysis copied to clipboard

Model Prediction and Model loading

Open charleswg opened this issue 7 years ago • 3 comments

I found that it doesn't load model for some reason. Maybe it's windows specific?

A quick fix change path checking in predict function from:

assert os.path.exists(self.params.modelPath) to assert os.path.exists(os.path.dirname(self.params.modelPath))

But when I try to predict after training, ds_tf = deepsurv_tf.DeepSurvTF(params) stats = ds_tf.train(train, valid) ds_tf.predict(valid['x'])

The follow error occur: --> 291 risk = sess.run([risk], feed_dict = {self.x : testXdata})

UnboundLocalError: local variable 'risk' referenced before assignment

charleswg avatar Aug 08 '17 18:08 charleswg

Thanks for giving the code a shot!

Could you provide more information about [risk]?

From this line

--> 291 risk = sess.run([risk], feed_dict = {self.x : testXdata})

alexhallam avatar Aug 10 '17 19:08 alexhallam

Actually I was trying to load the trained model to predict the hazard ratio of incoming data.

But I took a step back and tried in-session prediction right after training.

Would you provide example on how to do prediction (hazard_ratio, log_risk etc) using saved model?

charleswg avatar Aug 10 '17 19:08 charleswg

At the moment I am focusing on some other projects. I may not get to that in a timely manner. I tried to make the demo helpful, but of course I am sure there are many things (such as using a saved model) missing that would be helpful to many users. If other users are willing to push more ipython notebook examples that would be welcomed, as I do not plan on adding more examples any time soon. Also, freely submit pull requests as you try new things. Even if they are small things. I would be very accepting of ipython notebook demos. I am sure more examples could benefit someone else.

alexhallam avatar Aug 10 '17 20:08 alexhallam