How do I implement weka classifier MPL in matlab - matlab

hi : i m working with matlab 2014a and i need to implement MULTIPERCEPTRON classification algorithme from weka 3.6 to matlab .
I have dificulties to find the setting of the classifier
classifier=javaObject('weka.classifiers.functions.MultilayerPerceptron');
classifier.setOptions(weka.core.Utils.splitOptions(' -L 0.3 -M 0.2 -N 500 -V 0 -S 0 -E 20 -H a'));
and i m getting this error
> Java exception occurred: java.lang.Exception: Illegal options: -L
> 0.3 -M
> 0.2 -N 500 -V 0 -S 0 -E 20 -H a at
> weka.core.Utils.checkForRemainingOptions(Utils.java:534) at weka.classifiers.functions.MultilayerPerceptron.setOptions(MultilayerPerceptron.java:2376)

Related

More partitions same throughput in Kafka

I have an application in which I use apache Kafka and I try to do some tests.
My application consists of:
a) a service which receive http requests and sends the messages in Kafka. b) a mongoDB which receives the messages from kafka and store them.
My Kafka consists of 1 Kafka Broker, 1 topic and 1 partition. Also I use keys for messages in Kafka.
For my tests I use Apache Bench.
I created a script test.sh for my first test for run concurrency many requests. I send ever the same json object.
ab -s 150 -p post.json -T application/ld+json -c 10000 -n 100000 -rk http://localhost:3000/service_discovery/scorpio > tests/test1.txt &
ab -s 150 -p post.json -T application/ld+json -c 10000 -n 100000 -rk http://localhost:3000/service_discovery/scorpio > tests/test2.txt &
ab -s 150 -p post.json -T application/ld+json -c 10000 -n 100000 -rk http://localhost:3000/service_discovery/scorpio > tests/test3.txt &
ab -s 150 -p post.json -T application/ld+json -c 10000 -n 100000 -rk http://localhost:3000/service_discovery/scorpio > tests/test4.txt &
ab -s 150 -p post.json -T application/ld+json -c 10000 -n 100000 -rk http://localhost:3000/service_discovery/scorpio > tests/test5.txt &
First test:
1)1 partition . I make 5.000.000.000 http requests and the end-to-end throughput is 53.22 req/sec.
Also, I created a script test2.sh for my second test for run concurrency many requests. I send different json objects with different key and I checked that every object stored at different partition.
ab -s 180 -p request_post/post.json -T application/ld+json -c 10000 -n 100000 -rk http://localhost:3000/service_discovery/scorpio > tests/test1.txt &
ab -s 180 -p request_post/post2.json -T application/ld+json -c 10000 -n 100000 -rk http://localhost:3000/service_discovery/scorpio > tests/test2.txt &
ab -s 180 -p request_post/post3.json -T application/ld+json -c 10000 -n 100000 -rk http://localhost:3000/service_discovery/scorpio > tests/test3.txt &
ab -s 180 -p request_post/post4.json -T application/ld+json -c 10000 -n 100000 -rk http://localhost:3000/service_discovery/scorpio > tests/test4.txt &
ab -s 180 -p request_post/post5.json -T application/ld+json -c 10000 -n 100000 -rk http://localhost:3000/service_discovery/scorpio > tests/test5.txt &
Second test:
2) 5 partitions . I make 5.000.000.000 http requests and the end-to-end throughput is 50.13 req/sec.
I expected higher throughput in second test.
So the question is : why I don't get better throughput with more partitions?
(if you need more information ask me)

WEKA Command Line Parameters

I am able to run Weka form CLI using below command:
java -cp weka.jar weka.classifiers.functions.MultilayerPerceptron -t Dataset.arff
Weka Explorer Target Selection Parameters
How can I set the Target Parameters for example "Number of time units for forecast" using command Line?
We are trying to use command line to improve memory utilization , we have a large dataset with 10000 attributes which is causing Java Heap Space everytime we run it from GUI.
Thanks For the response.
Posting answer to my own question:
java -cp weka.jar weka.Run weka.classifiers.timeseries.WekaForecaster -W "weka.classifiers.functions.MultilayerPerceptron -L 0.01 -M 0.2 -N 5000 -V 0 -S 0 -E 20 -H 20 " -t <dataset file> -F <FieldList> -L 1 -M 3 -prime 3 -horizon 6
We can always get more help using :
java -cp weka.jar weka.Run -h

Raspivid save to disk and stream concurrently

I am trying to run a home security camera using Rasberry Pi Model B
I want to save the stream to a file locally (USB if possible) and also stream so I can pick this up on my network
The command I have is not working for both - any suggestions?
raspivid-o security.h264 -t 0 -n -w 600 -h 400 -fps 12 | cvlc -vvv stream:///dev/stdin --sout '#rtp{sdp=rtsp://:8554/}' :demux=h264
Try this command:
raspivid -o - -t 0 -n -w 600 -h 400 -fps 12 | tee security.h264 | cvlc -vvv stream:///dev/stdin --sout '#rtp{sdp=rtsp://:8554/}' :demux=h264
The tee command writes the output to the standard output and to the specified files.

