Scikit-learn Model Predict
Libraries:
Statistics and Machine Learning Toolbox /
Python Models
Description
The Scikit-learn Model Predict block predicts responses using a pretrained Python®
scikit-learn® model running in the MATLAB® Python environment. MATLAB supports the reference implementation of Python,
often called CPython. If you use 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. Your MATLAB Python environment must have the
scikit-learn
module installed. The Scikit-learn Model Predict block has
been tested using Python version 3.10 and scikit-learn
version
1.2.0.
Load a Python model into the block by specifying the path to a scikit-learn model file. You can optionally load a Python function to preprocess the observations (predictor data) that Simulink® passes to the Python model, and a Python function to postprocess the predicted responses from the model.
The input port x receives observations, optionally rearranges the input array dimensions, and then converts the observations to a Python array. The preprocessing function (if specified) processes the converted observations in Python and passes them to the Python model. The model generates predicted responses for the observations in Python and passes the responses to the Python postprocessing function (if specified). The output port Out1 returns the predicted responses from the model.
Note
The Scikit-learn Model Predict block cannot be run in Rapid Accelerator mode.
Examples
Ports
Input
Output
Parameters
Block Characteristics
Data Types |
|
Direct Feedthrough |
|
Multidimensional Signals |
|
Variable-Size Signals |
|
Zero-Crossing Detection |
|
Version History
Introduced in R2024a
See Also
Blocks
- Custom Python Model Predict | TensorFlow Model Predict (Deep Learning Toolbox) | PyTorch Model Predict (Deep Learning Toolbox) | ONNX Model Predict (Deep Learning Toolbox)