2010-02-03 18:43:35 +08:00
|
|
|
"""
|
2012-10-23 23:38:21 +08:00
|
|
|
Machine learning module for Python
|
|
|
|
|
==================================
|
2010-07-02 04:42:54 +08:00
|
|
|
|
2011-09-02 17:00:02 +08:00
|
|
|
sklearn is a Python module integrating classical machine
|
2011-05-21 06:01:36 +08:00
|
|
|
learning algorithms in the tightly-knit world of scientific Python
|
2010-07-02 04:42:54 +08:00
|
|
|
packages (numpy, scipy, matplotlib).
|
|
|
|
|
|
|
|
|
|
It aims to provide simple and efficient solutions to learning problems
|
|
|
|
|
that are accessible to everybody and reusable in various contexts:
|
|
|
|
|
machine-learning as a versatile tool for science and engineering.
|
|
|
|
|
|
2012-10-23 23:38:21 +08:00
|
|
|
See http://scikit-learn.org for complete documentation.
|
2010-02-03 18:43:35 +08:00
|
|
|
"""
|
2012-07-25 18:34:04 +08:00
|
|
|
import sys
|
2013-11-28 09:22:26 +08:00
|
|
|
import re
|
|
|
|
|
import warnings
|
2014-12-24 23:28:28 +08:00
|
|
|
|
2010-07-02 04:42:54 +08:00
|
|
|
|
2013-11-28 09:22:26 +08:00
|
|
|
# Make sure that DeprecationWarning within this package always gets printed
|
|
|
|
|
warnings.filterwarnings('always', category=DeprecationWarning,
|
2013-11-28 11:53:33 +08:00
|
|
|
module='^{0}\.'.format(re.escape(__name__)))
|
2013-11-28 09:22:26 +08:00
|
|
|
|
2014-12-24 23:28:28 +08:00
|
|
|
# PEP0440 compatible formatted version, see:
|
|
|
|
|
# https://www.python.org/dev/peps/pep-0440/
|
|
|
|
|
#
|
|
|
|
|
# Generic release markers:
|
|
|
|
|
# X.Y
|
|
|
|
|
# X.Y.Z # For bugfix releases
|
|
|
|
|
#
|
|
|
|
|
# Admissible pre-release markers:
|
|
|
|
|
# X.YaN # Alpha release
|
|
|
|
|
# X.YbN # Beta release
|
|
|
|
|
# X.YrcN # Release Candidate
|
|
|
|
|
# X.Y # Final release
|
|
|
|
|
#
|
|
|
|
|
# Dev branch marker is: 'X.Y.dev' or 'X.Y.devN' where N is an integer.
|
2015-03-07 01:10:18 +08:00
|
|
|
# 'X.Y.dev0' is the canonical version of 'X.Y.dev'
|
2014-12-24 23:28:28 +08:00
|
|
|
#
|
2015-10-16 23:17:57 +08:00
|
|
|
__version__ = '0.18.dev0'
|
2014-12-24 23:28:28 +08:00
|
|
|
|
|
|
|
|
|
2010-09-12 02:25:28 +08:00
|
|
|
try:
|
2012-07-26 17:39:56 +08:00
|
|
|
# This variable is injected in the __builtins__ by the build
|
|
|
|
|
# process. It used to enable importing subpackages of sklearn when
|
|
|
|
|
# the binaries are not built
|
2012-07-25 18:34:04 +08:00
|
|
|
__SKLEARN_SETUP__
|
|
|
|
|
except NameError:
|
|
|
|
|
__SKLEARN_SETUP__ = False
|
2010-07-02 04:42:54 +08:00
|
|
|
|
2012-07-25 18:34:04 +08:00
|
|
|
if __SKLEARN_SETUP__:
|
2012-07-26 17:39:56 +08:00
|
|
|
sys.stderr.write('Partial import of sklearn during the build process.\n')
|
|
|
|
|
# We are not importing the rest of the scikit during the build
|
|
|
|
|
# process, as it may not be compiled yet
|
2012-07-25 18:34:04 +08:00
|
|
|
else:
|
|
|
|
|
from . import __check_build
|
|
|
|
|
from .base import clone
|
2014-09-02 15:55:20 +08:00
|
|
|
__check_build # avoid flakes unused variable error
|
2010-11-06 22:42:55 +08:00
|
|
|
|
2015-02-18 19:04:07 +08:00
|
|
|
__all__ = ['calibration', 'cluster', 'covariance', 'cross_decomposition',
|
2014-09-02 15:55:20 +08:00
|
|
|
'cross_validation', 'datasets', 'decomposition', 'dummy',
|
2015-06-06 02:45:45 +08:00
|
|
|
'ensemble', 'exceptions', 'externals', 'feature_extraction',
|
2015-03-11 02:55:36 +08:00
|
|
|
'feature_selection', 'gaussian_process', 'grid_search',
|
2015-03-07 06:55:01 +08:00
|
|
|
'isotonic', 'kernel_approximation', 'kernel_ridge',
|
2014-12-11 02:42:39 +08:00
|
|
|
'lda', 'learning_curve',
|
2014-09-02 15:55:20 +08:00
|
|
|
'linear_model', 'manifold', 'metrics', 'mixture', 'multiclass',
|
|
|
|
|
'naive_bayes', 'neighbors', 'neural_network', 'pipeline',
|
|
|
|
|
'preprocessing', 'qda', 'random_projection', 'semi_supervised',
|
2015-03-20 11:11:33 +08:00
|
|
|
'svm', 'tree', 'discriminant_analysis',
|
2014-09-02 15:55:20 +08:00
|
|
|
# Non-modules:
|
|
|
|
|
'clone']
|
2010-07-02 04:42:54 +08:00
|
|
|
|
2012-05-09 03:50:23 +08:00
|
|
|
def setup_module(module):
|
2014-12-24 23:28:28 +08:00
|
|
|
"""Fixture for the tests to assure globally controllable seeding of RNGs"""
|
2012-05-09 03:50:23 +08:00
|
|
|
import os
|
|
|
|
|
import numpy as np
|
|
|
|
|
import random
|
|
|
|
|
|
|
|
|
|
# It could have been provided in the environment
|
|
|
|
|
_random_seed = os.environ.get('SKLEARN_SEED', None)
|
|
|
|
|
if _random_seed is None:
|
2012-10-03 00:31:00 +08:00
|
|
|
_random_seed = np.random.uniform() * (2 ** 31 - 1)
|
2012-05-09 03:50:23 +08:00
|
|
|
_random_seed = int(_random_seed)
|
2012-10-05 23:56:37 +08:00
|
|
|
print("I: Seeding RNGs with %r" % _random_seed)
|
2012-05-09 03:50:23 +08:00
|
|
|
np.random.seed(_random_seed)
|
|
|
|
|
random.seed(_random_seed)
|