Esatto include per signature with your model, pass signature object as an argument puro the appropriate log_model call, ed
g. sklearn.log_model() . The model signature object can be created by hand or inferred from datasets with valid model inputs (addirittura.g. the training 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 preciso abri a model signature for per simple classifier trained on the Iris dataset :
Tensor-based Signature Example
The following example demonstrates how sicuro cloison per model signature for a simple classifier trained on the MNIST dataset :
Model Input Example
Similar puro model signatures, model inputs can be column-based (i.ancora DataFrames) or tensor-based (i.ancora numpy.ndarrays). Per model stimolo example provides an instance of a valid model stimolo. Molla examples are stored with the model as separate artifacts and are referenced con the the MLmodel file .
How To Log Model With Column-based Example
For models accepting column-based inputs, an example can be per celibe primato or a batch of records. The sample molla can be passed per as per Pandas DataFrame, list or dictionary. The given example will be converted puro per 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 a column-based spinta example with your model:
How Preciso 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 con the model signature. The sample stimolo can be passed sopra as per numpy ndarray or per dictionary mapping a string sicuro a numpy array. The following example demonstrates how you can log a tensor-based molla example with your model:
Model API
You can save and load MLflow Models durante 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 sicuro create and write models. This class has four key functions:
add_flavor esatto add a flavor sicuro the model. Each flavor has per 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 norma flavors that might be useful durante your applications. Specifically, many of its deployment tools support these flavors, so you can esportazione your own model per one of these flavors sicuro benefit from all these tools:
Python Function ( python_function )
The python_function model flavor serves as verso default model interface for MLflow Python models. Any MLflow Python model is expected to be loadable as per python_function model. This enables other MLflow tools sicuro rete informatica with any python model regardless of which persistence bigarre or framework was used onesto produce the model. This interoperability is very powerful because it allows any Python model onesto be productionized durante per variety of environments.
In prime, the python_function model flavor defines per generic filesystem model format for Python models and provides utilities for saving and loading models sicuro and from this format. The format is self-contained con the sense that it includes all the information necessary preciso load and use a model. Dependencies are stored either directly with the model or referenced inizio conda environment. This model format allows other tools esatto integrate their models with MLflow.
How Sicuro Save Model As Python Function
Most python_function models are saved as part of datingranking.net/it/alt-review/ other model flavors – for example, all mlflow built-sopra flavors include the python_function flavor per the exported models. Durante addenda, the mlflow.pyfunc module defines functions for creating python_function models explicitly. This ondule also includes utilities for creating custom Python models, which is per convenient way of adding custom python code preciso ML models. For more information, see the custom Python models documentation .
Không có bình luận