py.importlib.import_module('gplearn') ???
조회 수: 9 (최근 30일)
이전 댓글 표시
gplearn = py.importlib.import_module('gplearn');
sklearn = py.importlib.import_module('sklearn');
why they are different???
댓글 수: 0
답변 (1개)
Rushikesh
2024년 9월 17일
Hello @slevin Lee
This is the intended behaviour, and it is due to the structure of these modules.
In “__init__.py” file of ‘sklearn’ library, you will find that it is importing several submodules and functions to be available directly from ‘sklearn’ namespace. Where as ‘gplearn’ library does not expose anything at top level when imported. It is related with how packages defined in there their ‘__init__.py’ file.
Added advantage of many properties get imported with ‘sklearn’ can be seen in below example. Let’s say you want to use ‘clone’ function of ‘sklearn’ then consider below scenarios:
1. Without importing submodules, functions at Top level:
from sklearn.base import clone
2. With importing submodules, functions at Top level:
from sklearn import clone
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Call Python from MATLAB에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!