AMPL
AMPL copied to clipboard
Inference from a multiclass classification model
Hi,
I am wondering how can i use the ''predict_from_model" function to make predictions on unknown molecules from a pre-trained tar.gz model, for a multi-class model (6 classes classification model)
I have tried to make the prediction in the standard way:
########### pfm.predict_from_model_file(model_path = mfile_NN, dont_standardize=True, input_df = input_df, smiles_col = smiles_col, response_col = response_col) ###########
as I do with binary models, but for multi-class models, I keep getting this error:
Traceback (most recent call last):
File "~/make_predictions_atomsci_models.py", line 35, in
Any clue ?
Thanks, M
The parameter class_number was never saved so when the new model is loaded it thinks there's only 2 classes instead of 6. You have a few options to work around this bug.
First, you can look at this commit and try out the fix. https://github.com/ATOMScience-org/AMPL/commit/a7fb0d6c77cdcdbfbf06ddb5a843a2a08592f0e9
Or, you can un-tar the model, manually edit the model_metadata.json, then re-tar the model and try to run predictions again. You'll need to make the following change:
"model_parameters": {
"ampl_version": "1.6.0",
"class_number": 6,
"featurizer": "ecfp",
"hyperparam_uuid": null,
"model_bucket": "public",
"model_choice_score_type": "roc_auc",
"model_type": "NN",
"num_model_tasks": 1,
"prediction_type": "classification",
Note the line that adds "class_number":6,