marketbasedanalysis.cs
来自「一个经典的apriori算法(c#实现)」· CS 代码 · 共 465 行 · 第 1/2 页
CS
465 行
this.buttonDataConnection.Text = "&Data Connection";
this.buttonDataConnection.Click += new System.EventHandler(this.buttonDataConnection_Click);
//
// dataGridViewAnalysisResult
//
this.dataGridViewAnalysisResult.AlternatingBackColor = System.Drawing.Color.Gainsboro;
this.dataGridViewAnalysisResult.DataMember = "";
this.dataGridViewAnalysisResult.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.dataGridViewAnalysisResult.HeaderForeColor = System.Drawing.SystemColors.ControlText;
this.dataGridViewAnalysisResult.Location = new System.Drawing.Point(16, 24);
this.dataGridViewAnalysisResult.Name = "dataGridViewAnalysisResult";
this.dataGridViewAnalysisResult.ReadOnly = true;
this.dataGridViewAnalysisResult.Size = new System.Drawing.Size(768, 496);
this.dataGridViewAnalysisResult.TabIndex = 1;
this.dataGridViewAnalysisResult.Navigate += new System.Windows.Forms.NavigateEventHandler(this.dataGridViewAnalysisResult_Navigate);
//
// groupBoxProgressMonitor
//
this.groupBoxProgressMonitor.Controls.AddRange(new System.Windows.Forms.Control[] {
this.groupBox2,
this.buttonOK});
this.groupBoxProgressMonitor.Location = new System.Drawing.Point(16, 536);
this.groupBoxProgressMonitor.Name = "groupBoxProgressMonitor";
this.groupBoxProgressMonitor.Size = new System.Drawing.Size(976, 88);
this.groupBoxProgressMonitor.TabIndex = 1;
this.groupBoxProgressMonitor.TabStop = false;
//
// groupBox2
//
this.groupBox2.Controls.AddRange(new System.Windows.Forms.Control[] {
this.lblProgressBar,
this.progressBarMonitor});
this.groupBox2.Location = new System.Drawing.Point(8, 8);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(880, 72);
this.groupBox2.TabIndex = 2;
this.groupBox2.TabStop = false;
//
// lblProgressBar
//
this.lblProgressBar.Location = new System.Drawing.Point(16, 48);
this.lblProgressBar.Name = "lblProgressBar";
this.lblProgressBar.Size = new System.Drawing.Size(856, 16);
this.lblProgressBar.TabIndex = 1;
//
// progressBarMonitor
//
this.progressBarMonitor.Location = new System.Drawing.Point(8, 16);
this.progressBarMonitor.Name = "progressBarMonitor";
this.progressBarMonitor.Size = new System.Drawing.Size(864, 24);
this.progressBarMonitor.TabIndex = 0;
//
// buttonOK
//
this.buttonOK.Font = new System.Drawing.Font("Tahoma", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.buttonOK.ForeColor = System.Drawing.Color.DarkBlue;
this.buttonOK.Location = new System.Drawing.Point(893, 37);
this.buttonOK.Name = "buttonOK";
this.buttonOK.TabIndex = 1;
this.buttonOK.Text = "&Analyze";
this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click);
//
// groupBoxViewTables
//
this.groupBoxViewTables.Location = new System.Drawing.Point(8, 80);
this.groupBoxViewTables.Name = "groupBoxViewTables";
this.groupBoxViewTables.Size = new System.Drawing.Size(160, 264);
this.groupBoxViewTables.TabIndex = 2;
this.groupBoxViewTables.TabStop = false;
//
// MarketBasedAnalysis
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 14);
this.ClientSize = new System.Drawing.Size(1000, 629);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.groupBoxProgressMonitor,
this.groupBox1});
this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "MarketBasedAnalysis";
this.Text = "Market Based Analysis";
this.TopMost = true;
this.Load += new System.EventHandler(this.MarketBasedAnalysis_Load);
this.groupBox1.ResumeLayout(false);
this.groupBoxCommands.ResumeLayout(false);
this.groupBoxSettings.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.dataGridViewAnalysisResult)).EndInit();
this.groupBoxProgressMonitor.ResumeLayout(false);
this.groupBox2.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// The main entry point for this application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new MarketBasedAnalysis());
}
private void MarketBasedAnalysis_Load(object sender, System.EventArgs e)
{
}
private void buttonDataConnection_Click(object sender, System.EventArgs e)
{
connectionDialogBox = new ConnectionDialogBox();
connectionDialogBox.ShowDialog(this);
}
private void buttonOK_Click(object sender, System.EventArgs e)
{
this.DMS = new DataMining();
this.DMS.ProgressMonitorEvent += new ProgressMonitorEventHandler(this.OnProgressMonitorEvent);
if((ClassInfo.DataStorage == ClassInfo.DataStorageLocation.Database) && (ClassInfo.DataStorageModel == ClassInfo.DataModel.TransactionsTable))
{
this.dataAnalysis = DMS.MarketBasedAnalysis(ClassInfo.MinimumSupport, ClassInfo.MinimumConfidence,ClassInfo. ConnectionString,"TransactionsTable",CommandType.TableDirect);
}
else if (ClassInfo.DataStorage == ClassInfo.DataStorageLocation.XMLFile)
{
this.dataAnalysis = DMS.MarketBasedAnalysis(ClassInfo.MinimumSupport, ClassInfo.MinimumConfidence,ClassInfo. XMLFilePath);
}
else if((ClassInfo.DataStorage == ClassInfo.DataStorageLocation.Database) && (ClassInfo.DataStorageModel == ClassInfo.DataModel.NorthwindDatabase ))
{
dts = new NorthwindDTS();
dts.LoadNorthwindwindProducts(ClassInfo.ConnectionString);
dts.LoadNorthwindwindOrders(ClassInfo.ConnectionString);
dts.LoadNorthwindwindOrderDetails(ClassInfo.ConnectionString);
orders = dts.GetOrders();
this.dataAnalysis = DMS.MarketBasedAnalysis(ClassInfo.MinimumSupport,ClassInfo.MinimumConfidence,orders);
}
if(this.dataAnalysis != null)
{
this.dataView = new ViewData();
this.dataAnalysis.Tables.Add(this.dataView.CreateViewRulesTable(ClassInfo.MinimumConfidence,this.dataAnalysis).Copy());
this.dataAnalysis.Tables.Add(this.dataView.CreateViewSubsetTable(this.dataAnalysis).Copy());
this.dataGridViewAnalysisResult.DataSource = DMS.ViewDataMiningAnalysis("ViewRulesTable","Confidence desc");
}
}
private void dataGridViewAnalysisResult_Navigate(object sender, System.Windows.Forms.NavigateEventArgs ne)
{
}
private void txtMinimumSupport_TextChanged(object sender, System.EventArgs e)
{
}
private void txtMinimumSupport_Validating(object sender, System.ComponentModel.CancelEventArgs e)
{
if (txtMinimumSupport.Text.Length == 0)
{
MessageBox.Show(this,"Please enter a minimum support between 0% and 100%",ClassInfo.AppCaption,MessageBoxButtons. OK ,MessageBoxIcon.Information);
}
else if (txtMinimumSupport.Text.Length > 0)
{
minimumSupport = txtMinimumSupport.Text.Trim();
minimumSupportLength = minimumSupport.Length;
if (minimumSupport.EndsWith("%"))
{
ClassInfo.MinimumSupport = Convert.ToDouble(minimumSupport.Substring(0, minimumSupportLength-1));
}
else
{
ClassInfo.MinimumSupport = Convert.ToDouble(minimumSupport.Substring(0, minimumSupportLength));
}
}
}
private void txtMinimumConfidence_Validating(object sender, System.ComponentModel.CancelEventArgs e)
{
if (txtMinimumConfidence.Text.Length == 0)
{
MessageBox.Show(this,"Please enter a minimum confidence between 0% and 100%",ClassInfo.AppCaption, MessageBoxButtons.OK ,MessageBoxIcon.Information);
}
else if (txtMinimumConfidence.Text.Length > 0)
{
minimumConfidence = txtMinimumConfidence.Text.Trim();
minimumConfidenceLength = minimumConfidence.Length;
if (minimumConfidence.EndsWith("%"))
{
ClassInfo.MinimumConfidence = Convert.ToDouble(minimumConfidence.Substring(0, minimumConfidenceLength-1));
}
else
{
ClassInfo.MinimumConfidence = Convert.ToDouble(minimumConfidence.Substring(0, minimumConfidenceLength));
}
}
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?