Machine learning module for Python==================================sklearn is a Python module integrating classical machinelearning algorithms in the tightly-knit world of scientific Pythonpackages n
""" Python的机器学习模块
sklearn是一个Python模块,将经典的机器学习算法集成到科学Python包(numpy、scipy、matplotlib)的紧密结合中。
它旨在为学习问题提供简单高效的解决方案,这些解决方案对每个人都是可访问的,并且在各种上下文中可重复使用:机器学习作为科学和工程的通用工具。
请参阅http://scikit-learn.org以获取完整文档。 """
import sys import logging import os import random
from ._config import get_config, set_config, config_context
logger = logging.getLogger(name)
PEP0440兼容的格式化版本,参见:
https://www.python.org/dev/peps/pep-0440/
通用发布标记:
X.Y.0 #在Y增量后的第一个发布
X.Y.Z #针对错误修复版本
可接受的预发布标记:
X.Y.ZaN #Alpha发布
X.Y.ZbN #Beta发布
X.Y.ZrcN #发布候选版
X.Y.Z #最终发布
Dev分支标记为:'X.Y.dev'或'X.Y.devN',其中N是整数。
'X.Y.dev0'是'X.Y.dev'的规范版本。
version = "1.0.2"
在OSX上,由于同时加载了多个OpenMP库,我们可能会遇到运行时错误。
例如,在调用BLAS内部时。设置以下环境变量允许加载多个OpenMP库。
它不应该降低性能,因为我们在可能发生嵌套OpenMP循环的代码部分中手动处理潜在的超订阅性能问题,
通过动态重新配置内部OpenMP运行时,在外部OpenMP并行部分的作用域下暂时禁用它。
os.environ.setdefault("KMP_DUPLICATE_LIB_OK", "True")
解决intel-openmp 2019.5中发现的问题:
https://github.com/ContinuumIO/anaconda-issues/issues/11294
os.environ.setdefault("KMP_INIT_AT_FORK", "FALSE")
try: # 构建过程中,此变量由__builtins__注入。它用于在二进制未构建时启用导入sklearn的子包。 # mypy错误:无法确定“SKLEARN_SETUP”的类型 SKLEARN_SETUP # type: ignore except NameError: SKLEARN_SETUP = False
if SKLEARN_SETUP:
sys.stderr.write("在构建过程中部分导入sklearn。\n")
# 在构建过程中,我们不会导入scikit-learn的其余部分,因为它可能尚未编译
else:
# _distributor_init允许分销商运行自定义的init代码。
# 例如,在Windows轮子中,这用于预加载嵌入在sklearn/.libs子文件夹中的OpenMP中的vcomp共享库运行时。
# 在导入show_versions之前这是必要的,因为后者链接到OpenMP运行时,以便能够内省它,
# 并且首先导入它会导致如果找不到OpenMP dll,则失败。
from . import _distributor_init # noqa: F401
from . import __check_build # noqa: F401
from .base import clone
from .utils._show_versions import show_versions
__all__ = [
"calibration",
"cluster",
"covariance",
"cross_decomposition",
"datasets",
"decomposition",
"dummy",
"ensemble",
"exceptions",
"experimental",
"externals",
"feature_extraction",
"feature_selection",
"gaussian_process",
"inspection",
"isotonic",
"kernel_approximation",
"kernel_ridge",
"linear_model",
"manifold",
"metrics",
"mixture",
"model_selection",
"multiclass",
"multioutput",
"naive_bayes",
"neighbors",
"neural_network",
"pipeline",
"preprocessing",
"random_projection",
"semi_supervised",
"svm",
"tree",
"discriminant_analysis",
"impute",
"compose",
# 非模块:
"clone",
"get_config",
"set_config",
"config_context",
"show_versions",
]
def setup_module(module): """测试装置,以确保全局可控的RNG种子"""
import numpy as np
# 检查环境中是否存在随机种子,如果不存在,则创建一个。
_random_seed = os.environ.get("SKLEARN_SEED", None)
if _random_seed is None:
_random_seed = np.random.uniform() * np.iinfo(np.int32).max
_random_seed = int(_random_seed)
print("I: 用%r种子设置RNG" % _random_seed)
np.random.seed(_random_seed)
random.seed(_random_seed
原文地址: https://www.cveoy.top/t/topic/ha3h 著作权归作者所有。请勿转载和采集!