为什么在机器学习中要连接特征?

5
我正在学习微软的ML框架,但是对于为什么需要连接特征感到困惑。在微软的鸢尾花示例中,如下所示: https://learn.microsoft.com/en-us/dotnet/machine-learning/tutorials/iris-clustering 特征被连接起来:
string featuresColumnName = "Features";
var pipeline = mlContext.Transforms
    .Concatenate(featuresColumnName, "SepalLength", "SepalWidth", "PetalLength", "PetalWidth")
    ...

在像线性回归这样的计算中,是否将多个特征视为单个特征进行处理?如果是,这如何保证准确性?背后发生了什么?


1
列包含你需要处理的所有记录的值。拼接将来自列的数据组合成一个表,您可以将每行视为记录。记录是您需要进行聚类或回归的数据点。 - tintin
2
处理合并的数据点是否比处理多个独立点不够准确?如果其中一个列(特征)在预测结果方面只有轻微的帮助,通过将其与其他特征结合,您是否没有给予它与其他特征相等的权重? - Sandy
1个回答

2
根据官方文档,连接是必要的,因为训练器将特征向量作为输入。连接将以单独列的形式呈现的特征转换为特征向量的单列形式。特征值本身保持不变,只是其格式和类型发生了变化。可以通过这个示例更加清楚的理解:
转换之前:
        var samples = new List<InputData>()
        {
            new InputData(){ Feature1 = 0.1f, Feature2 = new[]{ 1.1f, 2.1f,
                3.1f }, Feature3 = 1 },

            new InputData(){ Feature1 = 0.2f, Feature2 = new[]{ 1.2f, 2.2f,
                3.2f }, Feature3 = 2 },

            new InputData(){ Feature1 = 0.3f, Feature2 = new[]{ 1.3f, 2.3f,
                3.3f }, Feature3 = 3 },

            new InputData(){ Feature1 = 0.4f, Feature2 = new[]{ 1.4f, 2.4f,
                3.4f }, Feature3 = 4 },

            new InputData(){ Feature1 = 0.5f, Feature2 = new[]{ 1.5f, 2.5f,
                3.5f }, Feature3 = 5 },

            new InputData(){ Feature1 = 0.6f, Feature2 = new[]{ 1.6f, 2.6f,
                3.6f }, Feature3 = 6 },
        };

之后:

    //  "Features" column obtained post-transformation.
    //  0.1 1.1 2.1 3.1 1
    //  0.2 1.2 2.2 3.2 2
    //  0.3 1.3 2.3 3.3 3
    //  0.4 1.4 2.4 3.4 4
    //  0.5 1.5 2.5 3.5 5
    //  0.6 1.6 2.6 3.6 6

你能详细说明一下OP的评论吗?在预训练数据准备步骤中,数据应该被连接起来还是应该保持不同的数据片段或列分开?这有关系吗? - Jess

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接