【发布时间】:2020-08-31 19:57:50
【问题描述】:
请不要将此标记为 how to call python and sklearn from matlab? 的重复项,因为我认为这个问题没有得到真正的回答。
我认为自从 Matlab 发布 R2014b 以来,directly use python from matlab 是可能的。
简而言之,您只需将py 放在python 调用前面。
我的设置(在使用命令pyversion('PATH_TO_PYTHON') 为matlab 提供python 路径后,运行良好。我什至可以使用dask 多处理。非常酷。例如,执行py.dask.distributed.Client 导致
Python Client with properties:
asynchronous: 0
cluster: [1×1 py.distributed.deploy.local.LocalCluster]
get_futures_error: [1×1 py.method]
coroutines: [1×1 py.list]
scheduler_file: [1×1 py.NoneType]
loop: [1×1 py.tornado.platform.select.SelectIOLoop]
recreate_error_locally: [1×1 py.method]
refcount: [1×1 py.collections.defaultdict]
extensions: [1×1 py.dict]
scheduler: [1×1 py.distributed.core.rpc]
rpc: [1×1 py.distributed.core.ConnectionPool]
futures: [1×1 py.dict]
scheduler_comm: [1×1 py.distributed.batched.BatchedSend]
status: [1×7 py.str]
connection_args: [1×1 py.dict]
id: [1×43 py.str]
generation: [1×1 py.int]
io_loop: [1×1 py.tornado.platform.select.SelectIOLoop]
security: [1×1 py.distributed.security.Security]
<Client: scheduler='tcp://127.0.0.1:59795' processes=4 cores=4>
回到问题:我已经安装了 sklearn,可以从引用的 python 安装中使用它。它的工作方式与 dask 相同。但是 MATLAB R2017a 找不到 sklearn。
对上述py.sklearn.cluster.dbscan 的类似调用会导致
Undefined variable "py" or class "py.sklearn.cluster.dbscan".
有没有python高手可以解释一下?
【问题讨论】:
-
无法复制。 MATLAB R2017a 在这里与 sklearn 完美配合。无需额外设置,只需正确设置
pyversion。您是否 100% 确定您在控制台和 MATLAB 中使用相同的 python 版本?您可以尝试使用 sklearn 创建一个新的虚拟环境并在 MATLAB 中使用它吗? -
@hbaderts:感谢您的测试。我运行 Windows 并且在计算机上只有一个 python。我完全确定运行/测试相同的 pyhton 版本(Anaconda 3 64 位)。您正在运行哪个安装程序?
标签: python matlab scikit-learn