/
ppgmmga.Rmd
147 lines (117 loc) · 3.22 KB
/
ppgmmga.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
---
title: "A quick tour of ppgmmga"
author:
- Alessio Serafini, Luca Scrucca
date: "`r format(Sys.time(), '%d %b %Y')`"
output:
rmarkdown::html_vignette:
toc: true
number_sections: false
# highlight: "monochrome"
css: "vignette.css"
vignette: >
%\VignetteIndexEntry{A quick tour of ppgmmga}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---
```{r setup, include=FALSE}
library(knitr)
opts_chunk$set(fig.align = "center",
out.width = "80%",
fig.width = 6, fig.height = 5,
dev.args = list(pointsize = 10),
par = TRUE, # needed for setting hook
collapse = TRUE, # collapse input & ouput code in chunks
message = FALSE,
warning = FALSE)
knit_hooks$set(par = function(before, options, envir)
{ if(before && options$fig.show != "none")
par(family = "sans", mar=c(4.1,4.1,1.1,1.1), mgp=c(3,1,0), tcl=-0.5)
})
```
# Introduction
An R package implementing a Projection Pursuit algorithm based on finite Gaussian Mixtures Models for density estimation using Genetic Algorithms (PPGMMGA) to maximise a Negentropy index.
The **PPGMMGA** algorithm provides a method to visualise high-dimensional data in a lower-dimensional space, with special reference to reveal clustering structures.
```{r, message = FALSE, echo=1}
library(ppgmmga)
cat(ppgmmga:::ppgmmgaStartupMessage(), sep="")
```
# Banknote data
```{r, fig.width = 7, fig.height = 6, out.width = "100%"}
library(mclust)
data("banknote")
X <- banknote[,-1]
Class <- banknote$Status
table(Class)
Class_color <- ggthemes::tableau_color_pal("Classic 10")(2)
clPairs(X, classification = Class,
symbols = ppgmmga.options("classPlotSymbols"),
colors = ppgmmga.options("classPlotColors"))
```
# 1-dimensional PPGMMGA
```{r}
PP1D <- ppgmmga(data = X, d = 1, seed = 1)
PP1D
summary(PP1D)
```
```{r, out.width="60%", fig.width=6, fig.height=4}
plot(PP1D)
```
```{r, out.width="70%", fig.width=7, fig.height=4}
plot(PP1D, class = Class)
```
# 2-dimensional PPGMMGA
```{r}
PP2D <- ppgmmga(data = X, d = 2, seed = 1)
summary(PP2D)
summary(PP2D$GMM)
```
```{r}
plot(PP2D$GA)
```
```{r}
plot(PP2D)
```
```{r, fig.width = 7, fig.height = 5}
plot(PP2D, class = Class, drawAxis = FALSE)
```
# 3-dimensional PPGMMGA
```{r}
PP3D <- ppgmmga(data = X, d = 3,
center = TRUE, scale = FALSE,
gatype = "gaisl",
options = ppgmmga.options(numIslands = 2),
seed = 1)
summary(PP3D)
```
```{r}
plot(PP3D$GA)
```
```{r, fig.width = 7, fig.height = 6, out.width = "100%"}
plot(PP3D)
```
```{r, fig.width = 7, fig.height = 6, out.width = "100%"}
plot(PP3D, class = Class)
```
```{r, fig.width = 6, fig.height = 5}
plot(PP3D, dim = c(1,2))
```
```{r, fig.width = 7, fig.height = 5, out.width = "90%"}
plot(PP3D, dim = c(1,3), class = Class)
```
```{r, eval=FALSE}
# A rotating 3D plot can be obtained using
if(!require("msir")) install.packages("msir")
msir::spinplot(PP3D$Z, markby = Class,
pch.points = c(20,17),
col.points = Class_color)
```
<br><br>
# References
```{r, echo=FALSE, results='asis'}
print(citation("ppgmmga"), style = "text")
```
----
```{r}
sessionInfo()
```