我的解决方案在这里:http
://www.mediafire.com/?rzrhvc71musz793
我在第 238 行文件 Apriori.cs 中收到错误“其他信息:索引超出范围。必须是非负数且小于集合的大小”
private List<Rule> GenerateRules()
{
var rules = new List<Rule>();
foreach (var item in _allFrequentItems)
{
if (item.val.Count > 1)
{
int maxCombinationLength = item.val.Count / 2;
GenerateCombination(item.val, maxCombinationLength, ref rules);
}
}
return rules;
}
private void GenerateCombination(List<int> item, int combinationLength, ref List<Rule> rules)
{
int itemLength = item.Count;
switch (itemLength)
{
case 2:
AddItem(new List<int>(){item[0]}, item, ref rules);
break;
case 3:
for (int i = 0; i < itemLength; i++)
{
AddItem(new List<int>{item[i]}, item, ref rules);
}
break;
default:
for (int i = 0; i < itemLength; i++)
{
GetCombinationRecursive(new List<int>() { item[i] }, item, combinationLength, ref rules);
}
break;
}
}
在 GenerateRules() 我有检查 item.val.Count>1 和 GenerateCombination itemLength = item.Count..为什么在我的调试 item.Count =1 , itemLength =3????