Loading...
 

CX_NEURAL_NETWORK

CX_NEURAL_NETWORK

Class hierarchy
Description:

This class enables the handling of self-generated neural networks. To be able to use this class, the cxAI DLL must be specified in the classix.ini.

The implementation of the neural networks is based on the OpenNN Library: https://www.opennn.net/

Currently supported forms of data transfer for training and testing: CX_EXCEL_XML, ObjectListView, Collection, Vector.
Within the given data set, the types of the following list are supported:

Supported data types:

It is important to note the correct formatting of the columns of the training and test data. Each column must correspond to exactly one format (each item in the above list of supported data types corresponds to a format). For columns of values with units, the cells in this column must all have the same base unit. During training, the most frequently used unit of the column is used to determine the default unit, which serves as a reference for converting all cells of the column and all future input values of this column.

The currently supported net types are Regression and Classification. Nets of type Regression are suitable for models with numerical output (see above list of supported data types), where the magnitude of the output values correlates to the inputs (e.g. price of a house depends on the properties of the house). Classification type networks are suitable for models with categorising output (see above list of supported data types), i.e. outputs in the form of clearly distinguishable classes (e.g. type of a flower depends on the properties of the flower). Basically, one must be clear: the use of neural networks is generally suitable for models in which the inputs are not orthogonal to each other, i.e. are mutually correlated. In addition, (at least some) inputs must be correlated with the output(s). For models where the inputs are mutually independent, a statistical approach is more appropriate.

Regression:

RegressionCropped

