private void FrequentProducts(int product) { var apriori = new Apriori(Tree); FrequentItem[] items = apriori.GetFrequentItems(product); var sb = new StringBuilder(); sb.AppendLine($"Frequent product for: {product}. Find {items.Length} results;"); foreach (var frequentItem in items.OrderByDescending(x => x.Confidence)) { sb.AppendLine(frequentItem.ToString()); } string path = Path.Combine(DirectoryPath, $"{TreeName}-frequentproducts-{product}.txt"); File.WriteAllText(path, sb.ToString()); }