mgraph | R Documentation |
Plots a graph given a mining
list, list of several mining lists or given the pair y - target and x - predictions.
mgraph(y, x = NULL, graph, leg = NULL, xval = -1, PDF = "", PTS = -1,
size = c(5, 5), sort = TRUE, ranges = NULL, data = NULL,
digits = NULL, TC = -1, intbar = TRUE, lty = 1, col = "black",
main = "", metric = "MAE", baseline = FALSE, Grid = 0,
axis = NULL, cex = 1)
y |
if there are predictions ( |
x |
the predictions (should be a numeric vector if |
graph |
type of graph. Options are:
|
leg |
legend of graph:
|
xval |
auxiliary value, used by some graphs:
|
PDF |
if |
PTS |
number of points in each line plot. If -1 then |
size |
size of the graph, c(width,height), in inches. |
sort |
if TRUE then sorts the data (works only for some graphs, e.g. |
ranges |
matrix with the attribute minimum and maximum ranges (only used by |
data |
the training data, for plotting histograms and getting the minimum and maximum attribute ranges if not defined in ranges (only used by |
digits |
the number of digits for the axis, can also be defined as c(x-axis digits,y-axis digits) (only used by |
TC |
target class (for multi-class classification class) from 1 to Nc, where Nc is the number of classes. If multi-class and TC==-1 then TC is set to the index of the last class. |
intbar |
if 95% confidence interval bars (according to t-student distribution) should be plotted as whiskers. |
lty |
the same |
col |
color, as defined in the |
main |
the title of the graph, as defined in the |
metric |
the error metric, as defined in |
baseline |
if the baseline should be plotted (used by |
Grid |
if >1 then there are GRID light gray squared grid lines in the plot. |
axis |
Currently only used by |
cex |
label font size |
Plots a graph given a mining
list, list of several mining lists or given the pair y - target and x - predictions.
A graph (in screen or pdf file).
See also http://hdl.handle.net/1822/36210 and http://www3.dsi.uminho.pt/pcortez/rminer.html
Paulo Cortez http://www3.dsi.uminho.pt/pcortez/
To check for more details about rminer and for citation purposes:
P. Cortez.
Data Mining with Neural Networks and Support Vector Machines Using the R/rminer Tool.
In P. Perner (Ed.), Advances in Data Mining - Applications and Theoretical Aspects 10th Industrial Conference on Data Mining (ICDM 2010), Lecture Notes in Artificial Intelligence 6171, pp. 572-583, Berlin, Germany, July, 2010. Springer. ISBN: 978-3-642-14399-1.
@Springer: https://link.springer.com/chapter/10.1007/978-3-642-14400-4_44
http://www3.dsi.uminho.pt/pcortez/2010-rminer.pdf
This tutorial shows additional code examples:
P. Cortez.
A tutorial on using the rminer R package for data mining tasks.
Teaching Report, Department of Information Systems, ALGORITMI Research Centre, Engineering School, University of Minho, Guimaraes,
Portugal, July 2015.
http://hdl.handle.net/1822/36210
fit
, predict.fit
, mining
, mmetric
, savemining
and Importance
.
### regression
y=c(1,5,10,11,7,3,2,1);x=rnorm(length(y),0,1.0)+y
mgraph(y,x,graph="RSC",Grid=10,col=c("blue"))
mgraph(y,x,graph="REG",Grid=10,lty=1,col=c("black","blue"),
leg=list(pos="topleft",leg=c("target","predictions")))
mgraph(y,x,graph="REP",Grid=10)
mgraph(y,x,graph="REP",Grid=10,sort=FALSE)
x2=rnorm(length(y),0,1.2)+y;x3=rnorm(length(y),0,1.4)+y;
L=vector("list",3); pred=vector("list",1); test=vector("list",1);
pred[[1]]=y; test[[1]]=x; L[[1]]=list(pred=pred,test=test,runs=1)
test[[1]]=x2; L[[2]]=list(pred=pred,test=test,runs=1)
test[[1]]=x3; L[[3]]=list(pred=pred,test=test,runs=1)
# distance line comparison graph:
mgraph(L,graph="DLC",metric="MAE",leg=c("x1","x2","x3"),main="MAE errors")
# new REC multi-curve single graph with NAREC (normalized Area of REC) values
# for maximum tolerance of val=0.5 (other val values can be used)
e1=mmetric(y,x,metric="NAREC",val=5)
e2=mmetric(y,x2,metric="NAREC",val=5)
e3=mmetric(y,x3,metric="NAREC",val=5)
l1=paste("x1, NAREC=",round(e1,digits=2))
l2=paste("x2, NAREC=",round(e2,digits=2))
l3=paste("x3, NAREC=",round(e3,digits=2))
mgraph(L,graph="REC",leg=list(pos="bottom",leg=c(l1,l2,l3)),main="REC curves")
### regression example with mining
## Not run:
data(sin1reg)
M1=mining(y~.,sin1reg[,c(1,2,4)],model="mr",Runs=5)
M2=mining(y~.,sin1reg[,c(1,2,4)],model="mlpe",nr=3,maxit=50,size=4,Runs=5,feature="simp")
L=vector("list",2); L[[1]]=M2; L[[2]]=M1
mgraph(L,graph="REC",xval=0.1,leg=c("mlpe","mr"),main="REC curve")
mgraph(L,graph="DLC",metric="TOLERANCE",xval=0.01,
leg=c("mlpe","mr"),main="DLC: TOLERANCE plot")
mgraph(M2,graph="IMP",xval=0.01,leg=c("x1","x2"),
main="sin1reg Input importance",axis=1)
mgraph(M2,graph="VEC",xval=1,main="sin1reg 1-D VEC curve for x1")
mgraph(M2,graph="VEC",xval=1,
main="sin1reg 1-D VEC curve and histogram for x1",data=sin1reg)
## End(Not run)
### classification example
## Not run:
data(iris)
M1=mining(Species~.,iris,model="rpart",Runs=5) # decision tree (DT)
M2=mining(Species~.,iris,model="ksvm",Runs=5) # support vector machine (SVM)
L=vector("list",2); L[[1]]=M2; L[[2]]=M1
mgraph(M1,graph="ROC",TC=3,leg=-1,baseline=TRUE,Grid=10,main="ROC")
mgraph(M1,graph="ROC",TC=3,leg=-1,baseline=TRUE,Grid=10,main="ROC",intbar=FALSE)
mgraph(L,graph="ROC",TC=3,leg=c("SVM","DT"),baseline=TRUE,Grid=10,
main="ROC for virginica")
mgraph(L,graph="LIFT",TC=3,leg=list(pos=c(0.4,0.2),leg=c("SVM","DT")),
baseline=TRUE,Grid=10,main="LIFT for virginica")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.