knitr::opts_chunk$set(echo = TRUE)

The alpha parameter

Under certain circumstances, it may be necessary to tune the form of the elastic energy to obtain a better results. This is the case, for example, when an excessive number of branches is introduced by the tree grammar.

To tune the elastic energy, it is necessary to set FinalEnergy = "Penalized" and specify values for the alpha parameter. This parameter can be used to give more weight to the components of the energy associted with the lenght of the edges, hence penalizing graphs that are longer. Increasing alpha will penalize stars with a larger number of edges, and will preferentially introduce 3-stars.

Excessinve branching due to noise

To exemplify the effect of alpha, we will increase the level of noise around the &st and 2nd dimension of the tree example dataset. This will generate spurious clusters of points that are likely to be identified as branches.

library(ElPiGraph.R)
set.seed(42)

nExp <- 1

NewPoints <- lapply(1:nExp, function(x){
  tree_data[,1:2] + rnorm(n = length(tree_data[,1:2]), sd = .15)
})

NewPoints <- do.call(rbind, NewPoints)

NoisyTree <- rbind(tree_data[,1:2], NewPoints)
NoisyTree_Cat <- c(rep("Real", nrow(tree_data)), rep("Noise", nrow(NewPoints)))
TreeEPG <- computeElasticPrincipalTree(X = NoisyTree, NumNodes = 60,
                                       Lambda = .001, Mu = .01,
                                       drawAccuracyComplexity = FALSE,
                                       drawEnergy = FALSE,
                                       drawPCAView = FALSE,
                                       n.cores = 1)
PlotPG(X = NoisyTree, TargetPG = TreeEPG[[1]], GroupsLab = NoisyTree_Cat,
       Do_PCA = FALSE)
TreeEPG <- computeElasticPrincipalTree(X = NoisyTree, NumNodes = 50,
                                       Lambda = .001, Mu = .01,
                                       drawAccuracyComplexity = FALSE,
                                       drawEnergy = FALSE, drawPCAView = FALSE,
                                       n.cores = 1,
                                       FinalEnergy = "Rebalanced",
                                       alpha = .1, beta = 1, gamma = 0)
PlotPG(X = NoisyTree, TargetPG = TreeEPG[[1]], GroupsLab = NoisyTree_Cat,
       Do_PCA = FALSE)
TreeEPG <- computeElasticPrincipalTree(X = NoisyTree, NumNodes = 60,
                                       Lambda = .001, Mu = .1,
                                       drawAccuracyComplexity = FALSE,
                                       drawEnergy = FALSE, drawPCAView = FALSE,
                                       n.cores = 1,
                                       FinalEnergy = "Penalized",
                                       alpha = 0.02)
PlotPG(X = NoisyTree, TargetPG = TreeEPG[[1]], GroupsLab = NoisyTree_Cat,
       Do_PCA = FALSE)

Note that when using elastic energy controlled graph embeddment (Mode = 2) the standard energy funtion will be used.

TreeEPG <- computeElasticPrincipalTree(X = NoisyTree, NumNodes = 60,
                                       Lambda = .001, Mu = .1,
                                       drawAccuracyComplexity = FALSE,
                                       drawEnergy = FALSE, drawPCAView = FALSE,
                                       n.cores = 1,
                                       FinalEnergy = "PenalizedV2", Mode = 2,
                                       alpha = 1.3)
PlotPG(X = NoisyTree, TargetPG = TreeEPG[[1]], GroupsLab = NoisyTree_Cat,
       Do_PCA = FALSE)


Albluca/ElPiGraph.R documentation built on May 28, 2019, 11:02 a.m.