Data Science

Machine learning & data science for beginners and experts alike.
jeremyshih
Alteryx
Alteryx

In the exciting world of artificial intelligence (AI) and machine learning (ML), Alteryx Machine Learning has made it easier for data analysts and data scientists to extract valuable insights from their data and build ML models. But wait, there's more! We've recently introduced a game-changing feature called Model Export that takes the ML experience to a whole new level. In this blog post, we'll explore the fantastic benefits of using Alteryx Machine Learning's Model Export, which enables effortless model deployment, refinement, and collaboration. But before that, we’ll go through a quick tutorial on using model export. 

 

image001.jpg

Figure 1: Python Model Export Section in Alteryx Machine Learning 

  

Tutorial 

 

To access model export, run through Alteryx Machine Learning with your dataset and problem type of choice and end up on the “Export and Predict” page. Here you can click the “Export Script” button (shown above) to receive a nifty zip file containing your model exported as a Python script. Alteryx Machine Learning automatically maps your column names to internal names for data privacy and creates better features (using Featuretools). Therefore, there will be accompanying files for feature generation, column mapping, a requirements file, and training/holdout data that is split from your uploaded data in Alteryx Machine Learning. 

 

image002.png

 Figure 2: Example files within the downloading zip 

 

To run the “modelExport.py” files, in your terminal of choice, install Python requirements (preferably in a fresh virtual environment) using pip install –r requirements.txt. Then you can run the script using “python modelExport.py.” 

 

image003.jpg

 Figure 3: Example Python Script Output 

 

Doing the above will train your selected model using the training data, print out the steps and parameters in the preprocessing pipeline leading to the model, and predict using the holdout data. 

The “modelExport.py” script is a great building block to use your Alteryx Machine Learning model. Let’s see how we can leverage your model further! 

 

Refining Models for Optimal Performance 

 

Model refinement is essential for maximizing ML model performance, and Alteryx Machine Learning's Model Export feature makes it a breeze. Once you export your model, you can inspect the Python code used to create it and take advantage of EvalML, Alteryx's open-source automated ML library. EvalML empowers you to fine-tune and optimize your models further. You can apply advanced techniques for data imputation, ensemble learning, and feature engineering (using Featuretools). The exported models give you the flexibility to refine your models using a broader range of tools and methodologies, resulting in optimal performance. 

 

For example, you can run EvalML’s model understanding tools like prediction explanations to understand your model by generating SHAP values and summarizing the top 3 most positive and negative contributing features to the predicted value. For more examples, please look at the EvalML user guide. 

 

image004.png Figure 4: Running EvalML’s “prediction explanation” functionality 

 

Model Deployment 

 

Alteryx Machine Learning's Model Export feature lets you deploy your ML models with a single click. You can export your trained models in Python code or a handy pickle file, compatible with your preferred deployment environment. Whether you want to deploy your models in the cloud or embed them into existing applications, Model Export simplifies the process. This saves you time and resources, allowing you to put your ML models to work quickly, generating valuable insights for better decision-making. An example of this would be to alter the above Python script to use BentoML, an open-source Python framework to serve models, where we’ve conveniently added an EvalML integration:

 

import bentoml
from bentoml.frameworks.evalml import EvalMLModelArtifact
from bentoml.adapters import DataframeInput
@bentoml.env(infer_pip_packages=True)
@bentoml.artifacts([EvalMLModelArtifact('evalml_pipeline')])
class EvalMLModelService(bentoml.BentoService):
    @bentoml.api(input=DataframeInput(), batch=True)
    def predict(self, df):
        result = self.artifacts.model.predict(df)
        return result
svc = EvalMLModelService()
# Pack directly with EvalML model object
svc.pack('evalml_pipeline', pipeline)
svc.save()

 

Note: The EvalML integration only works up to BentoML < 1.0. To run EvalML models and pipelines with BentoML > 1.0, please follow these examples. 

 

Conclusion 

 

Model Export opens the doors to collaboration and knowledge sharing. You can easily share your exported models with stakeholders, domain experts, or team members for analysis, validation, or integration into other systems. This fosters cross-functional collaboration, allowing stakeholders to contribute their expertise and collectively improve ML models. 

 

This will empower your organizations to unlock the full potential of your ML models by enabling streamlined deployment, facilitating model refinement, and encouraging collaboration. You can effortlessly integrate your ML models into various deployment environments, refine them using a wide range of tools, and foster a culture of teamwork and knowledge sharing. With Alteryx Machine Learning’s Model Export feature, you'll drive innovation and extract valuable insights from your data like never before. 

Comments