GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||
GeezerVison is showing docs.voltdb.com — VoltDB and Machine Learning DocumentationVoltDB and Machine LearningV1.0 October, 2018 1. IntroductionThe VoltDB Machine Learning utility simplifies the process of implementing machine learning models in VoltDB. The initial offering includes the model loader, voltml, that converts a machine learning model into an executable process as a VoltDB user-defined function (UDF). The utility currently supports PMML exported models only. Support for other types of machine learning systems (H20, for example) may be added in the future. There are two steps to preparing your systems to use the Machine Learning utility:
Once installed, using the utility is a very simple two-step process:
The following sections describe both of these processes. 2. Getting StartedThe VoltDB Machine Learning utility comes as a compressed tar file. Before you can use the utility, you need to download the kit, install it, and prepare the servers. The following sections describe these steps. Note that these preliminary steps only need to be completed once. 2.1. Downloading and Installing the KitThe first step is to download and unpack the kit:
For example, the following command unpacks the utility to a folder in your home directory: $ tar -zxvf voltdb-ml-v1.0.tar.gz -C $HOME You can run the voltml utility by itself directly from the installation folder, with or without a full VoltDB database installation. Alternately, you can copy the files for the machine learning utility into an existing VoltDB installation. This option is useful if you install voltml on an existing VoltDB server because:
To install voltml into an existing VoltDB installation after unpacking the kit, simply copy the
contents of the $ cd ~/voltdb-ml-v1.0 $ cp -r ./lib ~/voltdb/ $ cp -r ./bin ~/voltdb/ 2.2. Preparing the ServersThe second step is to prepare the VoltDB servers that will be using the resulting user-defined function. To do this,
copy the following files from the
For example, if voltml is installed in $ cd ~/voltml/lib $ cp * ~/voltdb/lib/ $ scp * srv2:voltdb/lib/ $ scp * srv3:voltdb/lib/ Note that you must copy the files to all of the VoltDB servers in the cluster before starting the database. 3. Loading PMML Models into VoltDBThe next step is to compile the model into a VoltDB UDF and load it into your database. To compile machine learning models using the voltml utility, you must have the Java JDK version 7 or 8 installed. To execute the resulting user-defined functions, the VoltDB database cluster must be running VoltDB version 7.6 or later. 3.1. Running the voltml UtilityTo compile your PMML model, use the voltml command. If you installed the utility separately, you
can set default to the directory where it is installed and run the command from the In either case, enter the command and specify the location of your model PMML file as an argument. For example: $ cd ~/voltdb-ml-1.0 $ bin/voltml mymodel.pmml Or: $ cd /dev/workspace
$ voltml mymodel.pmmlBy default, the utility compiles the model and creates a JAR file, with the same name as the model file, containing the JAVA class for a user-defined function (UDF). The UDF uses the same name, "mymodel" in this example, for both the class and the method. For example "Mymodel.mymodel". If you want the UDF to have a different name, you can use the $ voltml --name="colormatch" mymodel.pmmlYou can also rename the output file using the $ voltml --outputjar="myudf.jar" mymodel.pmmlTable 1, “Arguments to the voltml Command” summarizes the allowable arguments to the voltml command. Table 1. Arguments to the voltml Command
3.2. Loading and Defining the UDFOnce you compile your model into a user-defined function (UDF), you are ready to load and define the UDF in the VoltDB database. Use the sqlcmd utility to perform this task using the LOAD CLASSES and CREATE FUNCTION statements that voltml displays when it completes its processing. You can just copy and paste the statements into sqlcmd: $ sqlcmd > LOAD CLASSES mymodel.jar; > CREATE FUNCTION mymodel FROM METHOD Mymodel.mymodel; 4. Applying the Model to Your DataOnce your UDF is defined, your database is ready to start processing data using the model evaluator. The voltml UDF works like any other function within SQL, where you specify the function name and the necessary arguments as a list within parentheses after the name. The number, order, and type of the arguments for the UDF are the same as the inputs declared in the PMML definition. For example, if you have a model called lifespan for a model that looks at the age, height, and weight of an individual, the following query evaluates the model against a selection of database entries: SELECT state, AVG( lifespan(age,height,weight) )
FROM members
GROUP BY state ORDER BY state; | ||||||||
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |