CX_NEURAL_NETWORK 
Class hierarchy
- CX_CLASS
- CX_SIMPLE
- CX_TERMED
- CX_EXPANDABLE
- CX_NEURAL_NETWORK
- CX_EXPANDABLE
- CX_TERMED
- CX_SIMPLE
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:
- Numeric data types:
- Numeric value without unit (INTEGER, CX_INTEGER, CX_NUMERIC, CX_FRACTION, CX_FLOAT).
- Numeric value with unit (CX_VALUE)
- Percent (CX_PERCENT)
- Time (CX_TIME)
- Date (CX_DATE)
- Categorising data types:
- String (STRING, CX_STRING, ML_STRING)
- Boolean (CX_BOOLEAN)
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:
A regression type network consists of 5 layers:
- Scaling layer: normalises the inputs (using f(xi) = xi/σ + μ/σ), μ is the mean of the inputs, σ is the standard deviation of the inputs.
- Perceptron layer (tanh): fits weights(w) and bias(b) to training data: f(Σixiwi + b), activation function f is tanh (tangent hyperbolicus)
- Perceptron layer (linear): fits weights(w) and bias(b) to training data: f(Σixiwi + b), activation function f is linear x) = x)
- 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
- Bounding layer: limits values to a certain range (by default the limits of a float (-3.402823466 * 1038, 3.402823466 * 1038)).
Classification:
A Classification type network consists of 4 layers:
- Scaling layer: normalises the inputs (using f(xi) = xi/σ + μ/σ), μ is the mean of the inputs, σ is the standard deviation of the inputs.
- Perceptron layer (tanh): fits weights(w) and bias(b) to training data: f(Σixiwi + b), activation function f is tanh (tangent hyperbolicus)
- perceptron layer (tanh)
- 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
| Function | MA* | Parameter | Return | Short description | ||
|---|---|---|---|---|---|---|
| Apply | VECTOROBJECT | VECTOROBJECT | Return: Output of the neural network with given input. | |||
| GetInputColumnCategories | INTEGER | VECTORSTRING | Query categories of the selected input column | |||
| GetInputColumnCount 238887 | INTEGER | INTEGER | Query number of input columns | |||
| GetInputColumnJSON 238902 | INTEGER | ANY* | INVALID | Query own data from input column | |||
| GetInputColumnNames | VECTORML_STRING | Query names of the input columns | ||||
| GetInputColumnType 238884 | INTEGER | STRING | Query internal OpenNN column type of the selected input column | |||
| GetInputColumnTypeID 238884 | INTEGER | INTEGER | Query ClassiX type of the selected input column | |||
| GetInputColumnUnitName 238884 | INTEGER | ML_STRING | Query the name of the most common unit in the selected input column | |||
| GetNetworkJSON 238902 | ANY* | INVALID | Query own data from the network | ||||
| GetOutputColumnCategories | INTEGER | VECTORSTRING | Query categories of the selected output column | |||
| GetOutputColumnCount 238887 | INTEGER | INTEGER | Query number of output columns | |||
| GetOutputColumnJSON 238902 | INTEGER | ANY* | INVALID | Query own data from output column | |||
| GetOutputColumnNames | VECTORML_STRING | Query names of the output columns | ||||
| GetOutputColumnType 238884 | INTEGER | STRING | Query internal OpenNN column type of the selected output column | |||
| GetOutputColumnTypeID 238884 | INTEGER | INTEGER | Query ClassiX type of the selected output column | |||
| GetOutputColumnUnitName 238884 | INTEGER | ML_STRING | Query 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_STRING | Set 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 training | Set start value for the random number generator used in training | Set start value for the random number generator used in training | ||
| Test | Different (see test) | VECTOR<CX_FLOAT> | VECTORCX_FLOATReturn: accuracy (RMSE) of the neural network given data.||||
| Train | different (see Train) | 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