A regression type network consists of 5 layers:

  1. Scaling layer: normalises the inputs (using f(xi) = xi/σ + μ/σ), μ is the mean of the inputs, σ is the standard deviation of the inputs.
  2. Perceptron layer (tanh): fits weights(w) and bias(b) to training data: f(Σixiwi + b), activation function f is tanh (tangent hyperbolicus)
  3. Perceptron layer (linear): fits weights(w) and bias(b) to training data: f(Σixiwi + b), activation function f is linear x) = x)
  4. Unscaling layer: scales values to the definition range of the output (using f(xi) = 2xi/(max-min) -(max+min)/(max-min, max is maximum output value, min is minimum output value
  5. Bounding layer: limits values to a certain range (by default the limits of a float (-3.402823466 * 1038, 3.402823466 * 1038)).
Classification:

ClassificationCropped

A Classification type network consists of 4 layers:

  1. Scaling layer: normalises the inputs (using f(xi) = xi/σ + μ/σ), μ is the mean of the inputs, σ is the standard deviation of the inputs.
  2. Perceptron layer (tanh): fits weights(w) and bias(b) to training data: f(Σixiwi + b), activation function f is tanh (tangent hyperbolicus)
  3. perceptron layer (tanh)
  4. Probabilistic Layer: maps neuron signal strengths to probabilities for output categories. If there are more than two output categories, Softmax is used: f(xi) =exi/Σjexj. If there are exactly two output categories, Sigmoid is used: f(x) = 1/(1 + e-x)
Excel:
Code example:
Var(network) CreateTransObject(CX_NEURAL_NETWORK) -> network // CX_NEURAL_NETWORK erzeugen "Regression" network Put(Parameter("NetworkType")) // Netztyp setzen ............................................... Var(excel) CreateTransObject(CX_EXCEL_XML) -> excel // CX_EXCEL_XML erzeugen "train_and_test_data.xlsx" excel Call(LoadFromFile) ............................................... 1 2 [ 1 2 ] [ 3 4 ] excel network Call(Train) // Netz wird mit Excel-Daten trainiert: Worksheet 1, Zeilen ab Reihe 2 einlesen, Spalte 1 und 2 als Input, Spalte 3 und 4 als Output ............................................... 2 2 [ "col1" "col2" ] [ "col3" "col4" ] // Netz wird mit Excel-Daten getestet: excel network Call(Test) Worksheet 2, Zeilen ab Reihe 2 einlesen, Spalte 1 und 2 als Input, Spalte 3 und 4 als Output ............................................... [ 50$ 2.45 ] network Call(Apply) // Netz ermittelt Output von gegebenem Input
ObjectListView:
Code example:
Var(network) CreateTransObject(CX_NEURAL_NETWORK) -> network // CX_NEURAL_NETWORK erzeugen "Regression" network Put(Parameter("NetworkType")) // Netztyp setzen ............................................... // ObjectListView definieren coll FillObox(, listViewObjects) // coll ist bspw. Collection aus CX_PERSON [ Path(CX_PERSON::wages.wagesValue) HEADER T("Einkommen", "Income") ] SetFormat [ Path(CX_PERSON::old.counter) HEADER T("Alter", "Age") ] SetFormat [ Path(CX_PERSON::own.counter) HEADER T("Anzahl Autos", "Number of cars") ] SetFormat ............................................... 2 // Netz wird mit ObjectListView trainiert: [ "Einkommen" "Alter" ] Zeilen ab Reihe 2 einlesen, [ "Anzahl Autos" ] Einkommen und Alter als Input, Widget(, listViewObjects) network Call(Train) Anzahl Autos als Output // Alternativ können Zugriffspfade zur Kennzeichnung von Input und Output genutzt werden: 2 [ Path(CX_PERSON::wages.wagesValue) Path(CX_PERSON::old.counter) ] [ Path(CX_PERSON::own.counter) ] Widget(, listViewObjects) network Call(Train) ............................................... 2 [ 1 2 ] [ 3 ] // Netz wird mit ObjectListView getestet: Widget(, listViewObjects) network Call(Test) Zeilen ab Reihe 2 einlesen, Spalte 1 und 2 als Input, Spalte 3 als Output ............................................... [ 50$ 2.45 ] network Call(Apply) // Netz ermittelt Output von gegebenem Input
Collection:
Code example:
Var(network) CreateTransObject(CX_NEURAL_NETWORK) -> network // CX_NEURAL_NETWORK erzeugen "Regression" network Put(Parameter("NetworkType")) // Netztyp setzen ............................................... Var(trainColl, testColl) CreateTransCollection -> trainColl ... // Collection mit Trainingsdaten CreateTransCollection -> testColl ... // Collection mit Testdaten ............................................... [ Path(CX_PERSON::wages.wagesValue) // Netz wird mit Collection trainiert: Path(CX_PERSON::old.counter) ] Pfade zum Einkommen und Alter als Input [ Path(CX_PERSON::own.counter) ] Pfad zur Anzahl an Autos als Output trainColl network Call(Train) ............................................... [ CX_PERSON::wages.wagesValue // Netz wird mit Collection getestet: CX_PERSON::old.counter ] Pfade zum Einkommen und Alter als Input [ CX_PERSON::own.counter ] Pfad zur Anzahl an Autos als Output testColl network Call(Test) ............................................... [ 50€ 39 ] network Call(Apply) // Netz ermittelt Output von gegebenem Input
Vector:
Code example:
Var(network) CreateTransObject(CX_NEURAL_NETWORK) -> network // CX_NEURAL_NETWORK erzeugen "Regression" network Put(Parameter("NetworkType")) // Netztyp setzen ............................................... Var(trainVec, testVec) [ CX_PERSON CX_PERSON ... ] -> trainVec // Vektor aus Objekten [ [ 32€ 46 2 ] [ 14€ 25 0 ] ... ] -> testVec // Vektor aus datenenthaltenden Vektoren ............................................... [ Path(CX_PERSON::wages.wagesValue) // Netz wird mit Vektor aus Objekten trainiert: Path(CX_PERSON::old.counter) ] Pfade zum Einkommen und Alter als Input [ Path(CX_PERSON::own.counter) ] Pfad zur Anzahl an Autos als Output trainVec network Call(Train) ............................................... [ 0 1 ] [ 2 ] testVec network Call(Test) // Netz wird mit Vektor aus Vektoren getestet: Spalte 0 und 1 als Input, Spalte 2 als Output ............................................... [ 50€ 39 ] network Call(Apply) // Netz ermittelt Output von gegebenem Input

Then the trained network can be saved and loaded as follows:

"model.xml" network Call(SaveToFile) // Volles Netz in XML-Format speichern ............................................... "model.xml" network Call(LoadFromFile) // Volles Netz aus Datei laden
VECTORCX_FLOATReturn: accuracy (RMSE) of the neural network given data.
Method Dictionary (MDI)
FunctionMA*ParameterReturnShort description
Apply VECTOROBJECTVECTOROBJECTReturn: Output of the neural network with given input.
GetInputColumnCategories INTEGERVECTORSTRINGQuery categories of the selected input column
GetInputColumnCount
238887
INTEGERINTEGERQuery number of input columns
GetInputColumnJSON
238902
INTEGERANY* | INVALIDQuery own data from input column
GetInputColumnNames VECTORML_STRINGQuery names of the input columns
GetInputColumnType
238884
INTEGERSTRINGQuery internal OpenNN column type of the selected input column
GetInputColumnTypeID
238884
INTEGERINTEGERQuery ClassiX type of the selected input column
GetInputColumnUnitName
238884
INTEGERML_STRINGQuery the name of the most common unit in the selected input column
GetNetworkJSON
238902
ANY* | INVALIDQuery own data from the network
GetOutputColumnCategories INTEGERVECTORSTRINGQuery categories of the selected output column
GetOutputColumnCount
238887
INTEGERINTEGERQuery number of output columns
GetOutputColumnJSON
238902
INTEGERANY* | INVALIDQuery own data from output column
GetOutputColumnNames VECTORML_STRINGQuery names of the output columns
GetOutputColumnType
238884
INTEGERSTRINGQuery internal OpenNN column type of the selected output column
GetOutputColumnTypeID
238884
INTEGERINTEGERQuery ClassiX type of the selected output column
GetOutputColumnUnitName
238884
INTEGERML_STRINGQuery the name of the most common unit in the selected output column
InputColumnParameter*STRING Read/write access to the input column parameters of the neural network.
InputParameter*STRING Read/write access to the input parameters of the neural network.
LayerParameter*STRING Read/write access to the layer parameters of the neural network.
LoadFromFile STRING Loads neural net from the file in the given path.
OutputColumnParameter*STRING Read/write access to the output column parameters of the neural network.
OutputParameter*STRING Read/write access to the output parameters of the neural network.
OutputTypeParameter*STRING Read/write access to the output type parameters of the neural network.
Parameters*STRING Read/write access to all parameters of the neural network
SetInputColumnJSON
238902
ANY* | INVALID, INTEGER Store own data in input column
SetInputColumnNames VECTORML_STRING Set names of input columns
SetNetworkJSON
238902
ANY* | INVALID Store own data on the network
SetOutputColumnJSON
238902
ANY* | INVALID, INTEGER Store own data in output column
SetOutputColumnNames VECTOR< <ML_STRING >VECTORML_STRINGSet names of output columns
SaveToFile STRING Save the full network architecture in XML format in the given path.
SeedRand INTEGER Set start value for the random number generator used in trainingSet start value for the random number generator used in trainingSet start value for the random number generator used in training
Test Different (see test)VECTOR<CX_FLOAT>
Train different (see Train)

CX_JSON_OBJECT

VECTOR<INTEGER>

VECTORINTEGER
Trains the neural network using supplied data.
Return: evolution of the training and validation error. Return: Evolution of the training and validation error and row indices of the data used for validation.

* MA = member access function,
greyed out = inherited function