Giter Club home page Giter Club logo

ml2sql's Introduction

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

ml2sql's People

Contributors

maxemanuel avatar matthiaas avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.