MATLAB - difference between fitglm and fitclinear? - matlab

I am creating a logistic regression model on MATLAB which will be a binary classifier (outcome is the label 'good' or 'bad'). I have found what appears to be two functions which can fit a logistic model:
fitglm()
fitclinear()
Can someone please help me understand the difference? So far I have been using fitclinear and enjoying it.
Thanks

Related

GradCAM implementation in Pytorch Vs Matlab

I have finetuned two resnet101s on the exact same dataset and with similar hyperparameters, one with Matlab and the other with Pytorch, and created GradCAMs with gradients on the same layers. The results are too far. Seems that the implementation in Matlab gives much more accurate results. Any thoughts are really appreciated.

SVM for multi-class in Matlab

I am trying to implement SVM for multiclass problems in Matlab. I know that there is an inbuilt code for SVM in matlab but I don't know how to use it. Need some help in getting started with Matlab SVM.
SVM classifies into two classes. If you want to create a multiclass SVM, you will have to hack it yourself. You could for instance do AdaBoost with SVMs as your "cheap classifiers", although they are not that cheap to train (contrary to decision trees or even decision stumps).
Speaking of AdaBoost, you'll probably end up using ensemble methods in matlab if you really don't want to program it yourself:
For classification with three or more classes:
'AdaBoostM2'
'LPBoost' (requires an Optimization Toolbox license)
'TotalBoost' (requires an Optimization Toolbox license)
'RUSBoost'
'Subspace'
'Bag'
The ensemble toolbox is really simple and there's a ton of documentation on matlab's help pages. Basically you state your X and Y, the type of learner you want (for instance SVM) and the ensemble method, which is the method you want to use to combine the different weak learners. AdaBoost is one way, but you could also just do Bagging where the majority vote of all your weak learners counts.
So some questions you can answer here or at least ask yourself are: Why do you want to to multiclass SVM? Is it a homework assignment? Do you know how SVM and other machine learning alorithms work? Do you need help picking the right algorithm?

Vectorized Implementation of Softmax Regression

I’m implementing softmax regression in Octave. Currently I’m using a non-vectorized implementation using following cost function and derivatives.
Source: Softmax Regression
Now I want to implement vectorized version of it in Octave. It seems like bit hard for me to write vectorized versions for these equations. Can somebody help me to implement this ?
Thanks
Upul
This is very similar to an exercise in Andrew Ng's deep learning class, they give some hints
http://ufldl.stanford.edu/wiki/index.php/Exercise:Vectorization

Matlab SVM training for muliclasses dataset

I have a question about the SVM MATLAB toolbox 2009b! the question is:
How I can train SVM classifier for classifying multi-classes datasets in MATLAB toolbox 2009b?
I just want to work with MATLAB toolbox, so please answer it if there is a way to implement it. For example, the below code is for classifying two classes datasets:
svmtrain( training data, ...
labels of training data, ...
'Kernel_Function', ...
'rbf', ...
'RBF_Sigma', ...
sigma value, ...
'Method', ...
'LS', ...
'BoxConstraint', ...
C ...
);
I want to know is there a way for training SVM for multi-classes dataset with writing a code such as above code, or should I write some code for training a SVM for each class versus the other classes?
It means, should I consider 1 for the label of the selected class and set the label of the other classes to 0, and train a SVM with above code, and do it for all classes!?
Thanks for your consideration :-)
I have not used SVM in Matlab, so other people can likely provide a more informed response, but I will share what I have learned.
Matlab Bioinformatics Toolbox SVM
From reading the documentation, the SVM in the Bioinformatics Toolbox appears to only support binary classification. As suggested in the question, a binary classifier can, with some effort, be used to classify into multiple classes. There is some discussion on approaches for doing this in the context of SVM here.
Alternate options
LIBSVM does support multi-class classification and comes with a Matlab interface. You could try installing and using it.
Additionally, while looking into this, I did come across several other Matlab toolboxes with SVM implementations. If LIBSVM is not a good option for you, it may be worth looking around to see if a different SVM implementation fits your needs.
If you have MATLAB release R2014b or later you can use the fitcecoc function in the Statistics and Machine Learning Toolbox to train a multi-class SVM.
Yup, the way for solving your problem - is to implement one vs all strategy. One of the SVM's lacks is that it has no direct multiclassification implementation.
But you can implement it through the binary classification.
I didn't see any function for svm multi classification in matlab. But i think it is not hard to implement it by yourself

SVM MATLAB Implementation

I have a homework to classify multi-class images with Support Vector Machines. I am not allowed to use any toolbox, I have to write SVM code by my self. I have to implement it in MATLAB. Since I am not familiar with MATLAB, I have some troubles about implementing.
Can you suggest me any pseudocode or paper that explains the svm implementation basically? I mean I know the theory of SVM but I am just not good at programming. Or any SVM code might be very helpful!
Thank you for your help in advance.
I like using LibSVM library. On its web pages you can find some useful hints and descriptions of the SVM. There is also beginner's guide to SVM classification. The source code itself should be available as well.
http://www.csie.ntu.edu.tw/~cjlin/libsvm/