Vowpal Wabbit runs without burning to disk

I wrote Java code to execute Vowpal Wabbit as follows:

 System.out.println("Executing command " + command);
        final Runtime r = Runtime.getRuntime();
        final Process p = r.exec(command);
        System.out.println("waiting for the process");
        try (final BufferedReader b = new BufferedReader(new InputStreamReader(p.getInputStream()))) {
            String line;

            while ((line = b.readLine()) != null) {
                final T lineResult = textParser.parseLine(line);
                parserResultCombiner.addToCombiner(lineResult);
            }
        }
        p.waitFor();
        System.out.println("done");
}

where is the team

vw -d input.txt --loss_function = logistic -f model.vw

The disadvantage of this is that it requires writing to disk. After some searching, I found out that wowpal wabbit supports reading data from standard input. Example in R

I could not find any examples for this in Java 1.8. Can anyone share this with me?

0
source share
1 answer

You need to run vw in daemon mode. This will start the process that is listening on the specified port.

$ vw -i model.vw  -t --daemon --quiet --port 26542

After starting the daemon, you can send patterns for prediction using socket calls

$ echo " abc-example| a b c" | netcat localhost 26542
0.000000 abc-example

$ echo " xyz-example| x y z" | netcat localhost 26542
1.000000 xyz-example

: https://github.com/JohnLangford/vowpal_wabbit/wiki/daemon-example

java- , vw, jni https://github.com/JohnLangford/vowpal_wabbit/tree/master/java

+3

Source: https://habr.com/ru/post/1653451/