Objects: Integer;
Objects: Integer;
The Objects property determines a field index of the data source containing analyzed elements.
Index of the field containing transactions is determined by the IDmAssociationRules.Transactions property.
Executing the example requires that the repository contains a table containing data for analysis with the DM_TABLE identifier. A regular report with the DM_REPORT_RES identifier where analysis results will be loaded must also be present.
Add links to the Metabase, Ms, Report, Stat, Tab system assemblies.
Sub UserARules;
Var
mb: IMetabase;
TableDS: IDmTableDataSource;
ReportDS: IDmReportDataSource;
Method: IDmMethod;
Report: IPrxReport;
Shs: IPrxSheets;
Sheet: ITabSheet;
DM: IDmAssociationRules;
Reports: IDmReports;
DmReport: IDmReport;
Begin
mb := MetabaseClass.Active;
// Create calculation method
Method := (New DataMiningMethod.Create) As IDmMethod;
// Specify method type
Method.Kind := DmMethodKind.AssociationRules;
// Create table data source
TableDS := (New TableDataSource.Create) As IDmTableDataSource;
// Determine source table
TableDS.Table := mb.ItemByID("DM_TABLE").Bind;
// Set input data source
Method.InputDataSource := TableDS;
// Create a data source that is a regular report
ReportDS := (New ReportDataSource.Create) As IDmReportDataSource;
// Set data consumer
Method.OutputDataSource := ReportDS;
// Set up calculation method parameters
DM := Method.Details As IDmAssociationRules;
// determine transactions
DM.Transactions := 1;
// Determine objects
DM.Objects := 2;
// Determine value of minimum support (in percents)
DM.UseSupportPercent := True;
DM.MinimumSupport := 20;
// Determine minimum confidence level
DM.MinimumConfidence := 0.45;
// Determine minimum size of the set
DM.MinimumFrequentItemsetSize := 2;
// Perform analysis and output results
Reports := Method.Execute;
DmReport := reports.FindByType(DmReportType.AssociationRules);
ReportDS := DmReport.Generate;
ReportDS.TabSheet.View.Selection.SelectAll;
ReportDS.TabSheet.View.Selection.Copy;
// Get regular report to which results will be unloaded
Report := mb.ItemByID("DM_REPORT_RES").Edit As IPrxReport;
Shs := Report.Sheets;
Shs.Clear;
Sheet := (Shs.Add("", PrxSheetType.Table) As IPrxTable).TabSheet;
Sheet.Table.Paste;
Sheet.Columns(0, 1).AdjustWidth;
Sheet.Rows(0, 1).AdjustHeight;
Report.Sheets.Item(0).Name := ReportDS.Caption;
// Save unloaded data
(Report As IMetabaseObject).Save;
End Sub UserARules;
After executing the example the Association Analysis data mining will be executed for data from the DM_TABLE table, data mining results will be unloaded to the DM_REPORT_RES report.
The requirements and result of the Fore.NET example execution match with those in the Fore example.
Imports Prognoz.Platform.Interop.Ms;
Imports Prognoz.Platform.Interop.Report;
Imports Prognoz.Platform.Interop.Stat;
Imports Prognoz.Platform.Interop.Tab;
…
Public Shared Sub Main(Params: StartParams);
Var
mb: IMetabase;
TableDS: IDmTableDataSource;
ReportDS: IDmReportDataSource;
Method: IDmMethod;
Report: IPrxReport;
Shs: IPrxSheets;
Sheet: ITabSheet;
DM: IDmAssociationRules;
Reports: IDmReports;
DmReport: IDmReport;
Begin
mb := Params.Metabase;
// Create calculation method
Method := (New DataMiningMethod.Create()) As IDmMethod;
// Specify method type
Method.Kind := DmMethodKind.dmmkAssociationRules;
// Create table data source
TableDS := (New TableDataSource.Create()) As IDmTableDataSource;
// Determine source table
TableDS.Table := mb.ItemByID["DM_TABLE"].Bind();
// Set input data source
Method.InputDataSource := TableDS;
// Create a data source that is a regular report
ReportDS := (New ReportDataSource.Create()) As IDmReportDataSource;
// Set data consumer
Method.OutputDataSource := ReportDS;
// Set up calculation method parameters
DM := Method.Details As IDmAssociationRules;
// determine transactions
DM.Transactions := 1;
// Determine objects
DM.Objects := 2;
// Determine value of minimum support (in percents)
DM.UseSupportPercent := True;
DM.MinimumSupport := 20;
// Determine minimum confidence level
DM.MinimumConfidence := 0.45;
// Determine minimum size of the set
DM.MinimumFrequentItemsetSize := 2;
// Perform analysis and output results
Reports := Method.Execute();
DmReport := reports.FindByType[DmReportType.drtAssociationRules];
ReportDS := DmReport.Generate();
ReportDS.TabSheet.View.Selection.SelectAll();
ReportDS.TabSheet.View.Selection.Copy();
// Get regular report to which results will be unloaded
Report := mb.ItemByID["DM_REPORT_RES"].Edit() As IPrxReport;
Shs := Report.Sheets;
Shs.Clear();
Sheet := (Shs.Add("", PrxSheetType.pstTable) As IPrxTable).TabSheet;
Sheet.Table.Paste();
Sheet.Columns[0, 1].AdjustWidth(-1, -1);
Sheet.Rows[0, 1].AdjustHeight(-1, -1);
Report.Sheets.Item[0].Name := ReportDS.Caption;
// Save unloaded data
(Report As IMetabaseObject).Save();
End Sub;
See also: