Showing posts with label Machine-Learning. Show all posts
Showing posts with label Machine-Learning. Show all posts

Sunday, July 22, 2012

ROC Curve

My recent work related to Text Classification got me introduced to ROC Curve which is a very effective way to compare classifiers against each other and decide on the cutoff value for classes.
Its best defined with a simple example. Say you have a binary classification problem. You have generated 3 train-test datasets from the original data. Say you are using Support Vector Machine (SVM) as the classifier. After training SVM on all the three sets, you want to select the "best" of these three. How do you go about it?

Here's where ROC comes into rescue. Sort the output of the SVM and compute True Positive %tage and False Positive %tage so far for each data point and plot this in x-y graph. The area under the curve will give you a way to measure the effectiveness of each classifier. Moreover you can use the nature of the graph to establish your positive and negative class boundary.

Here are a few links to know more about ROC curve:

Tuesday, May 17, 2011

Cell array to matrix in Matlab

Having used Matlab for machine learning work, I often face this problem. Typically while working with some classifier like "TreeBagger", the "eval()" function for computing labels of test data returns a cell array where each element is '1' or '-1'. The problem is that my original labels were numeric {1,-1}, so comparing these become a big problem especially if one is interested in things beyond accuracy.

Here is a simple technique to convert this cell array to a matrix. Say the original cell array is:
cellArr={'-1'; '-2'; '3' ;'6' ;'5'};
Now to convert this into a numeric array, all you have to do is:
mat=cellfun(@str2num,cellArr);
This calls the function str2num for each element of the cell array and returns the resultant matrix in numeric format.