我soluton這裏:http://www.mediafire.com/?rzrhvc71musz793
我得到錯誤「的更多信息:索引超出範圍必須大於集合的大小非負少。」在線238個文件Apriori.cs先驗在C#中 - 錯誤:索引超出範圍
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..Why在我的調試item.Count = 1,itemLength = 3 ????
哪一行是行238? –
AddItem(新列表 {item [i]},item,ref rules);在情況3:是行238 –
我想'AddItem'(你沒有給我們看)操縱其第二個參數('item')並從列表中刪除項目。 –