Skip to content
Snippets Groups Projects
Select Git revision
  • benchmark-tools
  • postgres-lambda
  • master default
  • REL9_4_25
  • REL9_5_20
  • REL9_6_16
  • REL_10_11
  • REL_11_6
  • REL_12_1
  • REL_12_0
  • REL_12_RC1
  • REL_12_BETA4
  • REL9_4_24
  • REL9_5_19
  • REL9_6_15
  • REL_10_10
  • REL_11_5
  • REL_12_BETA3
  • REL9_4_23
  • REL9_5_18
  • REL9_6_14
  • REL_10_9
  • REL_11_4
23 results

postgres-lambda-diff

  • Clone with SSH
  • Clone with HTTPS
  • ML Compiler

    A Compiler that compiles a declarative language for machine learning in either Hyperscript, Postgresql, or Python


    Dependencies

    Project generation and build:

    • (CMake and Make) or only Make

    Compiler with C++11 support:

    • g++ 5.5.0

    Libraries:

    • ANTLR4
    • csvkit (install by "sudo apt install python3-csvkit")

    Building

    Using Cmake and Make (recommended):

    mkdir build && cd build
    cmake ..
    make

    Stores executable in bin folder.


    Running the Compiler

    Run the following to run the compiler:

    ./bin/compiler <inputFile> <outputFile> <targetLanguage> <flags>

    The target language can be either postgres, hyper, or python. "flags" can consist of either "buildcsv", "usemod" or both.

    Since Hyper and Postgres can only load csv files in the correct format, the flag "buildcsv" allows the compiler the create a new modifeid csv that can be processed by the database system. (The new csv file created has the file ending .ml.csv)

    To allow the compiler to create code that uses the newly created csv file that was created by using the "buildcsv" flag.

    Notice, you may use the flag "buildcsv" only when you compil code the first time or have made any changes to the csv file, since using the "buildcsv" takes some time to precess the csv file.


    Installing ANTLR4

    To install ANTRL4 run the following commands in terminal:

    wget http://www.antlr.org/download/antlr4-cpp-runtime-4.7.1-source.zip
    wget http://www.antlr.org/download/antlr-4.7.1-complete.jar
    sudo mv antlr-4.7.1-complete.jar /usr/local/lib/antlr-4.7.1-complete.jar
    sudo apt-get install uuid-dev -y
    sudo apt install cmake -y
    unzip antlr4-cpp-runtime-4.7.1-source.zip -d antlr4-cpp-runtime
    cd antlr4-cpp-runtime && mkdir build && mkdir run && cd build
    cmake ..
    make -j8
    sudo make install
    LD_LIBRARY_PATH=/usr/local/lib
    export LD_LIBRARY_PATH
    sudo ldconfig -v

    Server

    The server accepts JSON data of the following form (default port 5000):

    {"lang": "python", "code": "A=[[2]] \n print '%',A"}

    Possible destination languages are {python, postgres, hyper} (case insensitive) The answer looks like:

    {"lang": "PYTHON","result": "import numpy as np
    
    
    def main():
    
        A = np.array([ np.array([ 2])])
        print( '{}'.format(  A))
    
    main()
    "}
    

    Dockerfile

    To run ml2sql in a docker container

    docker build -t ml2sql .
    docker run --rm -p 5000:5000 ml2sql