multiple ROC curve in R with a matrix of prediction values and labels - roc

I want to plot multiple ROC curves with a matrix of predictions and labels. I have > 100 samples with a matrix of predictions and labels for each sample. The length of the samples is different. How could I get design a single matrix for all the samples and get multiple ROC curves in a single plot? I would appreciate any suggestions. Thanks

Related

Simulation data fitting

I have 154 scatter points and I want to fit them.
What is the best way to fit them to a curve? I tried with Excel sheet to fit the data to polynomial curve but I found the highest fitting power is 6. which program or numerical technique would help in fitting these data?

How do I find average-distance transform of a binary image?

The distance transform provides the distance of each pixel from the nearest boundary/contour/background pixel. I don't want closest distance, but I want to get some sort of average measure of the pixel's distance from the boundary/contour in all directions. Any suggestions for computing this distance transform would be appreciated. If there any existing algorithms and/or efficient C++ code available to compute such distance transform, that would be wonderful too.
If you have a binary image of the contours, then you can calculate the number of boundary pixels around each pixel within some windows (using e.g. the integral image, or cv::blur). This would give you something like what you want.
You might be able to combine that with normalizing the distance transform for average distances.
If you want the "average measure of the pixel's distance from the boundary/contour in all directions", then I am afraid that you have to extract the contour and for each pixel inside the pattern, you have to compute the average distance with the pixels belonging to the contour.
An heuristic for a "rough" approximation, would be to compute many distance maps using sources points (they could be the pattern extremities), and for each pixel inside the pattern, then you compute the sum of all distances from the distance maps. But to have the exact measure, you would have to compute as many distance maps as pixels belonging to the contour. But if an approximation is "okay", then this will speed up the processing.

Matlab: polar coordinates grey scale plot

edit: I decided to split this question into two parts, because it were really two questions: 1. how to make a polar surface plot in MATLAB (this question) and 2. how to put fit polar data points into a coarse (and non-polar) matrix
I have a matrix that contains certain grey values (values between zero and one). These points are stored in a rectangular matrix, but really the data points are acquired by rotating the detector. This means that I actually have polar coordinates (I know the polar coordinates for every single pixel in my starting matrix).
I want to make a polar plot of the data points. I have the example of this below.
Because MATLAB stores images as matrices, the polar coordinates I have do not exactly match the 'bins' of the matrix. Therefore, we currently use an interpolation algorithm to put the polar coordinates into a square matrix. However, this is extremely slow. I see two methods to solve this issue:
let MATLAB directly plot the data points as polar.
calculate once how to convert from the start matrix to the end matrix and let MATLAB do this through matrix multiplication.
Some basic information:
Input matrix size: 512×960
Current output matrix size: 1024×1024
I think there is built in function for polar plot in matlab.
Z = [2+3i 2 -1+4i 3-4i 5+2i -4-2i -2+3i -2 -3i 3i-2i];
polarplot(Z,'*')
this command plots:
plot polar
See this link:
http://www.mathworks.com/help/matlab/ref/polarplot.html
To plot in grayscale, use "pcolor" and specify colormap to "gray"
www.mathworks.com/help/matlab/ref/ pcolor.html
The question was solved (apart from a minor flaw), partially because K.M. Shihab Uddin pointed me in the right direction. Unfortunately, using surf means continuously really plotting the image in a figure, and this is slow as well.
So I have X and Y values both in separate matrices and greyscale values (in a matrix called C) for every X and Y combination.
I found out that pcolor is just surf with a viewpoint from the top. So I used the following code to plot my graph.
surf(X,Y,C*255)
view([0,0,500])
However, this gave me a completely black image. This is because surf (and pcolor) create 960 grid lines radially in my case. The solution is to use:
surf(X,Y,img2*255,'EdgeColor','none')
view([0,0,500])
Now I have an almost perfect image, like I had before. Only, of my 960 radial lines, one is left white, so I still have to solve that. However, I feel this is a technical detail of the function surf, and answering this part does not belong in this question.
The resulting image

multidimensional scatter plot with d3

I have a dataset which has 9 attributes out of which 2 are numerical and the rest are categorical.
I wish to plot as many attributes as possible within a scatter plot matrix. D3 examples have shown me scatter plot matrices with a majority of numerical values.
Are there any ways to plot multidimensional categorical data as scatter plots?
IF yes, are there any samples available on the wbe?

computer vision: extracting info about a shape given a contour (e.g. pointy, round...)

Given the 2D contour of a shape in the form of lines and vertices, how can I Extract Information from that?
like: Pointy, round, straight line.
Shape similarities with a given shape.
Code is not necessary, I am more interested in
concepts and the names of techniques involved to
guide my search....
Thanks in advance.
Image moments
One approach is to calculate the first and second order central moments of the shape described by the 2D contour. Using these values the elongation of the object can be calculated.
The central image moments can be combined to the seven moments of Hu, which are invariant to change in scale, rotation and translation (ie. they are very good for basic shape recognition). (More on image moments here).
Unitless ratio of perimeter and area
An other approach is to calculate the length of the perimeter (p) and the size of the inscribed area (a). Using these two values, the following ratio can be computed:
ratio = p^2 / (4 * pi * a)
The closer this ratio is to one, the more circle like is the described shape.
Other methods
Fourier descriptors
Ratio of shape area and the area of the convex hull of the shape
Another method of contour shape classification is topological aproach based on the "size function" That could be useful for global shape recognition, but not for extracting "local" features like pointy/round/straight.
http://en.wikipedia.org/wiki/Size_function
Basically slicing contour by parametrized line and counting number of connected components depending on parameter.
http://www.ingre.unimo.it/staff/landi/articoli/patrec.pdf
What I think you might be looking for is often called Blob or Connectivity Analysis, which I believe was first developed at SRI (Stanford Research Institute). Image moments are one component of this area.

Resources