ForecastingMethod: DmForecastingMethod;
ForecastingMethod: Prognoz.Platform.Interop.Ms.DmForecastingMethod;
The ForecastingMethod property returns the method used for value forecasting.
The number of forecasting periods is determined by the IDmForecasting.ForecastingPointsCount 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 Dimensions, Metabase, Ms, Report, Stat, Tab system assemblies.
Sub UserF;
Var
mb: IMetabase;
ReportDS: IDmReportDataSource;
TableDS: IDmTableDataSource;
Method: IDmMethod;
Report: IPrxReport;
Shs: IPrxSheets;
Sheet: ITabSheet;
DM: IDmForecasting;
i: Integer;
Attrs: Array Of Integer;
Reports: IDmReports;
DmReport: IDmReport;
Begin
mb := MetabaseClass.Active;
// Create calculation method
Method := (New DataMiningMethod.Create) As IDmMethod;
// Specify method type
Method.Kind := DmMethodKind.ExponentialSmoothing;
// 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 IDmForecasting;
// Set factors that influence analysis
Attrs := New Integer[3];
For i := 0 To 2 Do
Attrs[i] := i + 1;
End For;
DM.Attributes := Attrs;
If DM.ForecastingMethod = DmForecastingMethod.ExponentialSmoothing Then
Debug.WriteLine("Exponential smoothing");
// Set number of forecasting periods
DM.ForecastingPointsCount := 20;
// Determine calendar frequency
DM.Level := DimCalendarLevel.Year;
// Set data field containing labels for X axis
DM.Labels := 0;
// Add strings for forecasting results
ReportDS.AddResultRows(20);
End If;
// Perform analysis and output results
Reports := Method.Execute;
DmReport := reports.FindByType(DmReportType.Forecasting);
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 UserF;
After executing the example value forecasting using exponential smoothing is executed for data from the DM_TABLE, analysis results are loaded 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.Dimensions;
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;
ReportDS: IDmReportDataSource;
TableDS: IDmTableDataSource;
Method: IDmMethod;
Report: IPrxReport;
Shs: IPrxSheets;
Sheet: ITabSheet;
DM: IDmForecasting;
i: Integer;
Attrs: Array Of Integer;
Reports: IDmReports;
DmReport: IDmReport;
Begin
mb := Params.Metabase;
// Create calculation method
Method := (New DataMiningMethod.Create()) As IDmMethod;
// Specify method type
Method.Kind := DmMethodKind.dmmkExponentialSmoothing;
// 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 IDmForecasting;
// Set factors that influence analysis
Attrs := New Integer[3];
For i := 0 To 2 Do
Attrs[i] := i + 1;
End For;
DM.Attributes := Attrs;
If DM.ForecastingMethod = DmForecastingMethod.dmfmExponentialSmoothing Then
System.Diagnostics.Debug.WriteLine("Exponential smoothing");
// Set number of forecasting periods
DM.ForecastingPointsCount := 20;
// Determine calendar frequency
DM.Level := DimCalendarLevel.dclYear;
// Set data field containing labels for X axis
DM.Labels := 0;
// Add strings for forecasting results
ReportDS.AddResultRows(20);
End If;
// Perform analysis and output results
Reports := Method.Execute();
DmReport := reports.FindByType[DmReportType.drtForecasting];
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: