gpt4 book ai didi

c# - 使用 accord.net 将数据分类为已知模式

转载 作者:太空宇宙 更新时间:2023-11-03 14:58:48 30 4
gpt4 key购买 nike

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

我的问题领域演变出了 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 个值。但这并没有帮助它匹配它,实际上让它变得“更糟”。

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

最佳答案

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

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

关于c# - 使用 accord.net 将数据分类为已知模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47382721/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com