close×
Steema Documentation / TeeBI VCL/FMX / Tutorials

Machine-Learning

Machine Learning Algorithms

Included in TeeBI are two native algorithms developed in Delphi language, with more to come:

-DecisionTree (unit BI.Algorithm.DecisionTree)

-Clustering (unit BI.Algorithm.Clustering)

Example of use by code:

uses BI.Algorithm.DecisionTree;
var Tree: TDecisionTree;
Tree:= TDecisionTree.Create( Orders );
Tree.Target:= Orders['Price'];
Tree.Attributes:= [ Orders['Quantity'], Orders['OrderDate'] ];
Tree.Calculate;

In this case of a TDecisionTree, the algorithm output is a tree of nodes that can be iterated and used in different ways, like displaying it:

Memo1.Lines:= GetTreeRules( Tree.Root );

R integration

R is a free language ecosystem for statistical computing and machine-learning.

http://www.r-project.org

With "R" language integrated with TeeBI, it is possible to invoke any "R" script or algorithm, calling it passing TDataItem data and obtaining the results into other TDataItem objects.

The BI.Plugins.R.pas unit contains the current implementation of the class to interact with R.

There are two ways to interact with R, one is using disk files invoking R command line.

The other way (much better) is using native direct access to R dll using the opaR api.

https://github.com/SigmaSciences/opaR

Python / Scikit-learn integration

Similar to above R integration, the BI.Plugins.Python.pas unit contains classes to interact with Python.

The integration is done using an adapted subset of the excellent Python4Delphi project:

http://github.com/pyscripter/python4delphi

Several popular algorithms from Scikit-learn / numpy are included, with more to come.

Both R and Python algorithm classes derive from a common TModel class (in BI.Algorithm.Model.pas unit) that includes methods to split source data into train/test subsets, evaluate a "Confusion Matrix", return the Predicted values as a TDataItem, etc.