【问题标题】:Why concatenate features in machine learning?为什么要在机器学习中连接特征?
【发布时间】:2020-11-04 02:11:39
【问题描述】:

我正在学习 Microsoft ML 框架,但对为什么需要连接功能感到困惑。在 Microsoft 的鸢尾花示例中: https://docs.microsoft.com/en-us/dotnet/machine-learning/tutorials/iris-clustering

...特征被连接起来:

string featuresColumnName = "Features";
var pipeline = mlContext.Transforms
    .Concatenate(featuresColumnName, "SepalLength", "SepalWidth", "PetalLength", "PetalWidth")
    ...

为了进行线性回归等计算,是否将多个特征视为一个特征?如果是这样,这如何准确?幕后发生了什么?

【问题讨论】:

  • 列包含您需要处理的所有记录的值。连接使数据从列到表中,您可以将每一行视为一条记录。记录是您需要进行聚类或回归的数据点。
  • 处理一个组合的数据点会比处理多个独立的点更准确吗?如果其中一列(特征)对预测结果只有一点帮助怎么办。通过将其与其他功能相结合,您是否没有赋予它与其他功能同等的权重?

标签: machine-learning


【解决方案1】:

根据official documentation

连接是必要的,因为训练器将特征向量作为 输入。

它本质上是将单独列形式的特征转换为单列特征向量。特征值本身保持不变;只有它们的格式和类型被改变。通过这个example更清楚:

改造前:

        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 的评论?数据应该在预训练数据准备步骤中连接,还是应该保持不同的数据或列分开?有关系吗?
猜你喜欢
  • 2019-07-14
  • 2012-03-28
  • 1970-01-01
  • 2020-10-07
  • 1970-01-01
  • 2021-05-12
  • 2017-10-26
  • 2020-10-16
  • 1970-01-01
相关资源
最近更新 更多