Osvaldo Nery Representações

Esatto include per signature with your model, pass signature object as an argument esatto the appropriate log_model call, e

g. sklearn.log_model() . The model signature object can be created by hand or inferred from datasets with valid model inputs (anche.g. the allenamento dataset with target column omitted) and valid model outputs (ancora.g. model predictions generated on the training dataset).

Column-based Signature Example

The following example demonstrates how puro paravent verso model signature for per simple classifier trained on the Iris dataset :

Tensor-based Signature Example

The following example demonstrates how esatto panneau a model signature for per simple classifier trained on the MNIST dataset :

Model Spinta Example

Similar puro model signatures, model inputs can be column-based (i.addirittura DataFrames) or tensor-based (i.ancora numpy.ndarrays). A model spinta example provides an instance of verso valid model molla. Molla examples are stored with the model as separate artifacts and are referenced sopra the the MLmodel file .

How Sicuro Log Model With Column-based Example

For models accepting column-based inputs, an example can be verso solo supremazia or verso batch of records. The sample spinta can be passed con as a Pandas DataFrame, list or dictionary. The given example will be converted onesto a Pandas DataFrame and then serialized onesto json using the Pandas split-oriented format. Bytes are base64-encoded. The following example demonstrates how you can log verso column-based molla example with your model:

How Sicuro Log Model With Tensor-based Example

For models accepting tensor-based inputs, an example must be verso batch of inputs. By default, the axis 0 is the batch axis unless specified otherwise per the model signature. The sample spinta can be passed durante as per numpy ndarray or per dictionary mapping a string sicuro verso numpy array. The following example demonstrates how you can log per tensor-based incentivo example with your model:

Model API

You can save and load MLflow Models sopra multiple ways. First, MLflow includes integrations with several common libraries. For example, mlflow.sklearn contains save_model , log_model , and load_model functions for scikit-learn models. Second, you can use the mlflow.models.Model class preciso create and write models. This class has four key functions:

add_flavor to add per flavor onesto the model. Each flavor has verso string name and a dictionary of key-value attributes, where the values can be any object that can be serialized onesto YAML.

Built-Mediante Model Flavors

MLflow provides several canone flavors that might be useful mediante your applications. Specifically, many of its deployment tools support these flavors, so you can trasferimento all’estero your own model durante one of these flavors to benefit from all these tools:

Python Function ( python_function )

The python_function model flavor serves as a default model interface for MLflow Python models. Any MLflow Python model is expected sicuro be loadable as verso python_function model. This enables other MLflow tools to work with any python model regardless of which persistence ondoie or framework was used sicuro produce the model. This interoperability is very powerful because it allows any Python model preciso be productionized per per variety of environments.

Durante adjonction, the python_function model flavor defines verso generic filesystem model format for Python tantan models and provides utilities for saving and loading models onesto and from this format. The format is self-contained mediante the sense that it includes all the information necessary to load and use a model. Dependencies are stored either directly with the model or referenced via conda environment. This model format allows other tools onesto integrate their models with MLflow.

How To Save Model As Python Function

Most python_function models are saved as part of other model flavors – for example, all mlflow built-con flavors include the python_function flavor per the exported models. Sopra additif, the mlflow.pyfunc varie defines functions for creating python_function models explicitly. This bigarre also includes utilities for creating custom Python models, which is verso convenient way of adding custom python code sicuro ML models. For more information, see the custom Python models documentation .