Main Content

Python 模型协同执行

在 Simulink 中加载和协同执行用于预测的 Python 机器学习模型

使用 Statistics and Machine Learning Toolbox™ 中的模块在 Simulink® 中协同执行用于预测的 Python® scikit-learn® 和自定义 Python 机器学习模型。将保存的 Python 模型加载到 Scikit-learn Model Predict 模块或 Custom Python Model Predict 模块中,并配置传入的数据类型。每个模块都执行 Python 中的模型,并将 Python 输出返回到 Simulink。您可以选择将 Python 函数加载到 Scikit-learn Model Predict 模块中以预处理 Simulink 传递给 Python 模型的预测变量数据,也可以加载一个函数来后处理来自模型的预测响应。

MATLAB 支持 Python 的参考实现,通常称为 CPython。如果您在 Mac 或 Linux® 平台上,则已默认安装 Python。如果您使用 Mac 或 Linux® 平台,则已默认安装 Python。如果您使用 Windows®,则需要安装一个分发版,这种版本您可以在 https://www.python.org/downloads/ 找到。有关详细信息,请参阅配置您的系统使用 Python。这两个模块都已使用 Python 3.10 版进行了测试。要使用 Scikit-learn Model Predict 模块,您的 MATLAB Python 环境必须已安装 scikit-learn 模块。

模块

Scikit-learn Model PredictPredict responses using pretrained Python scikit-learn model (自 R2024a 起)
Custom Python Model PredictPredict responses using pretrained custom Python model (自 R2024a 起)

主题