Error trying to build a classifier with MatLab+Weka

I'm trying to perform a classification with some classifiers using weka+Matlab, however, some classifiers are not accepting the paremeter I've sent with setOptions.
Look at this test code, I don't know why, the Logistic classifier is built properly, but the Ibk presents an error:
%Load the csv File returning an object with the features.
wekaObj= loadCSV('C:\experimento\selecionados para o experimento\Experimento Final\dados\todos.csv');
%Create an instance of the Logistic classifier - OK
classifier1=javaObject(['weka.classifiers.','functions.Logistic']);
classifier1.setOptions('-R 1.8E-8 -M -1');
classifier1.buildClassifier(wekaObj);
%Create an instance of the K-nearest Neighbour classifier - Error
classifier2=javaObject(['weka.classifiers.','lazy.IBk']);
classifier2.setOptions('-K 10 -W 0 -A "weka.core.neighboursearch.LinearNNSearch -A \"weka.core.EuclideanDistance -R first-last\""');
classifier2.buildClassifier(wekaObj);
%Create an instance of the random forest classifier - Error
classifier3=javaObject(['weka.classifiers.','trees.RandomForest']);
classifier3.setOptions('-I 1200 -K 0 -S 1 -num-slots 1');
classifier3.buildClassifier(wekaObj);
%Create an instance of the MultiLayer Perceptron classifier - Error
classifier4=javaObject(['weka.classifiers.','functions.MultilayerPerceptron']);
classifier4.setOptions('-L 0.1 -M 0.1 -N 500 -V 0 -S 0 -E 20 -H a');
classifier4.buildClassifier(wekaObj);
The error is that one:
Error using weka.classifiers.lazy.IBk/setOptions
Java exception occurred:
java.lang.Exception: Illegal options: -K 10 -W 0 -A
"weka.core.neighboursearch.LinearNNSearch -A "weka.core.EuclideanDistance -R
first-last""
at weka.core.Utils.checkForRemainingOptions(Utils.java:534)
at weka.classifiers.lazy.IBk.setOptions(IBk.java:715)
Has anyone here had this same problem?
obs: Sorry for possible typos, english is my second language.
I was able to figure out what was wrong, the correct implementation:
%Load the csv File returning an object with the features.
wekaObj= loadCSV('C:\experimento\selecionados para o experimento\Experimento Final\dados\todos.csv');
%Create an instance of the Logistic classifier - OK
classifier1=javaObject(['weka.classifiers.','functions.Logistic']);
classifier1.setOptions('-R 1.8E-8 -M -1');
classifier1.buildClassifier(wekaObj);
%Create an instance of the K-nearest Neighbour classifier - Error
classifier2=javaObject(['weka.classifiers.','lazy.IBk']);
classifier2.setOptions(weka.core.Utils.splitOptions('-K 10 -W 0 -A "weka.core.neighboursearch.LinearNNSearch -A \"weka.core.EuclideanDistance -R first-last\""'));
classifier2.buildClassifier(wekaObj);
%Create an instance of the random forest classifier - Error
classifier3=javaObject(['weka.classifiers.','trees.RandomForest']);
classifier3.setOptions(weka.core.Utils.splitOptions('-I 1200 -K 0 -S 1'));
classifier3.buildClassifier(wekaObj);
%Create an instance of the MultiLayer Perceptron classifier - Error
classifier4=javaObject(['weka.classifiers.','functions.MultilayerPerceptron']);
classifier4.setOptions(weka.core.Utils.splitOptions('-L 0.1 -M 0.1 -N 500 -V 0 -S 0 -E 20 -H a'));
classifier4.buildClassifier(wekaObj);

Weka: doing bagging from the command line

I can train a model using Bagging from the command line like this --
java -Xmx512m -cp $CLASSPATH weka.classifiers.meta.Bagging -P 100 -S 1 -num-slots 1 -I 10 \
-split-percentage 66 \
-t $traindata \
-d $model \
-W weka.classifiers.trees.REPTree -- -M 2 -V 0.001 -N 3 -S 1 -L -1 -I 0.0 \
> $out
But I can't reuse the same model to do prediction from the command line. I guess the command should be something like --
java -Xmx512m -cp $CLASSPATH weka.classifiers.meta.Bagging \
-l $model \
-T $testdata \
-W weka.classifiers.trees.REPTree \
-p 0 \
> $wkresult
But it does not work, any idea?
EDIT: However, when I am doing with a single classifier (i.e. no bagging), it works. The commands were like this --
java -Xmx512m -cp $CLASSPATH weka.classifiers.bayes.NaiveBayesMultinomial \
-split-percentage 66 \
-t $traindata \
-d $model \
> $out
java -Xmx512m -cp $CLASSPATH weka.classifiers.bayes.NaiveBayesMultinomial \
-T $testdata \
-l $model \
-p 0 \
> $wkresult
You need to call a different class to evaluate the model. The command line should be something like
java -cp $CLASSPATH weka.classifiers.Evaluation weka.classifiers.meta.Bagging \
-T $testdata -l $model
You may need to specify some of the additional options you gave when training the classifier. Also have a look at the commandline options for the evaluation class. More information here.