This page is part of the documentation for the Machine Learning Database.
It is a static snapshot of a Notebook which you can play with interactively by trying MLDB online now.
It's free and takes 30 seconds to get going.
pymldb
Tutorial¶Interactions with MLDB occurs via a REST API. Interacting with a REST API over HTTP from a Notebook interface can be a little bit laborious if you're using a general-purpose Python library like requests
directly, so MLDB comes with a Python library called pymldb
to ease the pain.
The pymldb
library includes a class called Connection
. The recommended usage pattern is shown here:
from pymldb import Connection
mldb = Connection("http://localhost")
mldb.get("/v1/types")
#keyword arguments to get() are appended to the GET query string
mldb.get("/v1/types", x="y")
#dictionaries arguments to put() and post() are sent as JSON via PUT or POST
mldb.put("/v1/datasets/sample", {"type": "sparse.mutable"} )
Here we create a dataset and insert two rows of two columns into it:
mldb.put( "/v1/datasets/demo", {"type":"sparse.mutable"})
mldb.post("/v1/datasets/demo/rows", {"rowName": "first", "columns":[["a",1,0],["b",2,0]]})
mldb.post("/v1/datasets/demo/rows", {"rowName": "second", "columns":[["a",3,0],["b",4,0]]})
mldb.post("/v1/datasets/demo/commit")
df = mldb.query("select * from demo")
print type(df)
df
Check out the other Tutorials and Demos.