How to predict risk scores with Cox models using lifelines package? - survival-analysis

I have made multiple cox models with Lifelines package and I am trying to predict the risk score of each individual following information in CoxPhFitter page. predict_hazard is a suggested command in that page, but when I use it to predict risk scores, it runs into an error: CoxPHFitter has no attribute 'predict_hazard'. Has anyone else seen such error with predict_hazard?

Related

Best way to choose a threshold for a multiclass classification problem

I have build a model using Keras. My main aim is to classify animals belonging to 10 different categories. The model is performing well. However, when I am testing the images with non animal images, the model is trying to fit the image between the 10 different categories. That is if I test the model with a non animal image I am getting an animal as output with a high confidence score. I know that to solve this issue I must use a threshold. But I have not found any resource on how to do this task. Can someone help please?

Does Mflow work only with predictive models?

I am trying to use Mlflow to manage my Bayesian Optimization Model, which has several methods other than the predict (run_optimization() for example). My doubt is that when I log my model to the tracking server the model and retrieve it, it only contains the predict() as it is wrapped as a PyFunctModel; that's a problem because I need the model also to run prescriptions (suggestion of a possible new optimum), does anyone ever tried it? Thanks

Retraining Tensorflow for new class labels

I am building a classifier that predicts the damage of a vehicle(like high, low, medium, good). I referred to this GitHub repository
https://github.com/raviranjan0309/Car-Damage-Detector
There is a retrained_label.txt file in models/tf_files which consist of four classes
not,
car,
high,
low
I do not want these four classes and I want my tf to predict one of the following
Good,
High Damage,
Low Damage,
Medium Damage
Is this possible ?
Should I need to retrain the tf for these classes ?
If so how ?
Thanks
The file you mentioned only has 4 words in it and to be honest it is difficult to understand why they are in that file.
Normally, for any tensorflow related analysis, you have to retrain the algorithm to be able to predict based on new labels.
If you are new to ML/DL and Tensorflow, I would suggest looking into excellent tutorials on Titanic predictors where you can use a simple database to predict either one of two outcomes: survive or die
You can then use a similar code and just use a different dataset (in this case I guess a car dataset) to have it predict one of four possible outcomes for damage. The only problem is getting that dataset of course
(many examples, but here's one: https://towardsdatascience.com/predicting-the-survival-of-titanic-passengers-30870ccc7e8)
Without having at least a 1000 or so data point with car information where that damage is already listed, it would be quite challenging.
So just to summarize:
1) yes you have to retrain and probably need a different dataset too
2) you may be able to create a dataset with damage info based on what you already have
3) once training/testing sets are ready, you can then retrain using simple ML techniques

The data set being scored must contain all features used during training, missing feature(s)

I built a model in Azure ML, then i published this model as a web service. I would like to customize the input fields of the web service by updating the needed inputs for the model prediction WS.
The model has been trained on set of features to predict a price value on a given date. I want the customer to provide a date to predict the price without the need to enter features values that i supplied when i trained the model.
The error message when i customize the web service inputs by removing the unneeded columns in the predictive experiment (by adding select column module before the score module):
Error 1000: AFx Library library exception: table: The data set
being scored must contain all features used during training, missing
feature(s).
How would i fix this issue?
I had this same problem, with the below error.
AFx Library library exception: table: The data set being scored must contain all features used during training, missing feature(s).
This happened when i changed my classification algorithm to regression algorithm in the same project. I got it cleared by creating a new project with same steps and all worked perfectly fine.
I think the problem is when we change the type of algorithm, ML studio is confused.
The Score Model module needs the same input features that were used to train the model. That's a basic property of the machine learning algorithms.
Could you clarify where the feature value come from, if not from customer?
-Roope

Train multiple models with various measures and accumulate predictions

So I have been playing around with Azure ML lately, and I got one dataset where I have multiple values I want to predict. All of them uses different algorithms and when I try to train multiple models within one experiment; it says the “train model can only predict one value”, and there are not enough input ports on the train-model to take in multiple values even if I was to use the same algorithm for each measure. I tried launching the column selector and making rules, but I get the same error as mentioned. How do I predict multiple values and later put the predicted columns together for the web service output so I don’t have to have multiple API’s?
What you would want to do is to train each model and save them as already trained models.
So create a new experiment, train your models and save them by right clicking on each model and they will show up in the left nav bar in the Studio. Now you are able to drag your models into the canvas and have them score predictions where you eventually make them end up in the same output as I have done in my example through the “Add columns” module. I made this example for Ronaldo (Real Madrid CF player) on how he will perform in match after training day. You can see my demo on http://ronaldoinform.azurewebsites.net
For more detailed explanation on how to save the models and train multiple values; you can check out Raymond Langaeian (MSFT) answer in the comment section on this link:
https://azure.microsoft.com/en-us/documentation/articles/machine-learning-convert-training-experiment-to-scoring-experiment/
You have to train models for each variable that you going to predict. Then add all those predicted columns together and get as a single output for the web service.
The algorithms available in ML are only capable of predicting a single variable at a time based on the inputs it's getting.

Resources