【问题标题】:Classifying data into known patterns with accord.net使用accord.net 将数据分类为已知模式
【发布时间】:2018-05-03 02:58:05
【问题描述】:

首先我要说的是,我对机器学习的了解非常非常有限。但我想我可以利用我的情况来学习它。

我的问题域演化出 18 种众所周知的模式。这些模式一旦在系统中创建,就会按照用户进入的顺序分配给用户。

现在的重点是从不同的系统导入用户数据,其中不包含模式信息。这些模式的存在是为了确保每个用户都能获得一份工作计划。对于被导入的用户,我必须通过观察他们的日程来弄清楚他们的模式是什么。重要的是要注意,他们当前的日程安排不完全符合任何已知模式是很常见的,所以我要做的就是找到最有可能的已知模式。

通读 Accord 的分类分类器,我认为序列分类可以很好地解决这个问题,所以我尝试使用它,如下:

class Program
{
    static void Main(string[] args)
    {
        int[][] inputs =
        {
            new[] {1, 1, 2, 2, 2, 2, 2, 1, 1, 1, 1, 3, 3, 3, 3, 3, 1, 1}, //pattern 1
            new[] {1, 1, 1, 2, 2, 2, 2, 2, 1, 1, 1, 1, 3, 3, 3, 3, 3, 1}, //pattern 2
            new[] {1, 1, 1, 1, 2, 2, 2, 2, 2, 1, 1, 1, 1, 3, 3, 3, 3, 3}, //pattern 3
            new[] {3, 1, 1, 1, 1, 2, 2, 2, 2, 2, 1, 1, 1, 1, 3, 3, 3, 3}, //pattern 4
            new[] {3, 3, 1, 1, 1, 1, 2, 2, 2, 2, 2, 1, 1, 1, 1, 3, 3, 3}, //pattern 5
            new[] {3, 3, 3, 1, 1, 1, 1, 2, 2, 2, 2, 2, 1, 1, 1, 1, 3, 3}, //pattern 6
            new[] {3, 3, 3, 3, 1, 1, 1, 1, 2, 2, 2, 2, 2, 1, 1, 1, 1, 3}, //pattern 7
            new[] {3, 3, 3, 3, 3, 1, 1, 1, 1, 2, 2, 2, 2, 2, 1, 1, 1, 1}, //pattern 8
            new[] {1, 3, 3, 3, 3, 3, 1, 1, 1, 1, 2, 2, 2, 2, 2, 1, 1, 1}, //pattern 9
            new[] {1, 1, 3, 3, 3, 3, 3, 1, 1, 1, 1, 2, 2, 2, 2, 2, 1, 1}, //pattern 10
            new[] {1, 1, 1, 3, 3, 3, 3, 3, 1, 1, 1, 1, 2, 2, 2, 2, 2, 1}, //pattern 11
            new[] {1, 1, 1, 1, 3, 3, 3, 3, 3, 1, 1, 1, 1, 2, 2, 2, 2, 2}, //pattern 12
            new[] {2, 1, 1, 1, 1, 3, 3, 3, 3, 3, 1, 1, 1, 1, 2, 2, 2, 2}, //pattern 13
            new[] {2, 2, 1, 1, 1, 1, 3, 3, 3, 3, 3, 1, 1, 1, 1, 2, 2, 2}, //pattern 14
            new[] {2, 2, 2, 1, 1, 1, 1, 3, 3, 3, 3, 3, 1, 1, 1, 1, 2, 2}, //pattern 15
            new[] {2, 2, 2, 2, 1, 1, 1, 1, 3, 3, 3, 3, 3, 1, 1, 1, 1, 2}, //pattern 16
            new[] {2, 2, 2, 2, 2, 1, 1, 1, 1, 3, 3, 3, 3, 3, 1, 1, 1, 1}, //pattern 17
            new[] {1, 2, 2, 2, 2, 2, 1, 1, 1, 1, 3, 3, 3, 3, 3, 1, 1, 1} //pattern 18
        };

        int[] outputs =
        {
            0, 
            1,
            2,
            3,
            4,
            5,
            6,
            7,
            8,
            9,
            10,
            11,
            12,
            13,
            14,
            15,
            16,
            17
        };

        int[][] actualData =
        {
            new[] {3,3,1,1,1,1,2,2,2,2,2,1,1,1,1,3,3,3} // should be pattern 5
        };

        // Create the Hidden Conditional Random Field using a set of discrete features
        var function = new MarkovDiscreteFunction(states: 3, symbols: 3, outputClasses: 18);
        var classifier = new HiddenConditionalRandomField<int>(function);

        // Create a learning algorithm
        var teacher = new HiddenResilientGradientLearning<int>(classifier)
        {
            MaxIterations = 1000
        };

        // Run the algorithm and learn the models
        teacher.Learn(inputs, outputs);

        // Compute the classifier answers for the given inputs
        int[] answers = classifier.Decide(actualData);

        foreach (var answer in answers)
        {
            Console.WriteLine(answer);
        }
    }
}

我希望输出是模式 5,因为它们完全匹配,但事实并非如此。我尝试通过重复模式并将输入与正确的模式相关联来使用更多输入来训练模型。实际数据包含超过 18 个值。但它并没有帮助它匹配它,实际上让它“更糟”了。

在我的理想情况下,程序将能够始终正确猜测已知模式并在不匹配的数据中找到最佳候选者。我是不是在这里选错了路?

【问题讨论】:

    标签: c# machine-learning classification hidden-markov-models accord.net


    【解决方案1】:

    示例代码引发了 Accord 3.8 的异常。如果您更改以下行,它将在 18 次迭代后执行并预测正确的类:

    var function = new MarkovDiscreteFunction(states: 18, symbols: 18, outputClasses: 18)
    

    【讨论】:

      猜你喜欢
      • 2019-11-12
      • 2018-08-12
      • 1970-01-01
      • 2023-03-29
      • 1970-01-01
      • 1970-01-01
      • 2016-07-14
      • 2019-09-04
      • 2016-06-19
      相关资源
      最近更新 更多