Zaznacz stronę

Puro include per signature with your model, pass signature object as an argument preciso the appropriate log_model call, addirittura

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

Column-based Signature Example

The following example demonstrates how sicuro store per model signature for per simple classifier trained on the Iris dataset :

Tensor-based Signature Example

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

Model Input Example

Similar preciso model signatures, model inputs can be column-based (i.e DataFrames) or tensor-based (i.addirittura numpy.ndarrays). Verso model input example provides an instance of per valid model molla. Molla examples are stored with the model as separate artifacts and are referenced per the the MLmodel file .

How Sicuro Log Model With Column-based Example

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

How To 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 sopra the model signature. The sample stimolo can be passed per as verso numpy ndarray or a dictionary mapping per string sicuro a numpy array. The following example demonstrates how you can log verso tensor-based stimolo example with your model:

Model API

You can save and load MLflow Models con 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 esatto create and write models. This class has four key functions:

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

Built-Mediante Model Flavors

MLflow provides several standard flavors that might be useful sopra your applications. Specifically, many of its deployment tools support these flavors, so you can esportazione your own model mediante one of these flavors onesto 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 a python_function model. This enables other MLflow tools preciso sistema with any python model regardless of which persistence ondule or framework was used onesto produce the model. This interoperability is very powerful because it allows any Python model preciso be productionized mediante a variety of environments.

Sopra addition, the python_function model flavor defines a generic filesystem model format for Python models and provides utilities for saving and loading models to and from this format. The format is self-contained durante the sense that it log in adam4adam includes all the information necessary puro load and use a model. Dependencies are stored either directly with the model or referenced coraggio conda environment. This model format allows other tools preciso integrate their models with MLflow.

How Onesto Save Model As Python Function

Most python_function models are saved as part of other model flavors – for example, all mlflow built-mediante flavors include the python_function flavor durante the exported models. Mediante additif, the mlflow.pyfunc diversifie defines functions for creating python_function models explicitly. This ondule also includes utilities for creating custom Python models, which is a convenient way of adding custom python code to ML models. For more information, see the custom Python models documentation .