本文整理汇总了Python中sklearn.__version__方法的典型用法代码示例。如果您正苦于以下问题:Python sklearn.__version__方法的具体用法?Python sklearn.__version__怎么用?Python sklearn.__version__使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sklearn
的用法示例。
在下文中一共展示了sklearn.__version__方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: set_configuration
# 需要导入模块: import sklearn [as 别名]
# 或者: from sklearn import __version__ [as 别名]
def set_configuration():
# set python version
config.ExternalDepFound('python', '.'.join([str(x)
for x in sys.version_info]))
version = mdp.__version__
if mdp.__revision__:
version += ', ' + mdp.__revision__
config.ExternalDepFound('mdp', version)
# parallel python dependency
try:
import pp
# set pp secret if not there already
# (workaround for debian patch to pp that disables pp's default password)
pp_secret = os.getenv('MDP_PP_SECRET') or 'mdp-pp-support-password'
# module 'user' has been deprecated since python 2.6 and deleted
# completely as of python 3.0.
# Basically pp can not work on python 3 at the moment.
import user
if not hasattr(user, 'pp_secret'):
user.pp_secret = pp_secret
except ImportError, exc:
config.ExternalDepFailed('parallel_python', exc)
示例2: _get_sklearn_version
# 需要导入模块: import sklearn [as 别名]
# 或者: from sklearn import __version__ [as 别名]
def _get_sklearn_version(): # pragma: no cover
""" Utility function to decide the version of sklearn.
PyOD will result in different behaviors with different sklearn version
Returns
-------
sk_learn version : int
"""
sklearn_version = str(sklearn.__version__)
if int(sklearn_version.split(".")[1]) < 19 or int(
sklearn_version.split(".")[1]) > 23:
raise ValueError("Sklearn version error")
return int(sklearn_version.split(".")[1])
示例3: _sklearn_version_21
# 需要导入模块: import sklearn [as 别名]
# 或者: from sklearn import __version__ [as 别名]
def _sklearn_version_21(): # pragma: no cover
""" Utility function to decide the version of sklearn
In sklearn 21.0, LOF is changed. Specifically, _decision_function
is replaced by _score_samples
Returns
-------
sklearn_21_flag : bool
True if sklearn.__version__ is newer than 0.21.0
"""
sklearn_version = str(sklearn.__version__)
if int(sklearn_version.split(".")[1]) > 20:
return True
else:
return False
示例4: __init__
# 需要导入模块: import sklearn [as 别名]
# 或者: from sklearn import __version__ [as 别名]
def __init__(self, params):
super(ExtraTreesAlgorithm, self).__init__(params)
logger.debug("ExtraTreesAlgorithm.__init__")
self.library_version = sklearn.__version__
self.trees_in_step = additional.get("trees_in_step", 100)
self.max_steps = additional.get("max_steps", 50)
self.early_stopping_rounds = additional.get("early_stopping_rounds", 50)
self.model = ExtraTreesClassifier(
n_estimators=self.trees_in_step,
criterion=params.get("criterion", "gini"),
max_features=params.get("max_features", 0.6),
min_samples_split=params.get("min_samples_split", 30),
warm_start=True,
n_jobs=-1,
random_state=params.get("seed", 1),
)
示例5: __init__
# 需要导入模块: import sklearn [as 别名]
# 或者: from sklearn import __version__ [as 别名]
def __init__(self, params):
super(RandomForestAlgorithm, self).__init__(params)
logger.debug("RandomForestAlgorithm.__init__")
self.library_version = sklearn.__version__
self.trees_in_step = additional.get("trees_in_step", 5)
self.max_steps = additional.get("max_steps", 3)
self.early_stopping_rounds = additional.get("early_stopping_rounds", 50)
self.model = RandomForestClassifier(
n_estimators=self.trees_in_step,
criterion=params.get("criterion", "gini"),
max_features=params.get("max_features", 0.8),
min_samples_split=params.get("min_samples_split", 4),
warm_start=True,
n_jobs=-1,
random_state=params.get("seed", 1),
)
示例6: save_model
# 需要导入模块: import sklearn [as 别名]
# 或者: from sklearn import __version__ [as 别名]
def save_model(self):
if self.mlp is not None:
fname, ext = QtWidgets.QFileDialog.getSaveFileName(
self,
"Save mode file",
"model.sav",
".sav",
)
base, ext = _ospath.splitext(fname)
fname = base + ".sav"
self.train_log["Model"] = fname
self.train_log["Generated by"] = "Picasso nanoTRON : Train"
import sklearn
self.train_log["Scikit-Learn Version"] = sklearn.__version__
self.train_log["Created on"] = datetime.datetime.now()
if fname:
joblib.dump(self.mlp, fname)
print("Saving complete.")
info_path = base + ".yaml"
io.save_info(info_path, [self.train_log])
示例7: __init__
# 需要导入模块: import sklearn [as 别名]
# 或者: from sklearn import __version__ [as 别名]
def __init__(self, options):
self.handle_options(options)
out_params = convert_params(
options.get('params', {}),
bools=['with_centering', 'with_scaling'],
strs=['quantile_range'],
)
if StrictVersion(sklearn_version) < StrictVersion(quantile_range_required_version) and 'quantile_range' in out_params.keys():
out_params.pop('quantile_range')
msg = 'The quantile_range option is ignored in this version of scikit-learn ({}): version {} or higher required'
msg = msg.format(sklearn_version, quantile_range_required_version)
messages.warn(msg)
if 'quantile_range' in out_params.keys():
try:
out_params['quantile_range'] = tuple(int(i) for i in out_params['quantile_range'].split('-'))
assert len(out_params['quantile_range']) == 2
except:
raise RuntimeError('Syntax Error: quantile_range requires a range, e.g., quantile_range=25-75')
self.estimator = _RobustScaler(**out_params)
示例8: enable
# 需要导入模块: import sklearn [as 别名]
# 或者: from sklearn import __version__ [as 别名]
def enable(name=None, verbose=True):
if LooseVersion(sklearn_version) < LooseVersion("0.20.0"):
raise NotImplementedError("daal4py patches apply for scikit-learn >= 0.20.0 only ...")
elif LooseVersion(sklearn_version) > LooseVersion("0.23.1"):
warn_msg = ("daal4py {daal4py_version} has only been tested " +
"with scikit-learn 0.23.1, found version: {sklearn_version}")
warnings.warn(warn_msg.format(
daal4py_version=daal4py_version,
sklearn_version=sklearn_version)
)
if name is not None:
do_patch(name)
else:
for key in _mapping:
do_patch(key)
if verbose and sys.stderr is not None:
sys.stderr.write("Intel(R) Data Analytics Acceleration Library (Intel(R) DAAL) solvers for sklearn enabled: "
"https://intelpython.github.io/daal4py/sklearn.html\n")
示例9: get_default_conda_env
# 需要导入模块: import sklearn [as 别名]
# 或者: from sklearn import __version__ [as 别名]
def get_default_conda_env(include_cloudpickle=False):
"""
:return: The default Conda environment for MLflow Models produced by calls to
:func:`save_model()` and :func:`log_model()`.
"""
import sklearn
pip_deps = None
if include_cloudpickle:
import cloudpickle
pip_deps = ["cloudpickle=={}".format(cloudpickle.__version__)]
return _mlflow_conda_env(
additional_conda_deps=[
"scikit-learn={}".format(sklearn.__version__),
],
additional_pip_deps=pip_deps,
additional_conda_channels=None
)
示例10: save
# 需要导入模块: import sklearn [as 别名]
# 或者: from sklearn import __version__ [as 别名]
def save(self, filename: str):
"""
Saves model to a custom file format
filename : str
Name of file to save. Don't include filename extensions
Extensions are added automatically
File format is a zipfile with joblib dump (pickle-like) + dependency metata
Metadata is checked on load.
Includes validation and metadata to avoid Pickle deserialization gotchas
See here Alex Gaynor PyCon 2014 talk "Pickles are for Delis"
for more info on why we introduce this additional check
"""
if '.zip' in filename:
raise UserWarning("The file extension '.zip' is automatically added"
+ " to saved models. The name will have redundant extensions")
sysverinfo = sys.version_info
meta_data = {
"python_": f'{sysverinfo[0]}.{sysverinfo[1]}',
"skl_": sklearn.__version__[:-2],
"pd_": pd.__version__[:-2],
"csrg_": cg.__version__[:-2]
}
with tempfile.TemporaryDirectory() as temp_dir:
joblib.dump(self, os.path.join(temp_dir, self.f_model), compress=True)
with open(os.path.join(temp_dir, self.f_mdata), 'w') as f:
json.dump(meta_data, f)
filename = shutil.make_archive(filename, 'zip', temp_dir)
示例11: load
# 需要导入模块: import sklearn [as 别名]
# 或者: from sklearn import __version__ [as 别名]
def load(filename: str):
"""
Load model from NodeEmbedding model zip file.
filename : str
full filename of file to load (including extensions)
The file should be the result of a `save()` call
Loading checks for metadata and raises warnings if pkg versions
are different than they were when saving the model.
"""
with tempfile.TemporaryDirectory() as temp_dir:
shutil.unpack_archive(filename, temp_dir, 'zip')
model = joblib.load(os.path.join(temp_dir, BaseNodeEmbedder.f_model))
with open(os.path.join(temp_dir, BaseNodeEmbedder.f_mdata)) as f:
meta_data = json.load(f)
# Validate the metadata
sysverinfo = sys.version_info
pyver = "{0}.{1}".format(sysverinfo[0], sysverinfo[1])
if meta_data["python_"] != pyver:
raise UserWarning(
"Invalid python version; {0}, required: {1}".format(
pyver, meta_data["python_"]))
sklver = sklearn.__version__[:-2]
if meta_data["skl_"] != sklver:
raise UserWarning(
"Invalid sklearn version; {0}, required: {1}".format(
sklver, meta_data["skl_"]))
pdver = pd.__version__[:-2]
if meta_data["pd_"] != pdver:
raise UserWarning(
"Invalid pandas version; {0}, required: {1}".format(
pdver, meta_data["pd_"]))
csrv = cg.__version__[:-2]
if meta_data["csrg_"] != csrv:
raise UserWarning(
"Invalid csrgraph version; {0}, required: {1}".format(
csrv, meta_data["csrg_"]))
return model
示例12: get_pandas_status
# 需要导入模块: import sklearn [as 别名]
# 或者: from sklearn import __version__ [as 别名]
def get_pandas_status():
try:
import pandas as pd
return _check_version(pd.__version__, pandas_min_version)
except ImportError:
traceback.print_exc()
return default_status
示例13: get_sklearn_status
# 需要导入模块: import sklearn [as 别名]
# 或者: from sklearn import __version__ [as 别名]
def get_sklearn_status():
try:
import sklearn as sk
return _check_version(sk.__version__, sklearn_min_version)
except ImportError:
traceback.print_exc()
return default_status
示例14: get_numpy_status
# 需要导入模块: import sklearn [as 别名]
# 或者: from sklearn import __version__ [as 别名]
def get_numpy_status():
try:
import numpy as np
return _check_version(np.__version__, numpy_min_version)
except ImportError:
traceback.print_exc()
return default_status
示例15: get_scipy_status
# 需要导入模块: import sklearn [as 别名]
# 或者: from sklearn import __version__ [as 别名]
def get_scipy_status():
try:
import scipy as sc
return _check_version(sc.__version__, scipy_min_version)
except ImportError:
traceback.print_exc()
return default_status