【问题标题】:Explanation of pipeline generated by tpottpot生成的管道说明
【发布时间】:2021-08-09 11:01:15
【问题描述】:

我正在使用 tpotClassifier() 并将以下管道作为我的最佳管道。我附上了我得到的管道代码。有人能解释一下管道流程和顺序吗?

import numpy as np
import pandas as pd
from sklearn.ensemble import ExtraTreesClassifier
from sklearn.feature_selection import SelectFwe, f_classif
from sklearn.model_selection import train_test_split
from sklearn.pipeline import make_pipeline, make_union
from tpot.builtins import StackingEstimator
from sklearn.preprocessing import FunctionTransformer
from copy import copy

tpot_data = pd.read_csv('PATH/TO/DATA/FILE', sep='COLUMN_SEPARATOR', dtype=np.float64)
features = tpot_data.drop('target', axis=1)
                         training_features, testing_features, training_target, testing_target = \
                         train_test_split(features, tpot_data['target'], random_state=None)

exported_pipeline = make_pipeline(
make_union(
    FunctionTransformer(copy),
    make_union(
        FunctionTransformer(copy),
        make_union(
            FunctionTransformer(copy),
            make_union(
                FunctionTransformer(copy),
                FunctionTransformer(copy)
            )
        )
    )
),
SelectFwe(score_func=f_classif, alpha=0.049),
ExtraTreesClassifier(bootstrap=False, criterion="entropy", max_features=1.0, min_samples_leaf=2, min_samples_split=5, n_estimators=100)
)

exported_pipeline.fit(training_features, training_target)
results = exported_pipeline.predict(testing_features)

【问题讨论】:

    标签: python python-3.x machine-learning tpot


    【解决方案1】:

    make_union 只是合并多个数据集,FunctionTransformer(copy) 复制所有列。所以嵌套的make_unionFunctionTransformer(copy) 会为每个功能制作多个副本。这似乎很奇怪,除了ExtraTreesClassifier 它将具有“引导”功能选择的效果。另请参阅Issue 581,了解为什么首先生成这些;基本上,添加副本在堆叠集成中很有用,TPOT 使用的遗传算法意味着它需要先生成这些副本,然后再探索此类集成。那里建议对遗传算法进行更多迭代可能会清除此类伪影。

    在那之后事情就很简单了,我猜:你执行一个单变量特征选择,并拟合一个额外的随机树分类器。

    【讨论】:

    • 谢谢本!有道理!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-12-13
    • 2018-01-27
    • 2011-07-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多