Get raw predictions from Vowpal Wabbit in daemon mode - machine-learning

I'm starting Vowpal Wabbit in daemon mode with the following command:
vw --loss_function hinge --ect 250 --quiet --passes 5 -b 25 --daemon --port 10001 --pid_file pidfile
This works well and I'm able to get predictions by connecting to the socket and sending my data and reading an answer.
My question is, is it possible to also get the raw predictions passed over the socket when in daemon mode?
Instead of only
1.000000 as an answer, I'd like to get something 1:-2.31425 2:-3.98557 3:-3.97967 instead.

There isn't a way to do this with VW currently. The best option is to write the raw predictions to a file and read from that file.
vw --loss_function hinge -r raw_pred --ect 250 --quiet --passes 5 -b 25 --daemon --port 10001 --pid_file pidfile

Related

Enabling Fluentd Log rotation

I am using fluentd with the tg-agent installation. And I observed my default td-agent.log file is growing without having any log rotation.
I am using the following command to run the td-agent
/etc/init.d/td-agent start
And I found the following link which tells how to configure the rotation and it seems like this is with the fluent itself.
https://docs.fluentd.org/deployment/logging
anyone knows how to configure the rotation with the command I am using? I have the td-agent config file also.
You can do this in two ways , first with td-agent itself and for this you need to update the td-agent init file /etc/init.d/td-agent. you have to find the below line in the file
TD_AGENT_ARGS="${TD_AGENT_ARGS:-${TD_AGENT_BIN_FILE} --log ${TD_AGENT_LOG_FILE} ${TD_AGENT_OPTIONS}}"
and update it to
TD_AGENT_ARGS="${TD_AGENT_ARGS:-${TD_AGENT_BIN_FILE} --log-rotate-age 5 --log-rotate-size 104857600 --log ${TD_AGENT_LOG_FILE} ${TD_AGENT_OPTIONS}}"
then restart td-agent and the result will be as shown below
16467 /opt/td-agent/embedded/bin/ruby /usr/sbin/td-agent --log-rotate-age 5 --log-rotate-size 104857600 --log /var/log/td-agent/td-agent.log --use-v1-config --group td-agent --daemon /var/run/td-agent/td-agent.pid
16472 /opt/td-agent/embedded/bin/ruby -Eascii-8bit:ascii-8bit /usr/sbin/td-agent --log-rotate-age 5 --log-rotate-size 104857600 --log /var/log/td-agent/td-agent.log --use-v1-config --group td-agent --daemon /var/run/td-agent/td-agent.pid --
The second method is to use logrotate for rotating the logs, create the below file on your server and make sure that logrotate is installed and it will take care of rotating the logs
cat /etc/logrotate.d/td-agent
/var/log/td-agent/td-agent.log {
daily
rotate 30
compress
delaycompress
notifempty
create 640 td-agent td-agent
sharedscripts
postrotate
pid=/var/run/td-agent/td-agent.pid
if [ -s "$pid" ]
then
kill -USR1 "$(cat $pid)"
fi
endscript
}

MQTT qos parameter has no effect

I have installed a mosquitto server on a raspberry server.
This server works fine: I have test with mosquitto_sub and mosquitto_pub commands.
I have write this python script:
import paho.mqtt.client as mqtt
import time
client = mqtt.Client('module_test_4')
client.connect('127.0.0.1', 1883, 10)
client.loop_start()
for i in range(10):
client.publish('topic_2', "valeur %d" % i, qos=0)
time.sleep(1)
client.loop_stop()
client.disconnect()
I have launched this script twice on 2 consoles:
mosquitto_sub -h 127.0.0.1 -i module_test_2 -t topic_2
It works fine: I see messages on each console.
Now, i have tried to change qos parameter to 0,1 and 2.
I have tried to run my python script without lauching any occurence of mosquitto_sub.
I was thinking mosquitto will buffer messages and send it again when mosquitto_sub will be launched but this does not work.
So i am wondering how qos works...
Thanks
QOS only applies to one leg of the connection at a time.
This means the QOS can be different between the publisher/broker and broker/subscriber.
So in the example you have posted you set QOS to 2 between the publisher and the broker, but it is still the default 0 between the subscriber and the broker. This means that as far as the broker is concerned the subscribing client only wants QOS 0.
If you want to test with mosquitto_sub you need to include a higher QOS on the command line as well. You need to have established a subscription at QOS 2 before disconnecting like so:
mosquitto_sub -h 127.0.0.1 -i module_test_2 -t topic_2 -q 2
You also need to tell mosquitto_sub not to ask for a clean session when it reconnects:
mosquitto_sub -h 127.0.0.1 -i module_test_2 -t topic_2 -q 2 -c

How to monitor and log networking latency between group of docker containers?

