Total Pageviews

Sunday 21 August 2011

Micro- and Macro-average of Precision, Recall and F-Score

I posted several articles explaining how precision and recall can be calculated, where F-Score is the equally weighted harmonic mean of them. I was wondering- how to calculate the average precision, recall and harmonic mean of them of a system if the system is applied to several sets of data.

Tricky, but I found this very interesting. There are two methods by which you can get such average statistic of information retrieval and classification.

1. Micro-average Method

In Micro-average method, you sum up the individual true positives, false positives, and false negatives of the system for different sets and the apply them to get the statistics. For example, for a set of data, the system's

True positive (TP1)= 12
False positive (FP1)=9
False negative (FN1)=3

Then precision (P1) and recall (R1) will be 57.14 and 80

and for a different set of data, the system's


True positive (TP2)= 50
False positive (FP2)=23
False negative (FN2)=9

Then precision (P2) and recall (R2) will be 68.49 and 84.75

Now, the average precision and recall of the system using the Micro-average method is

Micro-average of precision = (TP1+TP2)/(TP1+TP2+FP1+FP2) = (12+50)/(12+50+9+23) = 65.96
Micro-average of recall = (TP1+TP2)/(TP1+TP2+FN1+FN2) = (12+50)/(12+50+3+9) = 83.78

The Micro-average F-Score will be simply the harmonic mean of these two figures.

2. Macro-average Method

The method is straight forward. Just take the average of the precision and recall of the system on different sets. For example, the macro-average precision and recall of the system for the given example is

Macro-average precision = (P1+P2)/2 = (57.14+68.49)/2 = 62.82
Macro-average recall = (R1+R2)/2 = (80+84.75)/2 = 82.25

The Macro-average F-Score will be simply the harmonic mean of these two figures.

Suitability
Macro-average method can be used when you want to know how the system performs overall across the sets of data. You should not come up with any specific decision with this average.

On the other hand, micro-average can be a useful measure when your dataset varies in size.

Friday 12 August 2011

Research Writing: That or Which?

Very simple explanation on "that" and "which". But I would say- this one is the best clarification I found on the web so far. I am confident enough now to use either of the two as the papers I review mostly mix up them.

[Originally from Mignon Fogarty]

"
Restrictive Clause--That

A restrictive clause is just part of a sentence that you can't get rid of because it specifically restricts some other part of the sentence. Here's an example:

Gems that sparkle often elicit forgiveness.

