mljar-supervised icon indicating copy to clipboard operation
mljar-supervised copied to clipboard

Compute predictions from selected model

Open pplonski opened this issue 4 years ago • 12 comments
trafficstars

Details in discussion https://github.com/mljar/mljar-supervised/discussions/421

pplonski avatar Jun 25 '21 07:06 pplonski

I'll like to work on this

asuzukosi avatar Jun 25 '21 11:06 asuzukosi

@asuzukosi great!

Some tips:

  • You can pass model name in the predict() method. Model name will be simply a string that is displayed in the report.
  • When AutoML is loading models from the disk, only models needed by the best_model are loaded (for speed reason). You need to ensure that model selected for prediction is loaded. In the case of Ensemble that might be several models.

Please let me know if you need more help.

pplonski avatar Jun 28 '21 04:06 pplonski

hey, is this issue still open? can i work on this

matrixhead avatar Aug 21 '21 19:08 matrixhead

hey @matrixhead!

the issue is still open, I'm assigning it to you

pplonski avatar Aug 21 '21 20:08 pplonski

#460 I don't know this is the right way to do it

matrixhead avatar Aug 23 '21 17:08 matrixhead

@matrixhead few comments:

  1. Have you tested the code? Did you write the unit tests? I would suggest to write unit tests. Do you have idea what units tests can be added to cover corner cases?
  2. I would name the argument model_name.
  3. When loading the model from hard drive the only models from load_on_predict parameter in params.json file are loaded. Those are models needed be best_model. We need to assure that selected model by user is loaded.
  4. There are predict(), predict_proba() and predict_all() methods. They should support the model_name parameter.

pplonski avatar Aug 24 '21 06:08 pplonski

  1. no I didn't write tests, I will try to do that.
  2. ok
  3. can I do it this way, first by calling load() from _predict() and then checking user-specified model is present in the _models or not
  4. okay i will do that

matrixhead avatar Aug 27 '21 15:08 matrixhead

#460

matrixhead avatar Aug 28 '21 18:08 matrixhead

Hi @pplonski , I just opened a PR for this. I'm sure that more work would be required before we can merge it, but early feedback would be very helpful. Thanks!

Kshitij68 avatar Sep 02 '22 03:09 Kshitij68

Quick and dirty workaround until this is oficially implemented:

from supervised.model_framework import ModelFramework
model = ModelFramework.load("AUTOML_FOLDER_NAME_HERE", model_subpath="MODEL_FOLDER_NAME_HERE")

For regression results:

y_pred = automl._base_predict(qdqd_X_test, model=model)["prediction"].to_numpy()

For classification results:

y_pred = automl._base_predict(qdqd_X_test, model=model)["label"].to_numpy()

Hopefully i can save someones time. :D

dermodmaster avatar Mar 04 '24 08:03 dermodmaster