本文整理汇总了Python中sklearn.impute方法的典型用法代码示例。如果您正苦于以下问题:Python sklearn.impute方法的具体用法?Python sklearn.impute怎么用?Python sklearn.impute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sklearn
的用法示例。
在下文中一共展示了sklearn.impute方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import sklearn [as 别名]
# 或者: from sklearn import impute [as 别名]
def __init__(self, missing_values=None, strategy='mean', fill_value=None, verbose=0, copy=True):
self._hyperparams = {
'missing_values': missing_values,
'strategy': strategy,
'fill_value': fill_value,
'verbose': verbose,
'copy': copy}
self._wrapped_model = sklearn.impute.SimpleImputer(**self._hyperparams)
示例2: _make_est_func
# 需要导入模块: import sklearn [as 别名]
# 或者: from sklearn import impute [as 别名]
def _make_est_func(self):
import sklearn
from sklearn import multiclass # NOQA
from sklearn import ensemble # NOQA
from sklearn import neural_network # NOQA
from sklearn import svm # NOQA
from sklearn import preprocessing # NOQA
from sklearn import pipeline # NOQA
from functools import partial
wrap_type = self.wrap_type
est_type = self.est_type
multiclass_wrapper = {
None: ub.identity,
'OVR': sklearn.multiclass.OneVsRestClassifier,
'OVO': sklearn.multiclass.OneVsOneClassifier,
}[wrap_type]
est_class = {
'RF': sklearn.ensemble.RandomForestClassifier,
'SVC': sklearn.svm.SVC,
'Logit': partial(sklearn.linear_model.LogisticRegression, solver='lbfgs'),
'MLP': sklearn.neural_network.MLPClassifier,
}[est_type]
est_kw = self.est_kw
try:
from sklearn.impute import SimpleImputer
Imputer = SimpleImputer
import numpy as np
NAN = np.nan
except Exception:
from sklearn.preprocessing import Imputer
NAN = 'NaN'
if est_type == 'MLP':
def make_estimator():
pipe = sklearn.pipeline.Pipeline([
('inputer', Imputer(
missing_values=NAN, strategy='mean')),
# ('scale', sklearn.preprocessing.StandardScaler),
('est', est_class(**est_kw)),
])
return multiclass_wrapper(pipe)
elif est_type == 'Logit':
def make_estimator():
pipe = sklearn.pipeline.Pipeline([
('inputer', Imputer(
missing_values=NAN, strategy='mean')),
('est', est_class(**est_kw)),
])
return multiclass_wrapper(pipe)
else:
def make_estimator():
return multiclass_wrapper(est_class(**est_kw))
return make_estimator