How to register Label Encoder, Scaler and XGBoost model outputs of mlflow run in the same artifact path?

Sena Aslan 50 Reputation points
2023-12-20T22:56:38.2166667+00:00

loggingmodels

I am training a xgboost model with mlflow. In the preprocessing part i am using label encoder and min max scaler. I should log and register these encoder and scaler objects just like model.(to be able to use them in score.py in the prediction part). However i couldnt register all of them in the same artifact folder. I know that i should have one model (including xgboost model itself,encoder and scaler) in the azure ml models section and pass it into ManagedOnlineDeployment function.

I am adding the ss of the code i am trying as well as its output in the models section.modellist

So, how can i register encoder, scaler and xgbregressor objects at once in the same directory ?

Azure Machine Learning
Azure Machine Learning
An Azure machine learning service for building and deploying models.
3,334 questions
{count} votes

1 answer

Sort by: Most helpful
  1. dupammi 8,615 Reputation points Microsoft External Staff
    2023-12-21T12:23:39.19+00:00

    Hi @Sena Aslan ,

    I hope you got the resolution from the prior comments.

    To help others in the community, let me reiterate the solution here by jotting down the gist of my comment answer above.

    To register all of these objects in the same artifact folder, you can use the mlflow.pyfunc.log_model() method. This method logs a Python model as an MLflow artifact for the current run. You can pass the encoder, scaler, and XGBoost model objects to the MyModel class constructor and then pass the instance of this class to the python_model parameter of the mlflow.pyfunc.log_model() method.

    Here is an official documentation, that you can refer and modify, to meet your requirements.

    Hope this helps.


    If this answers your query, do click Accept Answer and Yes for was this answer helpful.

    1 person found this answer helpful.
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.