📄 datamining.cs
字号:
/// <returns>
/// A System.Data.DataSet in-memory database containing the Market Based Analysis results in
/// the TransactionsTable, ItemsetTable, SubsetTable, Rulestable.
/// </returns>
/// <remarks>
/// See <see cref="VISUAL_BASIC_DATA_MINING_NET.DataAccessLayer.GetTransactionsData"/>
/// </remarks>
public Data MarketBasedAnalysis(double supportCount, double minimumConfidence, string connectionString, string dataSource, CommandType dataSourceCommand)
{
Database database = new Database();
ItemsetCandidate Item = new ItemsetCandidate();
this.AP = new APriori.Apriori();
this.AP.ProgressMonitorEvent += new ProgressMonitorEventHandler(this.OnProgressMonitoringCompletedEvent);
this.dataBase = database.GetTransactionsData(connectionString, dataSource, dataSourceCommand);
database.Transactions = this.dataBase;
this.transactionsCount = this.dataBase.TransactionTable.Count;
supportCount = ((supportCount / 100) * this.transactionsCount);
minimumConfidence = (minimumConfidence / 100);
string support = "SupportCount >= " + supportCount + " AND Level > 1";
string sort = "SupportCount, Level";
ItemsetCandidate uniqueItems = AP.CreateOneItemsets(database);
AP.AprioriGenerator(uniqueItems,database,Convert.ToInt32(supportCount));
ItemsetArrayList [] keys = database.GetItemset(support, sort);
string msg = "Creating Frequent Subsets for Items";
ProgressMonitorEventArgs e = new ProgressMonitorEventArgs(1,100,95,"DataMining.MarketBasedAnalysis(3)",msg );
this.OnProgressMonitorEvent(e);
for(int counter = 0; counter < keys.Length; counter++)
{
AP.CreateItemsetSubsets(0,keys[counter], null, database);
}
msg = "Completed C#.NET Data Mining Market Based Analysis";
e = new ProgressMonitorEventArgs(1,100,100,"DataMining.MarketBasedAnalysis(3)",msg );
this.OnProgressMonitorEvent(e);
//Set the public properties of the class
this.minimumSupportCount = supportCount;
this.minimumConfidence = minimumConfidence;
this.connectionString = connectionString;
this.dataSource = dataSource;
this.dataSourceCommand = dataSourceCommand;
//return the database of transactions
return this.dataBase;
}
/// <summary>
/// Retrieves the results of a Market Based Analysis as an in-memory cache of data from an XML file.
/// </summary>
/// <param name="supportCount">
/// The support count is the number of transactions containing a set of items.
/// </param>
/// <param name="minimumConfidence">
/// The confidence of two sets of items A and B is the number of transactions supported by A and B
/// divided by the number of transactions divided by A and vice versa.
/// <example>
/// confidence[A->B) = (number of transactions containing both A and B) / (number of transactions
/// containing only A)
/// </example>
/// </param>
/// <param name="xmlFilePath">
/// The path to an XML file containing transaction data.
/// </param>
/// <returns>
/// A System.Data.DataSet in-memory database containing the Market Based Analysis results in
/// the TransactionsTable, ItemsetTable, SubsetTable, Rulestable.
/// </returns>
/// <remarks>
/// See <see cref="VISUAL_BASIC_DATA_MINING_NET.DataAccessLayer.GetXMLData"/>
/// </remarks>
public Data MarketBasedAnalysis(double supportCount, double minimumConfidence, string xmlFilePath)
{
Database database = new Database();
ItemsetCandidate Item = new ItemsetCandidate();
this.AP = new APriori.Apriori();
this.AP.ProgressMonitorEvent += new ProgressMonitorEventHandler(this.OnProgressMonitoringCompletedEvent);
this.dataBase = database.GetXMLData(xmlFilePath);
database.Transactions = this.dataBase;
this.transactionsCount = this.dataBase.TransactionTable.Count;
supportCount = ((supportCount / 100) * this.transactionsCount);
minimumConfidence = (minimumConfidence / 100);
string support = "SupportCount >= " + supportCount + " AND Level > 1";
string sort = "SupportCount, Level";
ItemsetCandidate uniqueItems = AP.CreateOneItemsets(database);
AP.AprioriGenerator(uniqueItems,database,Convert.ToInt32(supportCount));
ItemsetArrayList [] keys = database.GetItemset(support, sort);
string msg = "Creating Frequent Subsets for Items";
ProgressMonitorEventArgs e = new ProgressMonitorEventArgs(1,100,95,"DataMining.MarketBasedAnalysis(3)",msg );
this.OnProgressMonitorEvent(e);
for(int counter = 0; counter < keys.Length; counter++)
{
AP.CreateItemsetSubsets(0,keys[counter], null, database);
}
msg = "Completed C#.NET Data Mining Market Based Analysis";
e = new ProgressMonitorEventArgs(1,100,100,"DataMining.MarketBasedAnalysis(3)",msg );
this.OnProgressMonitorEvent(e);
//Set the public properties of the class
this.minimumSupportCount = supportCount;
this.minimumConfidence = minimumConfidence;
this.xmlFilePath = xmlFilePath;
//return the database of transactions
return this.dataBase;
}
public Data MarketBasedAnalysis(double supportCount, double minimumConfidence, Data transactionsData)
{
Database database = new Database();
ItemsetCandidate Item = new ItemsetCandidate();
this.AP = new APriori.Apriori();
this.AP.ProgressMonitorEvent += new ProgressMonitorEventHandler(this.OnProgressMonitoringCompletedEvent);
this.dataBase = transactionsData;
database.Transactions = this.dataBase;
this.transactionsCount = this.dataBase.TransactionTable.Count;
supportCount = ((supportCount / 100) * this.transactionsCount);
minimumConfidence = (minimumConfidence / 100);
string support = "SupportCount >= " + supportCount + " AND Level > 1";
string sort = "SupportCount, Level";
ItemsetCandidate uniqueItems = AP.CreateOneItemsets(database);
AP.AprioriGenerator(uniqueItems,database,Convert.ToInt32(supportCount));
ItemsetArrayList [] keys = database.GetItemset(support, sort);
string msg = "Creating Frequent Subsets for Items";
ProgressMonitorEventArgs e = new ProgressMonitorEventArgs(1,100,95,"DataMining.MarketBasedAnalysis(3)",msg );
this.OnProgressMonitorEvent(e);
for(int counter = 0; counter < keys.Length; counter++)
{
AP.CreateItemsetSubsets(0,keys[counter], null, database);
}
msg = "Completed C#.NET Data Mining Market Based Analysis";
e = new ProgressMonitorEventArgs(1,100,100,"DataMining.MarketBasedAnalysis(3)",msg );
this.OnProgressMonitorEvent(e);
//Set the public properties of the class
this.minimumSupportCount = supportCount;
this.minimumConfidence = minimumConfidence;
//return the database of transactions
return this.dataBase;
}
/// <summary>
/// A DataView for viewing the results of the Market Based Analysis Data Mining results.
/// </summary>
/// <returns>
///A System.Data.DataView object for viewing the tables of the Market Based Analysis tables.
/// </returns>
public DataView ViewDataMiningAnalysis()
{
double minimumconfidence = ((this.minimumConfidence) * 100);
string confidence = "Confidence >= " + minimumconfidence + "%";
viewDataMiningAnalysis = new DataView(this.dataBase.Tables["ViewRulesTable"], confidence, "Confidence", DataViewRowState.CurrentRows);
return viewDataMiningAnalysis;
}
/// <summary>
/// A DataView for viewing the contents of any of the Market Based Analysis tables.
/// </summary>
/// <param name="tableName">
/// The name of the table containing the results to be viewed with the DataView object.
/// </param>
/// <returns>
/// A System.Data.DataView object for viewing the tables of the Market Based Analysis tables.
/// </returns>
public DataView ViewDataMiningAnalysis(string tableName)
{
viewDataMiningAnalysis = new DataView(this.dataBase.Tables[tableName]);
return viewDataMiningAnalysis;
}
/// <summary>
/// A DataView for viewing the contents of any of the Market Based Analysis tables.
/// </summary>
/// <param name="tableName">
/// The name of the table containing the results to be viewed with the DataView object.
/// </param>
/// <param name="sortColumn">
/// The name of the table column to use in sorting the data to be viewed.
/// </param>
/// <returns>
/// A System.Data.DataView object for viewing the tables of the Market Based Analysis tables.
/// </returns>
public DataView ViewDataMiningAnalysis(string tableName, string sortColumn)
{
viewDataMiningAnalysis = new DataView(this.dataBase.Tables[tableName],"",sortColumn,DataViewRowState.CurrentRows);
return viewDataMiningAnalysis;
}
/// <summary>
/// A DataView for viewing the contents of any of the Market Based Analysis tables.
/// </summary>
/// <param name="tableName">
/// The name of the table containing the results to be viewed with the DataView object.
/// </param>
/// <returns>
/// A System.Data.DataView object for viewing the tables of the Market Based Analysis tables.
/// </returns>
public DataView ViewDataMiningAnalysis(string tableName, double minimumConfidence)
{
string confidence = "Confidence >= " + minimumConfidence;
viewDataMiningAnalysis = new DataView(this.dataBase.Tables[tableName], confidence, "Confidence", DataViewRowState.CurrentRows);
return viewDataMiningAnalysis;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -