本文整理匯總了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