IDmGradientBoostedTrees.LearningRate

Syntax

LearningRate: Double;

Description

The LearningRate property determines learning rate.

Comments

Available values within the (0; 1] range.

Default value is 0.1.

Examples

Executing the example requires that the repository contains:

Add links to the Metabase, Ms, Report, Stat, Tab, Ui system assemblies.

Sub UserGradBoost;
Var
    mb: IMetabase;
    TableDS: IDmTableDataSource;
    ReportDS: IDmReportDataSource;
    Method: IDmMethod;
    Report: IPrxReport;
    Shs: IPrxSheets;
    Sheet: ITabSheet;
    GradBoost: IDmGradientBoostedTrees;
    Binning: IDmField;
    i: Integer;
    Attrs: Array 
Of Integer;
    Target: IUiCommandTarget;
    Reports: IDmReports;
    DmReport: IDmReport;
Begin
    mb := MetabaseClass.Active;
    
// Create table data source
    TableDS := (New TableDataSource.Create) As IDmTableDataSource;
    
// Determine source table
    TableDS.Table := mb.ItemByID("DM_TABLE").Bind;
    
// Determine that data is located in table columns
    TableDS.DataInColumns := True;
    
// Create data source which is a regular report
    ReportDS := (New ReportDataSource.Create) As IDmReportDataSource;
    
// Get regular report
    Report := mb.ItemByID("DM_REPORT_RES").Edit As IPrxReport;
    Shs := Report.Sheets;
    Shs.Clear;
    
// Create page to load results
    Sheet := (Shs.Add("", PrxSheetType.Table) As IPrxTable).TabSheet;
    
// Determine page to which data will be loaded    
    ReportDS.TabSheet := Sheet;
    
// Determine data range
    ReportDS.Range := Sheet.Cell(00);
    ReportDS.AddResultColumn(
"Category");
    
// Create calculation method
    Method := (New DataMiningMethod.Create) As IDmMethod;
    
// Determine method type
    Method.Kind := DmMethodKind.GradientBoostedTrees;
    
// Set input data source
    Method.InputDataSource := TableDS;
    
// Set data consumer
    Method.OutputDataSource := ReportDS;
    
// Set up calculation method parameters
    GradBoost := Method.Details As IDmGradientBoostedTrees;
    
// Set coefficient of learning speed
    GradBoost.LearningRate := 0.15;
    
// Set number of iterations
    GradBoost.NumberOfIterations := 5;
    
// Determine column for analysis
    GradBoost.Target := TableDS.FieldCount - 1;
    Debug.WriteLine(
"Column for key impact factors analysis:");
    Debug.WriteLine(
" - " + TableDS.Field(GradBoost.Target).Name);
    
// Set factors impacting analysis
    Attrs := New Integer[TableDS.FieldCount - 2];
    Debug.WriteLine(
"Factors that impact analysis:");
    
For i := 0 To Attrs.Length - 1 Do
        Attrs[i] := i + 
1;
        Binning := TableDS.Field(i + 
1);
        Debug.WriteLine(Binning.Index.ToString + 
". " + Binning.Name);
        Debug.Indent;
        
// Set parameters of the Binning procedure
        If Binning.IsNumerical Then
            Binning.BinningType := BinningMethod.EqualDepth;
            Binning.CategoriesCount := 
4;
            Binning.TreatNanAsCategory := 
False;
            Debug.WriteLine(
"number of non empty values: " + Binning.NonEmptyCount.ToString);
        
End If;
        
Select Case Binning.FieldType
            
Case DmFieldType.Date: Debug.WriteLine("data type: date");
            
Case DmFieldType.Integer: Debug.WriteLine("data type: integer");
            
Case DmFieldType.Numeric: Debug.WriteLine("data type: numeric");
            
Case DmFieldType.String: Debug.WriteLine("data type: string");
        
End Select;
        Debug.WriteLine(
"data source: " + Binning.DataSource.Caption);
        
Select Case Binning.ExplanatoryType
            
Case DmExplanatoryType.Continuous: Debug.WriteLine("factor type: quantitative");
            
Case DmExplanatoryType.Ordered: Debug.WriteLine("factor type: ordinal");
            
Case DmExplanatoryType.Categorical: Debug.WriteLine("factor type: categorical");
        
End Select;
        Debug.Unindent;
    
End For;
    GradBoost.Attributes := Attrs;
    
// Analyze and load results
    Reports := Method.Execute;
    DmReport := reports.FindByType(DmReportType.Forest);
    ReportDS := DmReport.Generate;
    Debug.WriteLine(
"Report title: " + DmReport.Caption);
    Debug.WriteLine(
"Analysis type: " + GradBoost.DisplayName);
    ReportDS.TabSheet.View.Selection.SelectAll;
    ReportDS.TabSheet.View.Selection.Copy;
    Sheet.Table.Paste;
    Sheet.Columns(
01).AdjustWidth;
    Sheet.Rows(
01).AdjustHeight;
    Report.Sheets.Item(
0).Name := ReportDS.Caption;
    (Report 
As IMetabaseObject).Save;
    
// Open regular report containing analysis results
    Target := WinApplication.Instance.GetObjectTarget(Report As IMetabaseObject);
    Target.Execute(
"Object.Open"Null);
End Sub UserGradBoost;

After executing the example the Decision Tree Ensembles method performs data mining using the Gradient Boosting algorithm for data from the DM_TABLE table and applies the Binning procedure for numeric data. Analysis parameters will be displayed in the console window. Analysis results will be loaded to the DM_REPORT_RES report.

See also:

IDmGradientBoostedTrees