Skip to content
Snippets Groups Projects
Select Git revision
0 results

prolog_mlpack_library

  • Clone with SSH
  • Clone with HTTPS
  • user avatar
    Jakhes authored
    5f09d318
    History
    Name Last commit Last update
    src
    .gitignore
    Makefile
    README.md
    test_all.pl

    Prolog mlpack Library

    Getting started

    To use the main file with the connected BayesianLinearRegression functions in sicstus use:

    compile(main).

    while running sicstus in the repository or:

    ['/full_path_to_main/main'].

    when running sicstus in a different directory.

    Compile the main files with Makefile

    To compile the main files just use make

    if your full path to splfr is not /usr/local/sicstus4.7.1/bin/splfr

    then you will have to exchange this Makefile line with your splfr path.

    splfr=/usr/local/sicstus4.7.1/bin/splfr

    Compile the main files manually

    To compile the main files manually with splfr you need to use the following command in the repository folder.

    The flags

    -lmlpack (for mlpack intern libarys like armadillo)

    -lstdc++ (for stdI/O and vector etc.)

    --struct (for the sicstus struct library)

    splfr -lmlpack -lstdc++ -cxx --struct main.pl main.cpp mlpack-3.4.2/src/mlpack/methods/bayesian_linear_regression/bayesian_linear_regression.cpp 

    or if you dont have a command shortcut for splfr use

    /path_to_splfr/splfr -lmlpack -lstdc++ -cxx --struct main.pl main.cpp mlpack-3.4.2/src/mlpack/methods/bayesian_linear_regression/bayesian_linear_regression.cpp 

    Available functions

    For a list of the functions the BayesianLinearRegression method has go to

    Mlpack BayesianLinearRegression documentation

    For Arrays i have added predicates for converting Prolog lists [] to the needed float_array type and when receiving an array also Predicates for converting it to a normal list.

    A Matrix is just a long list with the added information how many row it has.

    In both cases when using the array in a function the size must also be send, since after sending or receiving it you cant get the length of the array from itself.

    for example:

    train :-
            convert_list_to_float_array([5.1,3.5,1.4,4.9,3.0,1.4,4.7,3.2,1.3,4.6,3.1,1.5],3, array(Xsize, Xrownum, X)),
            convert_list_to_float_array([0.2,0.2,0.2,0.2], array(Ysize, Y)),
            train(X,Xsize, Xrownum,Y, Ysize).

    here the longer list representing a Matrix gets convertet into an array X with the row amount, and the smaller list into an array Y. And they get used in the foreign function from BayesianLinearRegression that takes an Matrix of points and a vector of targets to train the model.