简体   繁体   中英

Importing hidden function from Python module

I'd like to import _init_centroids function from scikit-learn/sklearn/cluster/k_means_.py . However, it's not listed in scikit-learn/blob/main/sklearn/cluster/_ init _.py . Is there any "nice" way to do that?

"Hidden" functions are a recommendation in Python, you can import them.

Try

from scikit-learn.sklearn.cluster.k_means_ import _init_centroids

在 Python 中,没有什么是真正私有的,因此您显式导入此函数:

from sklearn.cluster.k_means_ import _init_centroids

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM