how to modify the template script on azure auto ml?

AMROUN Lysa 396 Reputation points
2023-03-31T08:39:49.91+00:00

Hello to all,

I am working on a machine learning project, I have trained my model on azure auto ml studio, I would like to import it in onnx format, but it is not in the download options, so I want to modify the resulting code directly in azure auto ml, in the script.py I have modified the recording format of the model but I can't find how to execute this script because it tells me that the script.py is not found,

Could you help me please ?

thank you

Lysa

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

Accepted answer
  1. romungi-MSFT 48,906 Reputation points Microsoft Employee Moderator
    2023-04-03T07:17:24.4466667+00:00

    AMROUN Lysa I believe you are looking to create a model wihich is ONNX compatible with AutoML as per your previous thread. In this case in the automl config if you setup enable_onnx_compatible_models to true in the automl config the model should be available for download. Something similar to what is provided as guidance in this notebook.

    I would recommend running through this notebook and then change your experiment settings in a similar way to retrieve the best onnx format model.

    automl_settings = {
        "experiment_timeout_hours": 0.3,
        "enable_early_stopping": True,
        "iteration_timeout_minutes": 5,
        "max_concurrent_iterations": 4,
        "max_cores_per_iteration": -1,
        # "n_cross_validations": 2,
        "primary_metric": "AUC_weighted",
        "featurization": "auto",
        "verbosity": logging.INFO,
        "enable_code_generation": True,
    }
    
    automl_config = AutoMLConfig(
        task="classification",
        debug_log="automl_errors.log",
        compute_target=compute_target,
        experiment_exit_score=0.9984,
        blocked_models=["KNN", "LinearSVM"],
        enable_onnx_compatible_models=True,
        training_data=train_data,
        label_column_name=label,
        validation_data=validation_dataset,
        **automl_settings,
    )
    
    

    If this answers your query, do click Accept Answer and Yes for was this answer helpful. And, if you have any further query do let us know.

    1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. AMROUN Lysa 396 Reputation points
    2023-04-04T13:01:39.6666667+00:00

    @romungi-MSFT Thanks for your help it worked, and I use this onnnx to do classification of my input text, however it gives me only the first predicted class and I would like to have the first three with their scores in descending order, I do not know if it is possible to have the first three qualifications, for example when I use this onnnx in python via this little code:

    import onnxruntime as ort
    import numpy as np
    import onnxruntime as rt
    
    
    model_path = r"C:\Users\lysa.amroun\Desktop\modelOnnx\modelCVClassify.onnx"
    
    session = rt.InferenceSession(model_path)
    
    input_name = session.get_inputs()[0].name
    clean_texte = "My Input Texte"
    data = np.array([[clean_texte]], dtype=np.object)
    outputs = session.run(None, {input_name: data})
    
    print(outputs)
    
    

    I have the following output: ``` ``[array(['LO'], dtype=object), array([[0.05193216, 0.12469713, 0.7025832 , 0.03859689, 0.0821906 ]],dtype=float32)] ```` (LO is my label), I would like to have the first three labels, how can I do it? thank you for your help Lysa


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.