I have a setup of 10 docker containers from different immages in a swarm on 3 machines. I need to monitor and log network latency / packet delays between each container. Is there a right tool for it?
I can implement something like
while true; for host in "${my_hosts[*]}"; do ping -c 1 "$host" > latency.log; done done
and launch it on each machine, tailing latency.log to monitor like Prometheus. But it feels like reinvensing a square wheel.
I hope i understand what you need , Im implementing something like this myself .
I tested netdata with prometheus and graphana and metricbeat\filebeat with elastic and kibana
we choose to use elastic (ELK stack) because in the same DB you can handle metrics and textual data .
hope i gave you some directions .
What I have at the end is a setup that:
Shares hosts between containers by volume,
Measures latency feeding hosts to fping,
Writes fping output to log file,
Serves this log file to Prometheus by mtail.
I've implemented wrapper around fping to let it work with mtail:
#!/usr/bin/env bash
# It wraps `fping -lDe` to give output for multiple hosts one line at time (for `mtail` parser)
# Default `fping -lDe` behavior produce X lines at time where X = number of hosts to ping
# This waits for hosts file with `# docker` section as described in usage guide
echo "Measuing time delays to docker hosts from '$1'"
# take hostnames after '# docker' comment line
hosts=$(cat $1 | sed -n '/# docker/,$p' | sed 1,1d)
trap "exit" INT # exit loop by SIGINT
# start `fping` and write it's output to stdout line by line
stdbuf -oL fping -lDe $hosts |
while IFS= read -r line
do
echo $line
done
And there is mtail parser for the log file:
gauge delay by host
gauge loss by host
# [<epoch_time>] <host> : [2], 84 bytes, <delay> ms (0.06 avg, 0% loss)
/\[(?P<epoch_time>\d+\.\d+)\] (?P<host>[\w\d\.]*) : \[\d+\], \d+ \w+, (?P<delay>\d+\.\d+) ms \(\d+\.\d+ avg, (?P<loss>\d+)% loss\)/ {
delay[$host]=$delay
loss[$host]=$loss
}
Now you can add fping and mtail to your images to let it serve delays and losses metrics for Prometheus.
References:
mtail: https://github.com/google/mtail
fping: https://fping.org/

One time vs Iteration Model in vowpal wabbit with --lrq option

I am using vowpal wabbit logistic regression with Low Rank Quadratic options (--lrq ) for CTR prediction.I have trained model with two scenario
Model building in one time with command
vw -d traning_data_all.vw --lrq ic2 --link logistic --loss_function logistic --l2 0.0000000360911 --l1 0.00000000103629 --learning_rate 0.3 --holdout_off -b 28 --noconstant -f final_model
I have breaks the training data in 20 chunks(day wise) and building the model iterative way (with option -i and --save_resume).
first step:-
vw -d traning_data_day_1.vw --lrq ic2 --link logistic --loss_function logistic --l2 0.0000000360911 --l1 0.00000000103629 --learning_rate 0.3 --holdout_off -b 28 --noconstant -f model_1
And then
`vw -d traning_data_day_2.vw --lrq ic2 --link logistic --loss_function logistic --l2 0.0000000360911 --l1 0.00000000103629 --learning_rate 0.3 --holdout_off -b 28 --noconstant --save_resume -i model_1 -f model_2`
And so on up to 20 iteration
1st scenario is working fine but in second scenario predictions are tending to 1 OR 0 (only ) after 7-8 iteration. I need 2nd scenario working because i want to update model frequently. l1, l2 and learning_rate are optimised by vw-hypersearch script.
please help me how to solve this issue. Am i missing something ?. I have tried with option --lrqdropout.

iperf, sctp command not recognized in command-promt

I'm using iperf3 that is supposedly a rewritten version of iperf. Reason why Im using this is because I love iperf when it comes to TCP and UDP throughput and I now want to test SCTP throughput between my end-points.
However when I'm trying to use the --sctp command that I've seen people been using it says command not recognizable. Is it the implementation I'm using that have not implemented this command?
https://github.com/esnet/iperf
This is the implementation I'm using, can't find any obvious documentation of the SCTP commands related to this. Most SCTP iperf implementations are added manually in the tests and the source code is often not provided.
Any help would be appreciated!
Get a copy of iperf which supports lksctp module of linux kernel. Install it using the standard process. (If it fails, please inform with the error message and the operating system and kernel details). Now to use SCTP in iperf these are the proper syntaxes.
For creating an SCTP server,
iperf -z -s
(-z is for selecting the SCTP protocol and -s is for server.)
For creating an SCTP client,
iperf -z -c <host address> -t <time duration for the connection in second>s -i <interval of the time to print the bandwidth in terminal in second>s
(-z for SCTP, -c is for client. Host address should be the ip address of the server where iperf -z -s is already running. -t is to specify the communication time duration. -i is to specify the interval to show the bandwidth.)
Example:
iperf -z -c 0.0.0.0 -t 10s -i 2s
Here the communication time is 10 seconds and it'll report the bandwidth for each 2 seconds interval.
P.S.
(1) To use iperf for SCTP, you must enable the SCTP module in the kernel and recompile it. The kernel version must be 2.6 or above. Check it using uname -a or uname -r. If you have a lower one, then download a new kernel from The Linux Kernel Archives. And compile it by enabling SCTP.
First check if it is already enabled or not by running these two commands in the terminal.
modprobe sctp
lsmod | grep sctp If you get any output then SCTP is already enabled.
(2) If still iperf with -z fails. Try the following solution. If the two machines are 'A' and 'B'.
First make 'A' the server and 'B' the client. It won't succeed. So
exit by using `ctrl + z` and kill iperf
using `pkill -9 iperf`.
Then make 'B' the server and 'A' the client. It may succeed. If it fails again, kill iperf using the above command and repeat step 1 again. it might get succeeded.
(The 2nd solution works for me with fedora 20 and kernel 2.6 and above.)
Couldn't find any recent answers through googling so I though I would leave an answer here for those looking to installing Iperf3 to use SCTP on RHEL / CentOS.
You'll need to install lksctp-tools-devel first and build from source to enable the SCTP support. Yum Install Iperf3 3.17 with lksctp-tools-devel did not enable SCTP for me.

Resources