Python Model Coexecution
Coexecute Python® scikit-learn® and custom Python machine learning models for prediction in Simulink® using blocks in Statistics and Machine Learning Toolbox™. Load a saved Python model into a Scikit-learn Model Predict block or a Custom Python Model Predict block and configure incoming data types. Each block executes the model in Python and returns the Python output to Simulink. You can optionally load a Python function into the Scikit-learn Model Predict block to preprocess the predictor data Simulink passes to the Python model, and a function to postprocess the predicted responses from the model.
MATLAB supports the reference implementation of Python, often called CPython.
If you are on a Mac or Linux® platform, you already have Python installed. If you use
Windows®, you need to install a distribution, such as those found at https://www.python.org/downloads/. For more information, see Configure Your System to Use Python. Both blocks have been tested
using Python version 3.10. To use the Scikit-learn Model Predict
block, your MATLAB Python environment must have the
scikit-learn
module installed.
Blocks
Scikit-learn Model Predict | Predict responses using pretrained Python scikit-learn model (Since R2024a) |
Custom Python Model Predict | Predict responses using pretrained custom Python model (Since R2024a) |
Related Information
Topics
- Predict Cluster Assignments Using Python Scikit-learn Model Predict Block
This example shows how to use the Scikit-learn Model Predict block for prediction in Simulink®.
- Predict Responses Using Custom Python Model in Simulink
This example shows how to use the Custom Python Model Predict block for prediction in Simulink®.