\HeaderA{vis.res}{Visualize Results}{vis.res}
\aliasA{fscores}{vis.res}{fscores}
\aliasA{pr}{vis.res}{pr}
\aliasA{rates}{vis.res}{rates}
\aliasA{show.pr}{vis.res}{show.pr}
\aliasA{show.roc}{vis.res}{show.roc}
\keyword{misc}{vis.res}
\begin{Description}\relax
A group of functions to plot precision-recall and ROC curves and to compute f-scores from the 
data.frame returned by the \code{\LinkA{validate}{validate}} function.
\end{Description}
\begin{Usage}
\begin{verbatim}
  pr(table)
  rates(table)
  fscores(table, beta=1)
  show.pr(table,device=-1,...)
  show.roc(table,device=-1,...)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{table}] This is the (\code{steps} x 5) data.frame returned by the \code{validate} function where 
\code{steps} is the number of thresholds used in the validation process and where columns contain 
TP,FP,TN,FN values (confusion matrix) as well as the threshold value used  - see \code{\LinkA{validate}{validate}}.
\item[\code{beta}] Numeric used as the weight of the recall in the f-score formula - see details. The default value of this argument is
1, meaning precision as important as recall.
\item[\code{device}] The device to be used. This parameter allows the user to plot precision-recall and 
receiver operating characteristic curves for various inference algorithms on the same plotting window - see examples.
\item[\code{...}] arguments passed to \code{plot} 
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
A confusion matrix contains FP,TP,FN,FP values.
\item "true positive rate" \eqn{tpr = \frac{TP}{TN+TP}}{tpr = TP/(TN+TP)}
\item "false positive rate" \eqn{fpr = \frac{FP}{FN+FP}}{fpr = FP/(FN+FP)}      
\item "precision" \eqn{p = \frac{TP}{FP+TP}}{p = TP/(FP+TP)}
\item "recall" \eqn{r = \frac{TP}{TP+FN}}{r = TP/(TP+FN)}
\item "f-beta-score" \eqn{F_\beta = (1+\beta) \frac{p r} {r + \beta p}}{Fbeta = (1+beta) * p*r/(r + beta*p)}
\end{Details}
\begin{Value}
The function \code{show.roc} (\code{show.pr}) plots the ROC-curve (PR-curve) and returns the device associated with the plotting window.

The function \code{pr} returns a (\code{steps} x 2) data.frame where steps is the number of thresholds used 
in the validation process. The first column contains precisions and the second recalls - see details.

The function \code{rates} also returns a (\code{steps} x 2) data.frame where the first column contains true 
positive rates and the second column false positive rates - see details.  

The function \code{fscores} returns \code{steps} fscores according to the \code{steps} confusion matrices 
contained in the 'table' argument - see details.
\end{Value}
\begin{References}\relax
Patrick E. Meyer, Kevin Kontos, Frederic Lafitte, and Gianluca Bontempi. 
Information-theoretic inference of large transcriptional regulatory
networks. EURASIP Journal on Bioinformatics and Systems Biology,
2007.
\end{References}
\begin{SeeAlso}\relax
\code{\LinkA{validate}{validate}},  \code{\LinkA{plot}{plot}}
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
data(syn.data)
data(syn.net)
# Inference
mr <- minet( syn.data, method="mrnet", estimator="mi.empirical" )
ar <- minet( syn.data, method="aracne", estimator="mi.empirical" )
clr<- minet( syn.data, method="clr", estimator="mi.empirical" )
# Validation
mr.tbl <- validate(mr,syn.net)
ar.tbl <- validate(ar,syn.net)
clr.tbl<- validate(clr,syn.net)
# Plot PR-Curves
max(fscores(mr.tbl))
dev <- show.pr(mr.tbl, col="green", type="b")
dev <- show.pr(ar.tbl, device=dev, col="blue", type="b")
show.pr(clr.tbl, device=dev, col="red",type="b")
\end{ExampleCode}
\end{Examples}

