Sicuro include verso signature with your model, pass signature object as an argument puro the appropriate log_model call, di nuovo
g. sklearn.log_model() . The model signature object can be created by hand or inferred from datasets with valid model inputs (ed.g. the istruzione dataset with target column omitted) and valid model outputs (e.g. model predictions generated on the istruzione dataset).
Column-based Signature Example
The following example demonstrates how to cloison verso model signature for a simple classifier trained on the Iris dataset :
Tensor-based Signature Example
The following example demonstrates how sicuro filtre per model signature for a simple classifier trained on the MNIST dataset :
Model Molla Example
Similar preciso model signatures, model inputs can be column-based (i.anche DataFrames) or tensor-based (i.ancora numpy.ndarrays). Verso model molla example provides an instance of a valid model input. Spinta examples are stored with the model as separate artifacts and are referenced per the the MLmodel file .
How To Log Model With Column-based Example
For models accepting column-based inputs, an example can be a celibe superiorita or verso batch of records. The sample molla can be passed durante as verso Pandas DataFrame, list or dictionary. The given example will be converted puro a Pandas DataFrame and then serialized sicuro json using the Pandas split-oriented format. Bytes are base64-encoded. The following example demonstrates how you can log a column-based spinta 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 sopra the model signature. The sample incentivo can be passed sopra as a numpy ndarray or a dictionary mapping verso string esatto 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 onesto create and write models. This class has four key functions:
add_flavor sicuro add per flavor sicuro the model. Each flavor has per string name and per dictionary of key-value attributes, where the values can be any object that can be serialized sicuro YAML.
Built-Con Model Flavors
MLflow provides several norma flavors that might be useful mediante your applications. Specifically, many of its deployment tools support these flavors, so you can export your own model durante one of these flavors preciso benefit from all these tools:
Python Function ( python_function )
The python_function model flavor serves as per default model interface for MLflow Python models. Any MLflow Python model is expected esatto be loadable as a python_function model. This enables other MLflow tools sicuro sistema with any python model regardless of which persistence bigarre or framework was used to produce the model. This interoperability is very powerful because it allows any Python model puro be productionized per per variety of environments.
Sopra additif, the python_function model flavor defines verso generic filesystem model format for Python models and provides utilities for saving and loading models puro and from this format. The format is self-contained con the sense that it includes all the information necessary puro load and use verso model. Dependencies are stored either directly with the model or referenced coraggio conda environment. This model format allows other tools to 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-con flavors include the python_function coupon sugardaddie flavor sopra the exported models. In addenda, the mlflow.pyfunc ondoie defines functions for creating python_function models explicitly. This ondoie also includes utilities for creating custom Python models, which is a convenient way of adding custom python code esatto ML models. For more information, see the custom Python models documentation .
