当前位置: 首页>>代码示例>>Python>>正文


Python pipeline.make_union方法代码示例

本文整理汇总了Python中sklearn.pipeline.make_union方法的典型用法代码示例。如果您正苦于以下问题:Python pipeline.make_union方法的具体用法?Python pipeline.make_union怎么用?Python pipeline.make_union使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sklearn.pipeline的用法示例。


在下文中一共展示了pipeline.make_union方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_missing_indicator_with_imputer

# 需要导入模块: from sklearn import pipeline [as 别名]
# 或者: from sklearn.pipeline import make_union [as 别名]
def test_missing_indicator_with_imputer(X, missing_values, X_trans_exp):
    trans = make_union(
        SimpleImputer(missing_values=missing_values, strategy='most_frequent'),
        MissingIndicator(missing_values=missing_values)
    )
    X_trans = trans.fit_transform(X)
    assert_array_equal(X_trans, X_trans_exp) 
开发者ID:PacktPublishing,项目名称:Mastering-Elasticsearch-7.0,代码行数:9,代码来源:test_impute.py

示例2: test_make_union

# 需要导入模块: from sklearn import pipeline [as 别名]
# 或者: from sklearn.pipeline import make_union [as 别名]
def test_make_union():
    pca = PCA(svd_solver='full')
    mock = Transf()
    fu = make_union(pca, mock)
    names, transformers = zip(*fu.transformer_list)
    assert_equal(names, ("pca", "transf"))
    assert_equal(transformers, (pca, mock)) 
开发者ID:PacktPublishing,项目名称:Mastering-Elasticsearch-7.0,代码行数:9,代码来源:test_pipeline.py

示例3: test_make_union_kwargs

# 需要导入模块: from sklearn import pipeline [as 别名]
# 或者: from sklearn.pipeline import make_union [as 别名]
def test_make_union_kwargs():
    pca = PCA(svd_solver='full')
    mock = Transf()
    fu = make_union(pca, mock, n_jobs=3)
    assert_equal(fu.transformer_list, make_union(pca, mock).transformer_list)
    assert_equal(3, fu.n_jobs)
    # invalid keyword parameters should raise an error message
    assert_raise_message(
        TypeError,
        'Unknown keyword arguments: "transformer_weights"',
        make_union, pca, mock, transformer_weights={'pca': 10, 'Transf': 1}
    ) 
开发者ID:PacktPublishing,项目名称:Mastering-Elasticsearch-7.0,代码行数:14,代码来源:test_pipeline.py

示例4: main

# 需要导入模块: from sklearn import pipeline [as 别名]
# 或者: from sklearn.pipeline import make_union [as 别名]
def main():
    vectorizer = make_union(
        on_field('name', Tfidf(max_features=100000, token_pattern='\w+')),
        on_field('text', Tfidf(max_features=100000, token_pattern='\w+', ngram_range=(1, 2))),
        on_field(['shipping', 'item_condition_id'],
                 FunctionTransformer(to_records, validate=False), DictVectorizer()),
        n_jobs=4)
    y_scaler = StandardScaler()
    with timer('process train'):
        train = pd.read_table('../input/train.tsv')
        train = train[train['price'] > 0].reset_index(drop=True)
        cv = KFold(n_splits=20, shuffle=True, random_state=42)
        train_ids, valid_ids = next(cv.split(train))
        train, valid = train.iloc[train_ids], train.iloc[valid_ids]
        y_train = y_scaler.fit_transform(np.log1p(train['price'].values.reshape(-1, 1)))
        X_train = vectorizer.fit_transform(preprocess(train)).astype(np.float32)
        print(f'X_train: {X_train.shape} of {X_train.dtype}')
        del train
    with timer('process valid'):
        X_valid = vectorizer.transform(preprocess(valid)).astype(np.float32)
    with ThreadPool(processes=4) as pool:
        Xb_train, Xb_valid = [x.astype(np.bool).astype(np.float32) for x in [X_train, X_valid]]
        xs = [[Xb_train, Xb_valid], [X_train, X_valid]] * 2
        y_pred = np.mean(pool.map(partial(fit_predict, y_train=y_train), xs), axis=0)
    y_pred = np.expm1(y_scaler.inverse_transform(y_pred.reshape(-1, 1))[:, 0])
    print('Valid RMSLE: {:.4f}'.format(np.sqrt(mean_squared_log_error(valid['price'], y_pred)))) 
开发者ID:pjankiewicz,项目名称:mercari-solution,代码行数:28,代码来源:mercari_golf.py

示例5: __init__

# 需要导入模块: from sklearn import pipeline [as 别名]
# 或者: from sklearn.pipeline import make_union [as 别名]
def __init__(self, training_values=None, training_targets=None):
        self.vectorizer = make_union(TfidfVectorizer(), PostTransformer())
        # Set using parameter_search. TODO: review after updating
        # corpus.
        self.classifier = svm.LinearSVC(C=1, loss='squared_hinge', multi_class='ovr', class_weight='balanced', tol=1e-6)
        if training_values is not None and training_targets is not None:
            self.fit(training_values, training_targets) 
开发者ID:Aurora0001,项目名称:LearnProgrammingBot,代码行数:9,代码来源:main.py

示例6: test_objectmapper

# 需要导入模块: from sklearn import pipeline [as 别名]
# 或者: from sklearn.pipeline import make_union [as 别名]
def test_objectmapper(self):
        df = pdml.ModelFrame([])
        self.assertIs(df.pipeline.Pipeline, pipeline.Pipeline)
        self.assertIs(df.pipeline.FeatureUnion, pipeline.FeatureUnion)
        self.assertIs(df.pipeline.make_pipeline, pipeline.make_pipeline)
        self.assertIs(df.pipeline.make_union, pipeline.make_union) 
开发者ID:pandas-ml,项目名称:pandas-ml,代码行数:8,代码来源:test_pipeline.py


注:本文中的sklearn.pipeline.make_union方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。