Using feature vector .mat file for LIBSVM in matlab - matlab

I'm new to matlab as well as LIBSVM. I calculated feature vector for every point stating r,g,b values of point in single vector and stored it in .mat file. Currently I'm having around 420 points and 4 classes viz Red/Green/Blue/Other. Now I want to pass this .mat file to train libsvm and based on that classify the newly arriving test point, whether it is red or blue or green or other. Need not to mention, its a multiclass classification and I don't even know how to deal with it ?
svmtrain(TrainingSet,Groups,'kernel_function','rbf'); where TrainingSet is my 420*4 feature vector set and Groups is class name.
Thanks in advance for help.

Related

How can I make confusion matrix in Matlab

Here, I have already build a detector .xml file by SVM with HOG features to detect human face with two classes (face and notFace). Now I want to evaluate the performance by confusion matrix. I have train samples of 2 classes. As a test sample, I want to use a picture which contains few faces. Are there any way in Matlab to evaluate the performance of this .xml detector file using these data?

naïve Bayes classifier

I am working on a naïve Bayes classifier and would like to classify some data using MATLAB. In the example of Fisher's Iris Data as given in MATLAB (see here for details), they consider only the first 2 variables (Sepal Length & Width). I would like to proceed with classification with more features such as Petal Length and Petal Width.
In the documentation of this Fisher Iris example it is mentioned that "You can use the two columns containing sepal measurements." I want to take 3 or 4 columns means 4 properties with 2 classes. I want to plot the classes on x-axis and y-axis. How I can do this?
You can plot things in 3D, and use color as your fourth dimension. However this will not be readable at all especially with large datasets.
I recommend you plot combinations of 2D because you will need to use color encoding for your class type normally.
The MATLAB machine learning app can be very helpful to you.

Support Vector Machine in Matlab

I need some help. I got *.mat Matlab file after extract the features from 2D static image. The extraction process was used 2D Haar Wavelet in Matlab Apps.
The problems are: 1. How I want to use the *.mat Matlab file as an input to the SVM program in Matlab?
Addition information: i. The image is the iris image.
ii. Link for the screen capture image of the example output after the extraction process
Based on the image, what is suitable/relevant data to be used in SVM in order to classify the image into 2 classes such as class 1 = Healthy Iris or class 2 = unhealthy iris. Or maybe somebody already got the sample Matlab code that similar with this case study, hope you willing to share the code.
TQ in advanced for the help.

Using MNIST DATABASE for digits recognition.

I am trying to use the MNIST DATABASE in order to recognize hand written digits. What I have so far is a binary matrix that represents the digit , the algorithm is written in matlab . I would love some help on getting started with using the MNIST DATABASE to recognize the digit from the binary image.
Thanks.
If you are using Matlab and already have the binary images now you need to:
1) Extract features from the images (you have many choices). For example, you can start by using the raw pixels ==> convert each image matrix into a row vector.
(Use a part of the data for training and the rest for testing)
Create a feature matrix with all these row vectors. Each row will be an "instance" in your feature matrix.
2) Now can select and try different classifiers. Try for example, an SVM (Support Vector Machine). The most basic way is using the svmtrain and svmclassify functions. The usage is simple and well explained in Matlab's help.
3)Test different partitions of data.
4)Experiment with other features and classifiers.

Create single .mat file by using multiple wave signal

I want to prepare training and testing set for Automatic Speech Recognition by using a Matlab toolbox. I already have the sample set containing several recorded audio (.wav). I am new to Matlab. In order to use the toolbox I need to create training ad testing set save in .mat file. The question is how to create single .mat file containing all the audio? Thanks a million.
To create disjoint training and testing set, the best method is to use crossvalind command. So it performs cross-validation of k-fold where k is the parameter given as input. If k=5 then 1/5th data is used for testing and 4/5th data is used for training. The code is as follows:
data=randi(20,[500 20]); %creating random data with 500 rows and 20 columns.
indices=crossvalid('Kfold',size(data,1),5);
test = (indices == 2); %you can put any number between 1 to 5
train = ~test;
trainData=data(train,:);
testData=data(test,:);
savefile='dataFile.mat'
save(savefile,'trainData','testData');
If you change the number 2 to other number, you will get train-test data with a same distribution and it will be random each time. You can also put it in a for loop but then for saving, you will need to use some tricks or do it manually by placing a breakpoint each point to avoid data getting overwritten. This a general technique to create train-test sets. I hope you will be able to apply this for your problem.