[英]Importing module functions from python packages
I saw the command listed as below for sklearn.tree.tree
我看到以下命令列出了
sklearn.tree.tree
from ._tree import Criterion, Splitter, Tree
from . import _tree
Yet in the same tree folder I cannot find any file or class named _tree
. 但是,在同一树文件夹中,我找不到任何名为
_tree
文件或类。 Can anyone tell me where exactly I can find this class? 谁能告诉我在哪里可以找到该课程?
The module you are looking for is written in Cython. 您要查找的模块是用Cython编写的。 The corresponding file is called
_tree.pyx
. 相应的文件称为
_tree.pyx
。 It can be found in .../scikit-learn/sklearn/tree/_tree.pyx
, if you have the scikit learn sources, eg in form of the git repo, on your computer. 如果您在计算机上拥有scikit学习源(例如,以git repo的形式),则可以在
.../scikit-learn/sklearn/tree/_tree.pyx
。
Cython is translated to C code, which can be found in _tree.c
. Cython转换为C代码,可以在
_tree.c
找到。
The compiled C code is what is imported in the lines you found, and the corresponding file is called _tree.so
. 编译后的C代码将在找到的行中导入,相应的文件称为
_tree.so
。 In a typical scikit-learn installation, this may be the only file you find. 在典型的scikit-learn安装中,这可能是您找到的唯一文件。 It is not human-readable, so if you are interested in the source, check it out here
它不是人类可读的,因此如果您对源感兴趣,请在此处查看
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.