Azure Machine Learning brings no code option. At 1st it might sound , a tool with minor capabilities, but in reality, it is already a very complex nice simple tool. There are already very nice tutorials about Azure ML. I will just use one them and show what Azure ML brings us for free.
It saves us writing hundreds of code lines. Much better it can optimize and try lots of algorithms. Moreover deploy for us in a few clicks with an web endpoint or API Call. I think, very soon, no one will write Machine Learning code, because with a few liner tools like PyCaret we can try lots of algorithms at once. With Microsoft Azure like tools, not only we can do the same, now it became a drag drop utility.
I will follow a simple case from official documentation, and list what Microsoft Azure Machine Learning gives us at default.
- It checks anomaly in data. (Imbalance, Missing Values, High Cardinality Feature.) These are in fact things we must always check. Now they are builtin.
2) It tries too many models with 1 click. Fully hand coding this will take too much time. You can also see the hyper parameters associated with each Model)
3) Automatically tries all performance metrics. Sometimes we try a metric, and then we decide to check another metric, and run training from scratch. Instead of this, we can check all at once.
4) Draws associated performance metric charts. All of these charts are what we need to get an intuitive idea about data.
5) It give a best model summary(Right Pane). For the model it choose, it gives much more details. If you want to check more detailed reports about a model, after initial training you can trigger sumary generation after training.
You can check hyperparameters used.
It gives a graph overview of steps included in whole process.
6) You can deploy a model with a few clicks. If you will do this manually, create your model, dockerize, push to registry, decide on deployment server, configure …. With a few clicks you can deploy your model.
You can download model.(Model file and py class to trigger it)
# ---------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# ---------------------------------------------------------
import json
import logging
import os
import pickle
import numpy as np
import pandas as pd
import joblib
import azureml.automl.core
from azureml.automl.core.shared import logging_utilities, log_server
from azureml.telemetry import INSTRUMENTATION_KEY
from inference_schema.schema_decorators import input_schema, output_schema
from inference_schema.parameter_types.numpy_parameter_type import NumpyParameterType
from inference_schema.parameter_types.pandas_parameter_type import PandasParameterType
from inference_schema.parameter_types.standard_py_parameter_type import StandardPythonParameterType
data_sample = PandasParameterType(pd.DataFrame({"age": pd.Series([0], dtype="int8"), "job": pd.Series(["example_value"], dtype="object"), "marital": pd.Series(["example_value"], dtype="object"), "education": pd.Series(["example_value"], dtype="object"), "default": pd.Series(["example_value"], dtype="object"), "housing": pd.Series(["example_value"], dtype="object"), "loan": pd.Series(["example_value"], dtype="object"), "contact": pd.Series(["example_value"], dtype="object"), "month": pd.Series(["example_value"], dtype="object"), "duration": pd.Series([0], dtype="int16"), "campaign": pd.Series([0], dtype="int8"), "pdays": pd.Series([0], dtype="int16"), "previous": pd.Series([0], dtype="int8"), "poutcome": pd.Series(["example_value"], dtype="object"), "emp.var.rate": pd.Series([0.0], dtype="float32"), "cons.price.idx": pd.Series([0.0], dtype="float32"), "cons.conf.idx": pd.Series([0.0], dtype="float32"), "euribor3m": pd.Series([0.0], dtype="float32"), "nr.employed": pd.Series([0.0], dtype="float32")}))
input_sample = StandardPythonParameterType({'data': data_sample})
method_sample = StandardPythonParameterType("predict")
sample_global_params = StandardPythonParameterType({"method": method_sample})
result_sample = NumpyParameterType(np.array(["example_value"]))
output_sample = StandardPythonParameterType({'Results':result_sample})
try:
log_server.enable_telemetry(INSTRUMENTATION_KEY)
log_server.set_verbosity('INFO')
logger = logging.getLogger('azureml.automl.core.scoring_script_v2')
except:
pass
def init():
global model
# This name is model.id of model that we want to deploy deserialize the model file back
# into a sklearn model
model_path = os.path.join(os.getenv('AZUREML_MODEL_DIR'), 'model.pkl')
path = os.path.normpath(model_path)
path_split = path.split(os.sep)
log_server.update_custom_dimensions({'model_name': path_split[-3], 'model_version': path_split[-2]})
try:
logger.info("Loading model from path.")
model = joblib.load(model_path)
logger.info("Loading successful.")
except Exception as e:
logging_utilities.log_traceback(e, logger)
raise
@input_schema('GlobalParameters', sample_global_params, convert_to_provided_type=False)
@input_schema('Inputs', input_sample)
@output_schema(output_sample)
def run(Inputs, GlobalParameters={"method": "predict"}):
data = Inputs['data']
if GlobalParameters.get("method", None) == "predict_proba":
result = model.predict_proba(data)
elif GlobalParameters.get("method", None) == "predict":
result = model.predict(data)
else:
raise Exception(f"Invalid predict method argument received. GlobalParameters: {GlobalParameters}")
if isinstance(result, pd.DataFrame):
result = result.values
return {'Results':result.tolist()}
7) You can register your model as MLFlow. MLFlow gives you the ability to control life cycle of Machine Learning models. This cool tool is also already integrated.
I showed maybe only a few cool things you can do with Azure Machine Learning. Azure ML gives you features, which need thousands lines coding, and capacity of lots of configuration, deployment tools, with a few click.
For well defined Machine Learning problems, Azure Machine Learning is a “click next” tool.