cs-pattern-discovery
1.0.1
dotnet add package cs-pattern-discovery --version 1.0.1
NuGet\Install-Package cs-pattern-discovery -Version 1.0.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="cs-pattern-discovery" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add cs-pattern-discovery --version 1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: cs-pattern-discovery, 1.0.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install cs-pattern-discovery as a Cake Addin #addin nuget:?package=cs-pattern-discovery&version=1.0.1 // Install cs-pattern-discovery as a Cake Tool #tool nuget:?package=cs-pattern-discovery&version=1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
cs-pattern-discovery
Pattern Discovery implemented in C#
Usage
Apriori
The sample codes shows how to use Apriori to find the frequent item sets from a transaction database:
using System;
using System.Collections.Generic;
using PatternDiscovery.FrequentPatterns;
namespace PatternDiscovery.FT
{
public class FTApriori
{
public static void Example()
{
List<Transaction<char>> database = new List<Transaction<char>>();
database.Add(new Transaction<char>('a', 'c', 'd', 'e') { ID = 10 });
database.Add(new Transaction<char>('a', 'b', 'e') { ID = 20 });
database.Add(new Transaction<char>('b', 'c', 'e') { ID = 30 });
database.Add(new Transaction<char>('b', 'c', 'e') { ID = 40 });
Apriori<char> method = new Apriori<char>();
ItemSets<char> itemsets = method.MinePatterns(database, 0.5, new List<char>() { 'a', 'b', 'c', 'd', 'e' });
for (int i = 0; i < itemsets.Count; ++i)
{
ItemSet<char> itemset = itemsets[i];
Console.WriteLine(itemset);
}
}
}
}
Apriori with DB Partitioning
The sample codes shows how to use Apriori with DB Partitioning to find the frequent item sets from a transaction database:
using System;
using System.Collections.Generic;
using PatternDiscovery.FrequentPatterns;
namespace PatternDiscovery.FT
{
public class FTAprioriWithDbPartitioning
{
public static void Example()
{
List<Transaction<char>> database = new List<Transaction<char>>();
database.Add(new Transaction<char>('a', 'c', 'd', 'e') { ID = 10 });
database.Add(new Transaction<char>('a', 'b', 'e') { ID = 20 });
database.Add(new Transaction<char>('b', 'c', 'e') { ID = 30 });
database.Add(new Transaction<char>('b', 'c', 'e') { ID = 40 });
AprioriWithDbPartitioning<char> method = new AprioriWithDbPartitioning<char>();
ItemSets<char> itemsets = method.MinePatterns(database, 0.5, new List<char>() { 'a', 'b', 'c', 'd', 'e' }, 3);
for (int i = 0; i < itemsets.Count; ++i)
{
ItemSet<char> itemset = itemsets[i];
Console.WriteLine(itemset);
}
}
}
}
FP-Growth
The sample codes shows how to use fp-growth to mine patterns and discover closed patterns:
using System;
using System.Collections.Generic;
using PatternDiscovery.FrequentPatterns;
namespace PatternDiscovery.FT
{
public class FTFPGrowth
{
public static void Example()
{
List<Transaction<char>> database = new List<Transaction<char>>();
database.Add(new Transaction<char>('f', 'a', 'c', 'd', 'g', 'i', 'm', 'p') { ID = 100 });
database.Add(new Transaction<char>('a', 'b', 'c', 'f', 'l', 'm', 'o') { ID = 200 });
database.Add(new Transaction<char>('b', 'f', 'h', 'j', 'o', 'w') { ID = 300 });
database.Add(new Transaction<char>('b', 'c', 'k', 's', 'p') { ID = 400 });
database.Add(new Transaction<char>('a', 'f', 'c', 'e', 'l', 'p', 'm', 'n') { ID = 500 });
Console.WriteLine("Using FPGrowth");
DateTime start_time = DateTime.UtcNow;
FPGrowth<char> method = new FPGrowth<char>();
ItemSets<char> fis = method.MinePatterns(database, Transaction<char>.ExtractDomain(database), 0.4);
DateTime end_time = DateTime.UtcNow;
Show(fis);
Console.WriteLine("Time Span: {0} ms", (end_time - start_time).TotalMilliseconds);
Console.WriteLine("Finding Closed Pattern");
Show(method.FindMaxPatterns(database, Transaction<char>.ExtractDomain(database), 0.4));
Console.WriteLine("Using baseline Apriori");
start_time = DateTime.UtcNow;
Apriori<char> baseline_method = new Apriori<char>();
fis = method.MinePatterns(database, Transaction<char>.ExtractDomain(database), 0.4);
end_time = DateTime.UtcNow;
Show(fis);
Console.WriteLine("Time Span: {0} ms", (end_time - start_time).TotalMilliseconds);
}
private static void Show(ItemSets<char> fis)
{
for (int i = 0; i < fis.Count; ++i)
{
Console.WriteLine("{0} (Support: {1})", fis[i], fis[i].Support);
}
}
}
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET Framework | net461 is compatible. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
This package has no dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.0.1 | 1,183 | 5/2/2018 |
Pattern Discovery Algorithms such as Apriori and FP-Growth in .NET 4.6.1