This is the documentation for the Project Prolog MLpack Library.
Here you can find documentaion on the used Datatypes, a detailed documentation for the available Methods and for the helper files.
Quickstart
How to get the project running:
-
Clone the project onto your system
-
Have MLpacks system Version installed
-
Have SICStus prolog installed (at least 4.7.1)
-
Have Ensmallen C++ Libary installed
(Required by the Methods Linear_SVM, LMNN, Logistic_regression and NCA)
-
Change the SPLFR_PATH Variable in the root folder Makefile to your absolute path to the SICStus splfr tool
-
Run the root folder Makefile
After that you can use each Method by loading their module with SICStus e.g.
:- use_module('path/to/.../src/methods/dbscan/dbscan.pl').
If you want to edit the Project then the steps are almost the same except you should also install the Eclipse IDE SICStus integration Spider.
Since it makes writing and running the prolog Code easier.
To test all methods there is a test_all.pl file in the root directory that you can compile with SICStus and then call :
run_tests.
Just make sure the SICStus Toplevel is the prolog-mlpack-libary root directory. (If not it will cause the predicate open/3, for opening files, to not find the iris2.csv)
Data Types
To connect mlpack and SICStus prolog i used the c interface of SICStus which can convert prolog datatypes to c datatypes and vise versa.
Here you can find a list of the available conversion types.
Extra Symbols
-
'+' is the symbol for inupting a concret value from prolog to c/c++
-
'-' is the symbol for inputing a variable from prolog to c/c++ that then gets assigned a value in one c side, that then can be used on the prolog side.
-
'[-]'
is the symbol for an output value from c/c++ to prolog, in its function very similar to -.
Data Types
-
Integer
are the normal numbers 1,2,3...
c/c++ : SP_integer
-
Float
are the numbers like 0.0, 1.2, 5.7...
full definition prolog : float_32 shortend to float32 since this has the correct Byte size for its counter part double
c/c++ : double
-
String
are just atoms like: word, hello, nice7...
c/c++ : char const *
-
Integer(bool)
there are no bool atoms in Prolog that could translate to bool in c, so i chose integer numbers as replacement with 1 = true and 0(or any other int number) = false
c/c++ : SP_integer (1)true, (0)false
-
Matrix
is defined a just a long list/vector where you specify its row numbers
Internally it converts a normal prolog list like [1, 2, 3] to a float_array with the help of some of the predicates in helper.pl.
To be then able to convert it into a c++ array, with the c Interface.
input :
- prolog : [1,2,3,1,2,3,...], DataDimensionality(Lenght of each DataPoint)
- c/c++ : float * array, SP_integer size, SP_integer rows
output :
- prolog : [[1,2,3],[1,2,3],...], DataDimensionality(Lenght of each DataPoint)
- c/c++ : float **array, SP_integer *colums, SP_integer *rows
-
Vector
When inputing or recieving a vector you just get a normal Prolog List.
Internaly that List gets converted to an float_array from the SICStus struct module to be then able to convert it into a c++ array, with the c Interface.
prolog : [1,2,3,...]
c/c++ : float *array, SP_integer size
Prolog Methods
Here you can find all the documentation sites for the implemented mlpack methods of this libraray.
In the project they can be found under :
/src/methods/name_of_method
Classification
- Adaboost
- Decision_Stump
- Decision_Tree
- Hoeffding_Tree
- Linear_SVM
- Logistic_Regression
- NBC
- Perceptron
- Random_Forest
- Softmax_Regression
Regression
Clustering
- DBScan
- GMM
- KMeans
- Mean_Shift
Geometry
Preproccessing
- Preproccess_Split
- Preproccess_Binarize
- Preproccess_Describe
- Preproccess_Scale
- Preproccess_One_Hot_Encoding
- Image_Converter