The words that sparkle restrict the kind of gems you're talking about. Without them, the meaning of the sentence would change. Without them, you'd be saying that all gems elicit forgiveness, not just the gems that sparkle. (And note that you don't need commas around the words that sparkle).

Nonrestrictive Clause--Which

A nonrestrictive clause is something that can be left off without changing the meaning of the sentence. You can think of a nonrestrictive clause as simply additional information. Here's an example:

Diamonds, which are expensive, often elicit forgiveness.

Leaving out the words which are expensive doesn't change the meaning of the sentence. (Also note that the phrase is surrounded by commas. Nonrestrictive clauses are usually surrounded by, or preceded by, commas.
"

Tuesday 9 August 2011

He as well as Me or He as well as I?

Found a very useful article (don't know the name of the poster in a language forum, but I am acknowledging him/ her with the deepest).

"as well as" functions as a conjunction in #1, not a preposition:

#1. She was into drama and took part in many youth theater productions as well as [took part in] singing in choirs.

"as well as" has two functions:

conjunction: courageous as well as strong.
preposition: The rhetoric, as well as the reasoning, is appreciated.

Notice the commas on each side of the prepositional phrase. They set off or bar the grammar from counting it as part of the subject. That's why the verb is singular "is", and not plural "are". Take the commas away and the prepositional phrase changes identity. It becomes a conjunction + noun phrase that's counted as part of the subject:

conjunction: The rhetoric as well as the reasoning are appreciated.

Below in #2a, there aren't any commas setting off "as well as" from the grammar, so it's counted as part of the subject. "He as well as I" is a compound subject so the verb should be plural "are" (#2b), not singular "is":

#2a. He as well as I is satisfied with the result.
#2b. He as well as I are satisfied with the result.

Subject verb agreement is also a problem for #3a. "He as well as me" is a compound subject; the verb should be plural:

#3a. He as well as me is satisfied with the result.
#3b. He as well as me are satisfied with the result.

Now, add in the commas and "as well as" functions as a preposition,

#2c. He, as well as I, is satisfied with the result.
#3c. He, as well as me, is satisfied with the result.

As a conjunction, "as well as" joins two like forms;i.e., courageous as well as strong; you as well as Sam, but in #3b, below, "as well as" joins two unlike forms, the subject pronoun "He" and the object pronoun "me".

#3b. He as well as me are satisfied with the result.
#3d. He as well as I are satisfied with the result.

Now, "as well as me" is non-standard English, but nevertheless speakers will use "me" as well as "myself" as a way of placing the other person above them. It's a way of humbling oneself.

Thursday 4 August 2011

Excel Graph to EPS (MS Office 2007)

Here is how I convert an excel (MS Office 2007) graph to EPS so that I can use that graph in a TEX file.

1. Open MS Excel. Copy the graph to a new sheet and be careful so that it fits in one page (you can double check if the graph fits in a page from print preview option).

2. Go to File-> Print-> Properties-> Advanced-> Postscript Option and select EPS.

3. The file will be saved as EPS so give the file an extension .eps

4. Open the GSview and open the .eps file you just saved. Go to File and select ps to eps. The file should be given an extension of .eps. This is the final eps file that you can insert in your TEX code.

From Tex to PDF

There are several ways to generate a PDF from a TEX file. I am stating the most popular 4 ways here.

Method 1

If you do not have bibliography file

% latex myfile (to generate myfile.dvi from myfile.tex)
% dvips myfile (to generate myfile.ps from myfile.dvi)
% ps2pdf myfile.ps (to generate the file myfile.pdf)

Method 2

If you have bibliography file

% latex myfile (to generate myfile.dvi from myfile.tex)
% bibtex myfile (uses the .aux file to extract cited publications from the database in the .bib file, formats them according to the indicated style, and puts the results into in a .bbl file)
% dvips myfile (to generate myfile.ps from myfile.dvi)
% ps2pdf myfile.ps (to generate the file myfile.pdf)

Method 3

If you want to convert a TEX file directly to PDF and do not have a bibliography file


% pdflatex myfile

N.B. If you have images in EPS format, you need to convert it into PDF format with the following command-

% epstopdf image.eps

Method 4

If you want to convert a TEX file directly to PDF and have a bibliography file


% pdflatex myfile
% bibtex myfile
% pdflatex myfile
% pdflatex myfile


N.B. If you have images in EPS format, you need to convert it into PDF format with the following command-

% epstopdf image.eps

Wednesday 3 August 2011

Two Figures Side-by-Side in Latex

Many times you can come across a situation where you need to put two figures side-by-side in a paper written in latex format. Well, of course, they are two different figures: one is say Figure 1 and the other is say Figure 2. How are you going to achieve this? Well, simply the following latex code helps.



\begin{figure}[b]
\begin{minipage}[t]{0.48\linewidth}
\centering
\includegraphics[scale=0.4]{\string"Path and file name without extension\string".pdf}
\caption{Number of new connections in five chunks for six papers on Ischemia
and Glutamate}
\label{fig:figure1}
\end{minipage}
\hspace{0.5cm}
\begin{minipage}[t]{0.48\linewidth}
\centering
\includegraphics[scale=0.4]{\string"Path and file name without extension\string".pdf}
\caption{Number of dropped connections in five chunks for six papers on Ischemia
and Glutamate}
\label{fig:figure2}
\end{minipage}
\end{figure}


The thing to remember is to create minipages. One minipage serves the purpose of putting one figure. All you need to adjust here is the position of the figure (here, I chose the bottom of the page), position of the linewidth of the minipage (mine here is 0.48, yours definitely depend on the page size), and the graphics size.