class of the fluid is carried by its vorticity.

######  Definition 4.168.

The _Godbillon-Vey number_ $\mathtt{gv}({\mathcal{F}})$ of the foliation
${\mathcal{F}}$ is the integral121212Here and throughout the rest of the
section we assume that integration on $M^{3}$ is well-defined. For simplicity,
one may take $M^{3}$ to be compact. invariant associated to the Godbillon-Vey
class $\mathtt{GV}({\mathcal{F}})=[\alpha_{v}\wedge\mathrm{d}\alpha_{v}]$:

$\mathtt{gv}({\mathcal{F}})\coloneqq\int_{M^{3}}\,\alpha_{v}\wedge\mathrm{d}\alpha_{v}\
.$ (4.169)

We can establish how a global conservation law arises from the Godbillon-Vey
invariant for a three-dimensional Aristotelian fluid flow through

######  Proposition 4.170.

The Godbillon-Vey number $\mathtt{gv}({\mathcal{F}})$ of an Aristotelian fluid
in three dimensions is a conserved quantity along the fluid lines if $M^{3}$
is closed, i.e. it yields the conservation law

$\frac{\mathrm{d}\,\mathtt{gv}({\mathcal{F}})}{\mathrm{d}t}=0\ .$ (4.171)

If $\partial M^{3}\neq\varnothing,$ then Equation (4.171) holds if the
vorticity vector field $\xi=\mathrm{curl}(v)$ is parallel to the boundary of
$M^{3}$.

###### Proof.

Since the velocity $v\in\mathsf{\Gamma}_{\mu}(TM^{3})$ preserves the volume
form $\mu,$ we can integrate Equation (4.159) to obtain

$\displaystyle\frac{\mathrm{d}\,\mathtt{gv}({\mathcal{F}})}{\mathrm{d}t}$
$\displaystyle=\int_{M^{3}}\,\frac{\mathrm{D}}{\mathrm{D}t}\big{(}\alpha_{v}\wedge\mathrm{d}\alpha_{v}\big{)}$
$\displaystyle=\int_{M^{3}}\,\mathrm{d}\Bigl{(}\big{(}\kappa\,v^{\flat}+\tfrac{1}{s_{v}}\,(\pounds_{v}\log
s_{v})\,\iota_{v}\,\omega_{\xi}-\tfrac{1}{s_{v}}\,(\pounds_{v}\log
s_{v})\,\mathrm{d}(p-\tfrac{s_{v}}{2})\big{)}\wedge\alpha_{v}\Bigr{)}\ .$

By Stokes’ Theorem the right-hand side is a boundary integral, which vanishes
because both $v$ and $\xi$ are taken to be parallel to the boundary $\partial
M^{3}$. By the vorticity equation $\frac{\partial\xi}{\partial t}=[\xi,v]$,
the flow of the vorticity vector field ensures that $\xi$ remains parallel to
the boundary at any time. When $M^{3}$ is closed this vanishes without any
further conditions. ∎

######  Remark 4.172.

The conservation law arising from the stronger setting of Corollary 4.164, for
a fluid flow on a three-manifold with non-empty boundary, relies solely on the
assumption that the vorticity vector field $\xi$ is parallel to the boundary
and hence so is its flow.

The Godbillon-Vey number $\mathtt{gv}({\mathcal{F}})$ is the helicity
${\mathcal{H}}(\zeta)$ of the null homologous vector field $\zeta$ defined by
[21]

$\iota_{\zeta}\mu=\pounds_{v}(\pounds_{v}\tau)\wedge\tau\ .$ (4.173)

The vector field $\zeta$ measures the angular acceleration of the rotation
determined by the vorticity $\xi.$ This can be potentially extended to the
Carrollian hydrodynamics of [12] as a relevant case in which the helicity of
the vorticity is non-vanishing.

######  Remark 4.174.

The helical wobble discussed in Example 3.32 inspires the following local
geometric interpretation of the Godbillon-Vey class as helical compression of
vorticity for an Aristotelian fluid in three dimensions, which is reflected in
the non-linearity of the Euler equations. Our interpretation builds on and
extends the discussion of [25] (see also [23]).

Let $\alpha\in\mathsf{\Omega}^{1}(M^{3})$ be a one-form satisfying the
integrability equation for the clock form $\tau.$ Then the dual vector field
$\alpha^{\sharp}$ measures the local compression (or expansion) of the leaves
of the foliation ${\mathcal{F}},$ i.e. the sections of the fluid flowing along
the fluid lines. In particular, its norm $g(\alpha^{\sharp},\alpha^{\sharp})$
measures the curvature of the fluid lines, which are normal to ${\mathcal{F}}$
with respect to $g.$ This quantity also determines the flow of the Godbillon-
Vey class $\mathtt{GV}({\mathcal{F}})$, as seen in Equation (4.165) where it
is the main contributing factor together with the vorticity $\xi$ and density
$\mu,$ if the pressure $p$ is constant and the speed of the fluid $s_{v}$ is
constant along the fluid lines, i.e. $\pounds_{v}s_{v}=0.$

The direction of $\alpha^{\sharp}$ determines the direction in which the
leaves of ${\mathcal{F}}$ expand. Because
$g(\alpha^{\sharp},\mathrm{curl}(\alpha^{\sharp}))\neq 0,$ the twist of
$\alpha^{\sharp}$ transverse to the leaves measures the topological helical
compression of the vortex lines. The Godbillon-Vey class
$\mathtt{GV}({\mathcal{F}})$ measures the local spin of $\alpha^{\sharp}$ in
the direction of the fluid lines, i.e. transversally to the fluid sections
determined by ${\mathcal{F}}.$ The Godbillon-Vey number
$\mathtt{gv}({\mathcal{F}})$ gives a global measure of this spin.

######  Example 4.175 (Hydrodynamics with Roussarie Foliations).

We study Aristotelian fluid flows, with non-trivial torsion and Godbillon-Vey
invariant, on three-dimensional domains that admit a _Roussarie foliation_ ,
which we construct following [43]. Consider the Lie group
$\mathsf{PSL}(2,\mathbb{R})$ whose Lie algebra ${\mathfrak{sl}}(2,\mathbb{R})$
is characterised by a basis of generators $\mathsf{b}=\\{T_{0},T_{1},T_{2}\\}$
in which the Lie brackets are

$\displaystyle[T_{1},T_{2}]=T_{0}\
,\quad[T_{0},T_{1}]=2\,T_{1}\qquad\mbox{and}\qquad[T_{0},T_{2}]=-2\,T_{2}\ .$
(4.176)

Let $\mathsf{\Lambda}\subset\mathsf{PSL}(2,\mathbb{R})$ be a torsion-free
cocompact discrete subgroup, acting on $\mathsf{PSL}(2,\mathbb{R})$ by left
multiplication. Then
$M^{3}\coloneqq\mathsf{\Lambda}\setminus\mathsf{PSL}(2,\mathbb{R})$ is a
compact connected three-manifold.

The three-manifold $M^{3}$ inherits the global frame
$\mathsf{F}=\\{X_{0},X_{1},X_{2}\\}\subset\mathsf{\Gamma}(TM^{3})$ from the
left-invariant vector fields on $\mathsf{PSL}(2,\mathbb{R})$ associated with
the basis of generators $\mathsf{b}.$ The Lie subalgebra

$\displaystyle\mathfrak{l}\coloneqq\mathrm{Span}\\{T_{0},T_{1}\\}\ \subset\
\mathfrak{sl}(2,\mathbb{R})$ (4.177)

induces a left-invariant foliation of $\mathsf{PSL}(2,\mathbb{R})$ that
descends to $M^{3}$, which is characterised as follows. Let
$\mathsf{F}^{\textrm{\tiny$\vee$}}=\\{\theta_{0},\theta_{1},\theta_{2}\\}\subset\mathsf{\Omega}^{1}(M^{3})$
be the global coframe dual to $\mathsf{F}.$ Then the foliation ${\mathcal{F}}$
of $M^{3}$ is given by the distribution $T{\mathcal{F}}=\ker(\theta_{2}),$
where the one-form $\theta_{2}$ satisfies the integrability condition (2.11)
with

$\displaystyle\mathrm{d}\theta_{2}=2\,\theta_{2}\wedge\theta_{0}\ ,$ (4.178)

which is a consequence of the Maurer-Cartan equations for the Lie group
$\mathsf{PSL}(2,\mathbb{R})$.

We define an Aristotelian fluid flowing in $M^{3}$ by taking, at an initial
time $t=t_{0}$, the Aristotelian structure on $M^{3}$ to be given by the clock
form and velocity vector field

$\displaystyle\tau=\theta_{2}\qquad\mbox{and}\qquad v=X_{2}\ ,$ (4.179)

together with any Riemannian metric $h$ on $T{\mathcal{F}}.$ A natural choice
for the spatial metric $h$ is the descendant from the left-invariant metric on
the foliation of $\mathsf{PSL}(2,\mathbb{R})$ for which its left-invariant
generating vector fields are orthonormal:

$h=\theta_{0}\otimes\theta_{0}+\theta_{1}\otimes\theta_{1}\ .$ (4.180)

Then we allow the Aristotelian structure to evolve in time according to the
Euler equations on $M^{3}$, with respect to the background Riemannian metric

$\displaystyle g=h+\tfrac{1}{2}\,\theta_{2}\otimes\theta_{2}\ .$ (4.181)

Hence the initial speed of the fluid is $s_{v}=1.$ Assuming that the speed
remains constant at all times $t\in\mathbb{R}$, by Proposition 4.56 it follows
that only pressure fields $p\in C^{\infty}(M^{3})$ that are invariant along
the fluid lines are permissible, i.e. $\pounds_{X_{2}}p=0.$

Lastly, the fluid density $\mu$ is given by the volume form induced on $M^{3}$
by the natural left-invariant volume form on $\mathsf{PSL}(2,\mathbb{R})$:

$\mu=\theta_{0}\wedge\theta_{1}\wedge\theta_{2}\ .$ (4.182)

Hence the condition $\pounds_{X_{2}}\mu=0$ for divergence-free flow is
satisfied. Equation (4.178) yields

$\displaystyle\alpha=\alpha_{v}=2\,\theta_{0}\ .$ (4.183)

Together with the fluid density $\mu$, this determines the vorticity vector
field and two-form

$\displaystyle\xi=2\,X_{1}\qquad\mbox{and}\qquad\omega_{\xi}=2\,\theta_{2}\wedge\theta_{0}\
.$ (4.184)

This provides a complete characterisation of the fluid at the initial time
$t=t_{0}$. Let us now determine its flow equations. By Lemma 4.12 the Euler
flow equation reads

$\displaystyle\frac{\partial X_{2}}{\partial
t}=(-2\,\theta_{0}-\mathrm{d}p)^{\sharp}\ .$ (4.185)

With respect to the choice of spatial metric $h$ in Equation (4.180), the dual
of the flow equation (4.185) gives the transport equation for the clock form
$\tau=\theta_{2}$:

$\displaystyle\frac{\partial\theta_{2}}{\partial
t}+2\,\theta_{0}=-\mathrm{d}p\ .$ (4.186)

Using Equation (4.91), in this case the torsion tensor is determined as the
two-form

$\bar{T}^{\nabla^{\mathtt{A}}}=2\,\theta_{2}\wedge\theta_{0}\ .$ (4.187)

Since $s_{v}=1$ and $\pounds_{X_{2}}p=0,$ from Equation (4.96) it follows that
it gives rise to a conservation law

$\displaystyle\frac{\mathrm{D}\bar{T}^{\nabla^{\mathtt{A}}}}{\mathrm{D}t}=\frac{\partial\bar{T}^{\nabla^{\mathtt{A}}}}{\partial
t}=0\ .$ (4.188)

Foliations such as the Roussarie foliation ${\mathcal{F}}$ of the quotient
manifold $M^{3}$ are well-known to have a non-trivial Godbillon-Vey class
$\mathtt{GV}({\mathcal{F}})$. Here it is represented by the three-form

$\displaystyle\alpha_{v}\wedge\mathrm{d}\alpha_{v}=\alpha\wedge\mathrm{d}\alpha=4\,\theta_{0}\wedge\theta_{1}\wedge\theta_{2}\
,$ (4.189)

which by Corollary 4.164 has flow equation

$\displaystyle\frac{\mathrm{D}}{\mathrm{D}t}\big{(}\alpha_{v}\wedge\mathrm{d}\alpha_{v}\big{)}=4\,\frac{\partial}{\partial
t}\big{(}\theta_{0}\wedge\theta_{1}\wedge\theta_{2}\big{)}=\mathrm{d}\kappa\wedge\bar{T}^{\nabla^{\mathtt{A}}}\
,$ (4.190)

where

$\kappa=-2\,g^{-1}(2\,\theta_{0}+\mathrm{d}p,\theta_{0})\ .$ (4.191)

Hence the torsion of the flow determines the time evolution of the Godbillon-
Vey class, together with the pressure field $p$ and the spatial metric $h$. If
the spatial metric is given by Equation (4.180), then
$\kappa=-2\,(2+\iota_{X_{0}}\,\mathrm{d}p).$

Since the torsion tensor is a conserved quantity, Equation (4.190) simplifies
to

$\displaystyle 2\,\frac{\partial\theta_{1}}{\partial t}=\mathrm{d}\kappa\ ,$
(4.192)

which determines the time evolution of $\theta_{1}.$ From Equation 4.66 the
flow equation for the one-form $\alpha_{v}$ gives

$\displaystyle\frac{\partial\theta_{0}}{\partial
t}+\theta_{1}=-\frac{\kappa}{2}\,\theta_{2}\ .$ (4.193)

Together with Equations (4.192) and (4.186), this completely determine the
time evolution of the coframe
$\mathsf{F}^{\textrm{\tiny$\vee$}}=\\{\theta_{0},\theta_{1},\theta_{2}\\}$,
given the set of initial data considered above. Conversely, given the flow of
the coframe, the pressure field can be determined.

By Proposition 4.129, in this example the flow equations cannot have a
stationary solution. This has a direct consequence on the time dependence of
the pressure field $p$.

## References

  * [1] E. Bergshoeff, J. Figueroa-O’Farrill and J. Gomis, _A non-lorentzian primer_ , [2206.12177].
  * [2] G. Oling and Z. Yan, _Aspects of Nonrelativistic Strings_ , _Front. Phys._ 10 (2022) 832271 [2202.12698].
  * [3] C. Godbillon and J. Vey, _Un invariant des feuilletages de codimension 1_ , _C. R. Acad. Sci. Paris A_ 273 (1971) 92.
  * [4] B. L. Reinhart and J. W. Wood, _A Metric Formula for the Godbillon-Vey Invariant for Foliations_ , _Proc. Amer. Math. Soc._ 38 (1973) 427.
  * [5] S. Hurder and R. Langevin, _Dynamics and the Godbillon-Vey class of $C^{1}$-foliations_, _J. Math. Soc. Japan_ 70 (2018) 423 [1403.0494].
  * [6] R. Brooks and W. Goldman, _The Godbillon-Vey invariant of a transversely homogeneous foliation_ , _Trans. Amer. Math. Soc._ 38 (1973) 651.
  * [7] W. Thurston, _Noncobordant Foliations of $S^{3}$_, _Bull. Amer. Math. Soc._ 78 (1972) 511.
  * [8] M. Geracie, K. Prabhu and M. M. Roberts, _Fields and fluids on curved non-relativistic spacetimes_ , _JHEP_ 08 (2015) 042 [1503.02680].
  * [9] N. Poovuttikul and W. Sybesma, _First order non-Lorentzian fluids, entropy production and linear instabilities_ , _Phys. Rev. D_ 102 (2020) 065007 [1911.00010].
  * [10] J. Armas, J. Hartong, E. Have, B. F. Nielsen and N. A. Obers, _Newton-Cartan Submanifolds and Fluid Membranes_ , _Phys. Rev. E_ 101 (2020) 062803 [1912.01613].
  * [11] J. de Boer, J. Hartong, N. A. Obers, W. Sybesma and S. Vandoren, _Perfect Fluids_ , _SciPost Phys._ 5 (2018) 003 [1710.04708].
  * [12] L. Freidel and P. Jai-akson, _Carrollian hydrodynamics from symmetries_ , _Class. Quant. Grav._ 40 (2023) 055009 [2209.03328].
  * [13] A. Bagchi, K. S. Kolekar and A. Shukla, _Carrollian Origins of Bjorken Flow_ , [2302.03053].
  * [14] J. de Boer, J. Hartong, E. Have, N. A. Obers and W. Sybesma, _Non-Boost Invariant Fluid Dynamics_ , _SciPost Phys._ 9 (2020) 018 [2004.10759].
  * [15] J. Armas and A. Jain, _Effective field theory for hydrodynamics without boosts_ , _SciPost Phys._ 11 (2021) 054 [2010.15782].
  * [16] J. Armas and E. Have, _Ideal fracton superfluids_ , [2304.09596].
  * [17] A. Jain, K. Jensen, R. Liu and E. Mefford, _Dipole superfluid hydrodynamics_ , [2304.09852].
  * [18] L. Ciambelli, C. Marteau, A. C. Petkou, P. M. Petropoulos and K. Siampos, _Covariant Galilean versus Carrollian hydrodynamics from relativistic fluids_ , _Class. Quant. Grav._ 35 (2018) 165001 [1802.05286].
  * [19] A. C. Petkou, P. M. Petropoulos, D. R. Betancour and K. Siampos, _Relativistic fluids, hydrodynamic frames and their Galilean versus Carrollian avatars_ , _JHEP_ 09 (2022) 162 [2205.09142].
  * [20] A. V. Tur and V. V. Yanovsky, _Invariants in dissipationless hydrodynamic media_ , _J. Fluid Mech._ 248 (1993) 67.
  * [21] V. I. Arnold and B. A. Khesin, _Topological Methods in Hydrodynamics_. Springer-Verlag, 1998.
  * [22] G. M. Webb, B. Dasgupta, J. F. McKenzie, Q. Hu and G. P. Zank, _Local and nonlocal advected invariants and helicities in magnetohydrodynamics and gas dynamics I: Lie dragging approach_ , _J. Phys. A_ 47 (2014) 095501 [1307.1105].
  * [23] G. M. Webb, A. Prasad, S. C. Anco and Q. Hu, _Godbillon-Vey helicity and magnetic helicity in magnetohydrodynamics_ , _J. Plasma Phys._ 85 (2019) 775850502 [1909.07291].
  * [24] T. Machon, _The Godbillon-Vey invariant as a restricted Casimir of three-dimensional ideal fluids_ , _J. Phys. A_ 53 (2020) 235701 [2001.01305].
  * [25] T. Machon, _The Godbillon-Vey invariant as topological vorticity compression and obstruction to steady flow in ideal fluids_ , _Proc. R. Soc. A_ 476 (2020) 20190851 [2002.09992].
  * [26] H. Geng, S. Kachru, A. Karch, R. Nally and B. C. Rayhaun, _Fractons and Exotic Symmetries from Branes_ , _Fortsch. Phys._ 69 (2021) 2100133 [2108.08322].
  * [27] L. Bidussi, J. Hartong, E. Have, J. Musaeus and S. Prohazka, _Fractons, dipole symmetries and curved spacetime_ , _SciPost Phys._ 12 (2022) 205 [2111.03668].
  * [28] A. Jain and K. Jensen, _Fractons in curved space_ , _SciPost Phys._ 12 (2022) 142 [2111.03973].
  * [29] J. Figueroa-O’Farrill, _On the intrinsic torsion of spacetime structures_ , [2009.01948].
  * [30] X. Bekaert and K. Morand, _Connections and dynamical trajectories in generalised Newton-Cartan gravity I. An intrinsic view_ , _J. Math. Phys._ 57 (2016) 022507 [1412.8212].
  * [31] H. P. Künzle, _Galilei and Lorentz structures on spacetime: comparison of the corresponding geometry and physics_ , _Ann. l’Inst. Henri Poincaré A_ 17 (1972) 337.
  * [32] I. Moerdijk and J. Mrčun, _Introduction to Foliations and Lie Groupoids_. Cambridge University Press, 2003.
  * [33] M. Spivak, _A Comprehensive Introduction to Differential Geometry, Volume 2_. Publish or Perish, 1970.
  * [34] D. Calegari, _Foliations and the Geometry of 3-manifolds_. Oxford University Press, 2007.
  * [35] D. Pereñiguez, _$p$ -brane Newton-Cartan geometry_, _J. Math. Phys._ 60 (2019) 112501 [1908.04801].
  * [36] S. Ebert, H.-Y. Sun and Z. Yan, _Dual D-brane actions in nonrelativistic string theory_ , _JHEP_ 04 (2022) 161 [2112.09316].
  * [37] L. Bidussi, T. Harmark, J. Hartong, N. A. Obers and G. Oling, _Torsional string Newton-Cartan geometry for non-relativistic strings_ , _JHEP_ 02 (2022) 116 [2107.00642].
  * [38] C. D. A. Blair, D. Gallegos and N. Zinnato, _A non-relativistic limit of M-theory and 11-dimensional membrane Newton-Cartan geometry_ , _JHEP_ 10 (2021) 015 [2104.07579].
  * [39] D. Peralta-Salas, A. Rechtman and F. Torres de Lizaur, _A characterization of 3D steady Euler flows using commuting zero-flux homologies_ , _Ergod. Th. Dynam. Sys._ 41 (2021) 2166 [1904.00960].
  * [40] L. Napper, I. Roulstone, V. Rubtsov and M. Wolf, _Monge-Ampère geometry and vortices_ , [2302.11604].
  * [41] V. Rovenski and P. Walczak, _Variations of the Godbillon-Vey Invariant of Foliated 3-Manifolds_ , _Complex Anal. Oper. Theory_ 13 (2019) 2917.
  * [42] R. Cardona, _The topology of Bott integrable fluids_ , _Discrete Contin. Dyn. Syst._ 42 (2022) 4321 [2006.16880].
  * [43] S. Morita, _Geometry of Characteristic Classes_. American Mathematical Society, 2001.


# Cross Version Defect Prediction with Class Dependency Embeddings

Moti Cohen<EMAIL_ADDRESS><EMAIL_ADDRESS>Lior Rokach
<EMAIL_ADDRESS>Rami Puzis<EMAIL_ADDRESS>Department of Software and
Information Systems Engineering, Ben Gurion University of The Negev

###### Abstract

Software Defect Prediction aims at predicting which software modules are the
most probable to contain defects. The idea behind this approach is to save
time during the development process by helping find bugs early. Defect
Prediction models are based on historical data. Specifically, one can use data
collected from past software distributions, or Versions, of the same target
application under analysis. Defect Prediction based on past versions is called
Cross Version Defect Prediction (CVDP). Traditionally, Static Code Metrics are
used to predict defects. In this work, we use the Class Dependency Network
(CDN) as another predictor for defects, combined with static code metrics. CDN
data contains structural information about the target application being
analyzed. Usually, CDN data is analyzed using different handcrafted network
measures, like Social Network metrics. Our approach uses network embedding
techniques to leverage CDN information without having to build the metrics
manually. In order to use the embeddings between versions, we incorporate
different embedding alignment techniques. To evaluate our approach, we
performed experiments on 24 software release pairs and compared it against
several benchmark methods. In these experiments, we analyzed the performance
of two different graph embedding techniques, three anchor selection
approaches, and two alignment techniques. We also built a meta-model based on
two different embeddings and achieved a statistically significant improvement
in AUC of 4.7% ($p<0.002$) over the baseline method.

###### keywords:

Defect Prediction , Network Embedding , Class Dependency.

††journal: Expert Systems with Applications

##  1 Introduction

Software Development is a very long and complicated process, involving many
stages and multiple participants. More so, today’s software systems have
become large and highly complex. Given these characteristics of the software
development process, it is inevitable that some defects will end up in
applications. Software Quality Assurance procedures provide a means to try and
locate these defects. These procedures are very time-consuming and not
complete, and usually involve intensive human intervention (unit test writing,
for example). In order to help focus quality assurance efforts, many defect
prediction and detection approaches were developed. In the last few decades,
much progress has been made in using machine learning techniques to help in
defect prediction and identification [20].

In the field of Defect Prediction, one can divide the different approaches
into two main categories. The first is Cross Project Defect Prediction (CPDP),
which performs transfer learning from one project to another. The main issue
in CPDP is to find from which project to learn and how to transfer the learned
model so that the model will be valid for the target project.

The second category is Within Project Defect Prediction (WPDP) aims at
predicting defective code in a given project using the same project’s past
data. This approach can be divided into two subcategories: Inner Version
Defect Prediction (IVDP) and Cross Version Defect Prediction (CVDP). In IVDP,
data from the same project version is used as training data and test data,
while in CVDP, data from past project versions are used as training data while
the latest (”new”) version is the test data. The data in IVDP is usually more
homogeneous, but this scenario is usually less realistic, and the data
available is usually sparse. In the case of CVDP, there is usually more data,
but the distribution tends to change between versions, making it hard to
transfer the knowledge. The focus of our work is on the CVDP scenario.

Class Dependency data was used in different studies to predict software
defects(e.g.[40, 27],[26],[21]). Most studies use manually crafted features
over the Class Dependency Network, usually Social Network measures. In [27],
graph embedding was first used to generate automatic features from CDN for the
Defect Prediction process, specifically in a IVDP setup. In this work, we try
to apply the same methodology but in the more complex CVDP setup. This higher
complexity is because software modules exhibit different statistics in
different versions[37]. In order to use embeddings in a cross-version setup,
we need to align the embeddings learned in the test set to the embeddings from
the train set. We use different alignment techniques and combine the aligned
embeddings with traditional static code metrics to train a classifier and
achieve an improvement over the state-of-the-art baseline method.

The main contributions of our study are:

  * •

We develop a novel approach to module level CVDP, based on a combination of
static code metrics and CDN embeddings. We incorporate the use of embedding
alignment techniques when moving from one version to another.

  * •

We developed two anchor selection techniques for the alignment process and
evaluated them with two alignment procedures. We also used two different
embedding frameworks during the experiments.

  * •

We performed an experimental analysis of our techniques on a public dataset,
with nine software projects written in Java[2]. These projects contain a total
of 24 (old version, new version) pairs. We calculated and analyzed two
performance metrics, AUC and F1-score, and compared them to a state-of-the-art
baseline technique.

  * •

We built a meta-model that combines the best models for each of the embedding
techniques. Our meta-model achieves an improvement of 4.7% in the AUC score
over the baseline method.

Figure 1: A Flowchart of Our Proposed Solution

##  2 Related Work

###  2.1 Cross Version Defect Prediction

There have been a lot of research done in the area of Defect Prediction [25,
17, 11]. Most of these studies were done in the areas of same-version and
cross-project defect prediction. To the best of our knowledge, the field of
cross-version defect prediction has been less studied. Zimmerman et al. [41]
were one of the first who showed that models learned from past versions data
are useful in predicting defects in future releases. They conducted an
experiment on Eclipse bug data over three releases and showed that models
learned from past releases give consistent results compared to same-version
models. In [8], the authors conducted a cross-version evaluation of 11
different prediction models. The dataset used was 25 open source projects,
having two releases each. They used seven process metrics as the features, and
no code features. Bennin et al. [7] analyzed the impact of data sampling on
CVDP. They used 20 pairs of software versions and analyzed the impact of six
data sampling techniques on classification performance. They also used five
different classifiers for the experiment. They concluded that data sampling is
beneficial for defect prediction, given that many datasets are imbalanced. Xu
et al. [38] tried to tackle the issue that software applications evolve, and
with it, the distribution of different metrics collected. To address this
issue, they devised a two-phase framework for CVDP. The first step (called
HALKP) is a hybrid active learning technique which selects modules from the
current version (which are unlabeled), based on different measures, and
consults an expert that assigns a label to it. This labeled instance is merged
with the previous version’s dataset, and the process continues. When they
decide to stop the process, the result is a dataset of combined previous and
current version instances. The second phase performs Kernel PCA (KPCA) to map
all instances (labeled and unlabeled) to a new feature space. The result of
this process is fed into a regular classifier. They show that their technique
improves classification performance over a baseline with just the original
features. Amasaki [5] investigated the performance of CPDP techniques in a
CVDP scenario. In this study, Amasaki evaluated the performance of 20 CPDP
techniques in two different scenarios: Single Older Version(SOV) and Multiple
Older Versions(MOV). They used 11 different projects for the experiment, with
3 to 5 versions each. The experiment had two interesting results:  1. CPDP
techniques can be useful in CVDP scenario 2. Using multiple past versions also
improves the prediction performance. Yang et al.[39] performed a different
CVDP study, trying to sort software modules according to defect count
prediction. The idea was to predict which modules might contain more bugs,
rather than simply predicting if a module has or does not have at least one
bug. They investigated the performance of Ridge and Lasso Regression in this
sorting problem. They concluded that although the datasets used have some
issues, the analyzed methods perform better than linear regression and
negative binomial regression on CVDP. Shukla et al.[30] formulated the CVDP
problem as a multi-objective optimization problem, trying to maximize recall
by minimizing classification error and QA cost. They compare this method with
basic models and show they have improved recall and achieved a smaller
misclassification error. In [37] the authors tried to tackle the distribution
dissimilarity between versions problem using a subset selection algorithm
called Dissimilarity based Sparse Subset Selection(DS3). The idea is to select
a subset of modules from a past version that best represents the distribution
of the current version, and use these modules as the training set. They
compared this technique with simply using all the original data as the
training set, and showed improved performance in classification accuracy and
effort aware metrics. The authors of [36] tried to improve this technique
further by adding a subset selection from the previous version, which
represents the data well. This subset is later fed into DS3, similar to the
previous work. They show improved results for regular and effort aware
metrics. For this work, they use Static Metrics only. In [13], the authors
used an Attention Based Recurrent Neural Network to encode AST information and
evaluated the performance of this method in a CVDP scenario. They show that
this technique achieves promising results.

###  2.2 Class Dependency Network

The idea behind CDN is to try and capture the structural information of a
given software application. Capturing structural information is achieved by
creating a graph with different relations between software components or
modules. Formally, a CDN is defined [32] as a multi-graph $G=(N,E)$ where $N$
is the set of nodes (modules), and $E$ is the set of edges (relations).

Class Dependency information has been used in different defect prediction
studies. In their seminal work, Zimmerman et al. [40] studied defect
prediction performance when using a combination of network measures and static
code metrics. They concluded that network measures increase recall by 10%,
when performed classification on windows server defect data. Premraj et
al.[26] replicated the experiment on different projects and in a CVDP setup
and concluded that in a CVDP scenario, the network measures offered no added
value. On the other hand, the authors of [21] performed a different evaluation
and concluded that network measures have a positive relation with defects, and
can be used in defect prediction. They also pointed out that these effects are
not consistent in some projects. In [27], the authors used CDN embedding as
the features in a same-version defect prediction scenario, combined with
static code metrics, and showed that this could improve the results of defect
prediction which uses only static code metrics. In a recent study, Qu et al.
[28] used a new approach to analyze CDN for defect prediction. They used
K-core Decomposition on the CDN and observed that modules within high k-cores
have a higher probability of being buggy. They used this new observation in
both IVDP and CVDP scenarios and showed an improvement over baseline methods
in an effort-aware bug prediction scenario.

###  2.3 Graph Embedding

Graph (or network) Embedding is the process of generating a representation of
graph elements in a vector space, which preserves some property desired. There
has been much research in the area[15], and many techniques and applications
have been researched and proposed. Graph embedding techniques have been used
in multiple domains and provided great results. One main advantage of these
techniques is their ability to extract features from graph data automatically,
usually with minor tuning. We will provide a short review of the two embedding
techniques used in this work: Node2vec[16] and LINE[33].

####  2.3.1 Node2vec

Node2vec is a framework for graph embedding. The basic idea comes from a
Natural Language Processing model called Skip-gram [24]. The idea in Node2vec
is to maximize the probability of observing a node’s neighborhood, given its
vector representation. The algorithm tries to learn a vector representation
that tries to maximize that probability. A node’s neighborhood is defined by a
sampling strategy, meaning a node can have different neighborhoods.

The Node2vec algorithm works as follows. For each node in the graph, we sample
a set of random walks from it. The length of the walk, the number of walks and
the sampling strategy can be modified. After sampling the walks, each walk is
used as a ”sentence” in natural language, to represent a node’s context. These
walks are used in the learning process of the embedding function, which maps
each node into a k dimensional embedding (also a parameter). The sampling
strategy used in Node2vec is based on a sampling rule the authors define as a
$2^{nd}$ order random walk with two parameters: $p$ and $q$. Generally
speaking, a sampling strategy can be biased towards ”walking” farther from the
start node (like a Depth First Search) or be biased towards ”staying” close to
the start node (like a Breadth-First Search). A high parameter $p$ value
(relative to $q$) causes a more DFS like sampling, and a high $q$ value
(relative to $p$) causes a more BFS like sampling.

####  2.3.2 LINE

The idea behind LINE (Large-scale Information Network Embedding) is to
generate an embedding that models node proximity similarity. We use second-
order proximity because our graph is directed. Second-order proximity assumes
that similar nodes have similar ”neighborhoods”, meaning connections to nodes.
So the idea is to model these connections and to learn the node similarity
based on these connections. Each node is modeled both as a node and as a
”context” (like modeling its connections). Later, we measure the probability
of getting a node given a context (a different node), and we look for a
representation that generates a distribution as similar as possible to the
empirical distribution, as defined in the original paper.

###  2.4 Embedding Alignment

As described earlier, a graph embedding is a vector representation for each
node or edge, to preserve some target measure. When describing embeddings, we
did not constrain the resulting embedding in any way, meaning there can be
many different embeddings which have the same ”results”. For example, in a
Euclidean vector space, every rotation of an embedding will preserve the
Euclidean distances in that embedding. Even running the same embedding
algorithm on the same dataset can result in a very different embedding space.
In case we have two embeddings of ”similar” items, for example, embeddings of
words from two languages, we might want to align those two embeddings to the
same coordinates system as close as possible while preserving the relations
between the data points. Performing the alignment can give us a unified
representation of the embeddings, enabling operations between the datasets.
These techniques have been used in Natural Language Processing[31, 35]. We
will describe an alignment procedure with parallel points bet1ween two
embeddings.

We start with two embeddings, $E_{1}$ and $E_{2}$. Our goal is to build a
linear transformation $T$ which maps from $E_{2}$ to $E_{1}$. We are also
provided with a set of parallel points, $(x^{(i)},y^{(i)}),x^{(i)}\in
E_{2},y^{(i)}\in E_{1}$. We wish to build $T$ s.t. $T(x^{(i)})\approx
y^{(I)}$. Let X and Y be the matrices whose columns are vectors $x^{(i)}$ and
$y^{(i)}$ respectively. Then we wish to solve

$\min_{T}\|Y-TX\|_{F}$ (1)

where $\|A\|=\sqrt{\sum_{i,j}{{|a_{ij}|}^{2}}}$ is the Frobenius norm. The
general problem is hard to solve, but in constraining the solution to be
orthogonal matrices, we get the Orthogonal Procrustes problem, which has a
closed-form solution. An orthogonal matrix $Q$ is defined by
$Q^{T}Q=QQ^{T}=I$, where $I$ is the identity matrix. Schönemann [29] found the
closed-form solution. if $U\Sigma V$ is the SVD decomposition of $YX^{T}$,
then the solution to (1) is given by $T=UV^{T}$. To the best of our knowledge,
no one has tried using this technique in code embedding alignment.

##  3 Proposed Framework for CVDP

In this section, we will describe our solution framework for CVDP.

###  3.1 Framework Overview

Given a pair of software versions $(\mathcal{V}_{0},\mathcal{V}_{1})$, where
$\mathcal{V}_{0}$ is a prior version to $\mathcal{V}_{1}$, we would like to
build a defect classifier for the modules in $\mathcal{V}_{1}$. Our solution
is composed of a few steps. In the training phase, we do the following:

  1. 1.

Calculate Static Code Metrics for $\mathcal{V}_{0}$ [Section 3.2]

  2. 2.

Extract CDN for $\mathcal{V}_{0}$, marked as $G_{0}=(V_{0},E_{0})$ [Section
3.3].

  3. 3.

Learn an embedding for $G_{0}$ [Section 3.4].

  4. 4.

Learn a Classifier using all the data available for $\mathcal{V}_{0}$ [Section
3.6].

After we built our training model, these are the steps for the classification
phase:

  1. 1.

Calculate Static Code Metrics for $\mathcal{V}_{1}$.

  2. 2.

Extract CDN for $\mathcal{V}_{1}$, marked as $G_{1}=(V_{1},E_{1})$.

  3. 3.

Learn an embedding for $G_{1}$.

  4. 4.

Perform embedding alignment between the embedding for $\mathcal{V}_{1}$ and
the embedding for $V_{0}$ [Section 3.5].

  5. 5.

Perform classification using the aligned embedding for $\mathcal{V}_{1}$.

In the following sections we will describe in detail the different steps of
our framework, and discuss different considerations that arose during the
study.

###  3.2 Static Code Metrics

Static Code Metrics are the classic and state-of-the-art metrics used in
defect prediction. These metrics exist for decades and many different metrics
were developed during the years[14]. Most of these metrics try to capture code
complexity and size, bad class design etc. We use the metrics defined by [10,
18, 6, 22, 34, 23]. The metrics used are described in Table 1.

Metric Name
---
Weighted methods per class[10]
Depth of Inheritance Tree[10]
Number of Children[10]
Coupling Between Object classes[10]
Response for a Class[10]
Lack of cohesion in methods[10]
Lack of cohesion in methods 3[18]
Number of Public Methods[6]
Data Access Metric[6]
Measure of Aggregation [6]
Measure of Functional Abstraction[6]
Cohesion Among Methods of Class[6]
Inheritance Coupling [34]
Coupling Between Methods[34]
Average Method Complexity[34]
Afferent Couplings[22]
Efferent Couplings[22]
Average McCabe’s Cyclomatic Complexity[23]
Maximum McCabe’s Cyclomatic Complexity[23]
Lines of Code
Table 1: Static Code Metrics list

###  3.3 Class Dependency Network Extraction

We have defined CDN formally in a previous section. We slightly modify this
definition and define the CDN to be directed, unlike in [32]. Each Edge
$e_{i}\in E$ has a type associated with it, and the set of edge types defined
by $T$.

Since we are analyzing Java programs, our components are classes, interfaces,
annotations, and enumerations. We extracted a total of 10 relation types($T$),
described in table 2. These edge types are based on the interactions between
types in the Java programming language. This list contains most relation
types. We chose not to handle relations based on Generic types since these
were not very common in our dataset. In Figure 1 there is an example java code
with different software dependencies, and the CDN generated from it. This
example demonstrates a subset of our recognized types. We have written a tool
that parses Java source code and builds the CDN based on references in the
source code, and not the compiled version of the application since some
changes can occur due to compiler optimizations. The resulting artifact is a
single graph for each software version, containing the nodes and edges as
described above.

The CDN extraction process runs in linear time and is composed of two passes.
The first pass parses all Java files in a project repository and constructs a
type dictionary for the project. The second pass traverses the ASTs of the
code, analyzes the statements and extracts type references. These references
are looked up in the dictionary built in the first pass. The extracted
relations are appended to the CDN.‘

Edge Type | Description
---|---
Extends[E] | A class extends another class
Implements[I] | A class implements an interface
Return Type[R] | A Type appears as a return type in a function
Variable[V] | A Type appears as a variable type in a function
Class Member[CM] | A Type appears as a class member type
Object Instantiation[OI] | A Type appears in a ”new” statement
Annotation[A] | A Type appears as an annotation
Parameter[P] | A Type appears as a parameter type in a function
Static Class Member[SCM] | A Type appears as a static class member type
Static Method Call[SMC] | A class calls a static method from another class

Table 2: List of edge types in our CDN

⬇

interface Ifc{

void f();

}

public class Ac implements Ifc{

private Cc c;

public void f(){

c = new Cc();

}

}

public class Bc extends Ac{

public Cc f2(Ifc i, Cc c2){

i.f();

return this.c;

}

}

public class Cc{

//…

}

(a)

(b)

Figure 2: Code and extracted CDN example

###  3.4 CDN Embedding Learning

As described earlier, we use a few different graph embedding algorithms for
the embedding process. We use the CDN extracted from the source code and
generate a stripped graph that is directed and without types. The stripping
means that if two types have multi connections in the CDN (in the same
direction), in the stripped graph they will have a single directed connection.
In case two types point to each other, there will be two edges. We do not give
weights to the edges. Some classes do not exist in the CDN, so they will not
have an embedding. For the process of embedding generation, we use the
algorithms described in Section 2.3.

###  3.5 Embedding Alignment

As we discussed, the key to performing CVDP is to align the two version’s
embeddings, so that we will have a close as possible coordinates system. For
this, we used an Orthogonal transformation to map between the embeddings. We
also experimented with Linear Regression as a benchmark alignment technique.
The relevant results will be discussed in section5. The reason we chose to use
an Orthogonal Transformation is that these transformations preserve angles
between vectors and vector lengths. Because of these properties, vector
distances (euclidean) are preserved, and hence the relations between the
embedded elements. Intuitively, an Orthogonal Transformation does not distort
the embedding but rotates and reflects it.

An essential part of the alignment procedure is to select the parallel points
(or anchors) correctly. Poorly selected anchors can degrade results. In our
setting, the nodes are software elements. Since we analyze a pair of versions
of the same application, we expect most elements from the old version to be
present in the newer version. Our goal is to select a subset of these types as
our anchors. To do this, we used two techniques and compared them. For each
technique, we calculate a score for a given node and select the $\mathcal{N}$
anchors with the highest scores. We performed experiments with different
$\mathcal{N}$ values and the results will be discussed in Section 5.

####  3.5.1 K-Nearest Neighbors Anchor Selection

The motivation behind embedding is to generate a vector representation that
preserves semantic relations. So, we expect nodes with similar structures in
the graph to be located relatively close in an embedding space. We also assume
that a node’s close neighborhood has semantic meaning. Our assumption is as
follows: given a node that exists in both graphs, we assume that if its
structural behavior did not change between the graphs, its neighborhood would
not change as well. This means that a node with high similarity in its
neighbors group should get a high score. Formally, for each node $v_{i}\in
V_{0}\cap V_{1}$ we calculate the following KNN score:

$S_{knn}(v_{i})=\frac{|N^{i}_{0}\cap N^{i}_{1}|}{k}$

Where $N^{i}_{0}$ and $N^{i}_{1}$ are node i’s $k$ nearest neighbors in
$G_{0}$ and $G_{1}$ respectively. As this ratio gets closer to 1, the greater
the similarity between the versions for that specific node. Each neighborhood
$N^{i}_{j}$ is the set of closest nodes in the respective graph’s embedding
space, using the euclidean distance metric. We have experimented with other
metrics, such as cosine similarity, and have achieved similar results.

####  3.5.2 Graph Neighbors Similarity Anchor Selection

The idea behind this technique is similar to the prior one, but from the
original graph’s point of view. Given a node that exists in both graphs, we
extract its direct neighbors in each graph. We then look at the intersection
of those groups, and reward nodes with a large intersection. We also assumed
that nodes with a high degree and a high similarity can be more important, and
the experiment showed that. Formally, we define this measure as follows:

$S_{GNS}(v_{i})=\frac{|M^{i}_{0}\cap M^{i}_{1}|^{2}}{|M^{i}_{0}\cup
M^{i}_{1}|}$

Where $M^{i}_{0}$ and $M^{i}_{1}$ are node i’s immediate neighbors group in
$G_{0}$ and $G_{1}$ respectively. Formally,

$M^{i}_{j}=\\{v_{l}|(v_{i},v_{l})\in E_{j}\vee(v_{l},v_{i})\in E_{j}\\}$

Where

$v_{l},v_{i}\in V_{j},j\in\\{0,1\\},i,l\in\\{1,...,|V_{j}|\\}$

###  3.6 Classifier Learning

In the previous sections, we demonstrated how we perform CDN extraction,
embedding learning, and alignment. We also mentioned the use of static code
metrics as additional features. The way we use both feature sets is rather
straight forward. We concatenate both the static code metrics and the
embedding values into a unified set and use this new set as our training/test
data, which is fed into a regular classifier. The classification goal is to
predict if a software module contains a bug or not. In the experiments, a
Random Forest[9] classifier was used. Because Random Forest is based on
multiple random decisions, each experiment we performed was repeated 30 times
to generate an average estimate that is less biased by randomness. We chose
the Random Forest classifier because of its popularity in Defect Prediction
setups, and because it showed promising results in our experiments.

##  4 Experimental Setup

To evaluate our methods, we experimented with real-world software
applications, comparing our results with two baselines. First, we build a
classifier with only static code metrics as the features. Second, we want to
build baseline techniques that use embeddings and alignments. For this purpose
we provide two models. The first model uses the learned embeddings without
performing alignment. This shows the need for performing some alignment. The
second model uses Linear Regression as a benchmark alignment technique.

The Linear Regression alignment is rather straightforward. Linear Regression
learns a linear relation between a set of variables and a target variable. In
our setup, we wish to represent the new version’s embeddings as a relation of
the old one’s embeddings. As was discussed earlier, the idea is to learn a
mapping $T$ between $E_{1}$ and $E_{2}$. This can be broken down to $k$
different linear relations (n is the embedding size). So, given our anchors
set, we build k linear regression problems from $E_{1}$ to each of the
dimensions of $E_{2}$. These regression problems have a zero coefficient for
simplicity. Our embedding alignment matrix $T$ is composed of the learned
coefficients.

In our experiments, we used static code metrics collected by Jureczko et
al.[19]. Not all projects that are reported in this dataset have an available
source code, so we used only the ones we could locate the relevant sources.
Also, only projects with more than one version available were used. We used
data from a total of 9 projects, and a total of 24 version pairs. Table 3
describes the different projects and versions analyzed in the experiments.
Version pairs were chosen based on the dataset, where consecutive versions
were paired. The original dataset does not cover all versions, so version
jumps are sometimes significant. We collected the source code of each version
from the relevant project’s website, including all peripheral code (tests, for
example). This code is used during our CDN construction and provides
additional knowledge on the structural dependencies in the core application
code. During embedding generation, some software modules do not have an
embedding, due to a lack of graph edges in the CDN. To make a fair analysis,
we only keep modules that have both static code metrics and an embedding. In
table4 we provide a summary of the dataset’s statistics. For each project, we
calculate average measures of CDN size (vertices and edges), the number of
modules that have both an embedding and static code metrics ($|V\cap
M_{DS}|$), and average defect percentage in $|V\cap M_{DS}|$.

For the experiments, we used implementations available on Github[1]. The
Node2Vec implementation is the one released by the authors[3]. The LINE
implementation is part of the OpenNE toolkit[4]. For all embedding methods we
used an embedding dimesion of 32, and used the default parameters.
Specifically, we used $p$ and $q$ (for Node2Vec) to be 1.

To evaluate the performance of our methods and the baseline methods, we used
two commonly used performance metrics, Area Under the ROC Curve (AUC) and the
F1-Score. F1-Score is defined by

$F_{1}=2\cdot\frac{precision\cdot recall}{precision+recall}$

The results of the different setups were compared statistically using the
Wilcoxon signed-rank test[12]. We performed experiments and compared the
results on the following scenarios:

####  4.0.1 Static Code Metrics (Baseline)

In this setup we simply trained a classifier only on the static code metrics
(of the old version) and tested on the new version. This represents a baseline
since most defect prediction studies rely on these features.

####  4.0.2 Embedding with No Alignment (Baseline)

In this setup we train a classifier on static features together with learned
embeddings, but without performing the alignment process. This setup comes to
show how not performing alignment usually degrades the performance of the
model. This is due to the fact that the embedding algorithm is not constrained
to learn the same semantic meaning of each of the embedding dimensions
(although a close solution might happen by chance).

####  4.0.3 Embedding Alignment with Random Anchor Selection (Baseline)

As another baseline, we evaluated the performance of Linear Regression and
Orthogonal Transformation on a randomly selected set of anchors. The number of
anchors selected was also modified to get a broader result.

####  4.0.4 Embedding Alignment with KNN Anchor Selection

For this scenario, we evaluated the performance of our KNN Anchor Selection
algorithm. We experimented with different numbers of anchors and numbers of
nearest neighbors to take into account. The experiments were done using both
an Orthogonal Transformation and Linear Regression and on both embedding
techniques.

####  4.0.5 Embedding Alignment with Graph Neighbors Similarity Anchor
Selection

For this scenario, we evaluated the performance of our Graph Neighbors
Similarity Anchor Selection algorithm. In this scenario, we modified the
number of anchors selected. The experiments were done using both an Orthogonal
Transformation and Linear Regression and on both embedding techniques.

Project Name |  Project Description |  Version Pairs
---|---|---
Apache Camel |  Integration Framework |  (1.0,1.2) (1.2,1.4) (1.4,1.6)
JEdit |  Text Editor |  (3.2,4.0) (4.0,4.1) (4.1,4.2) (4.2,4.3)
Apache Log4J |  Logging Library |  (1.0,1.1) (1.1,1.2)
Apache Lucene |  Information Retrieval Library |  (2.0,2.2) (2.2,2.4)
Apache POI |  Microsoft Office processing library |  (1.5,2.0) (2.0,2.5) (2.5 3.0)
Apache Synapse |  Enterprise Service Bus |  (1.0,1.1) (1.1,1.2)
Apache Velocity |  Template Engine |  (1.4,1.5) (1.5,1.6)
Apache Xalan |  XSLT and XPath implementation |  (2.4,2.5) (2.5,2.6) (2.6,2.7)
Apache Xerces |  XML Processing Library |  (init,1.2) (1.2,1.3) (1.3,1.4)
Table 3: Projects Analyzed In Our Experiment Project Name |  Average $|V|$ |  Average $|E|$ |  Average $|V\cap M_{DS}|$ |  Average Defect Percentage
---|---|---|---|---
Apache Camel |  1312 |  4856 |  664 |  19.7
JEdit |  662 |  2449 |  340 |  18.7
Apache Log4J |  225 |  626 |  133 |  51.03
Apache Lucene |  1069 |  5197 |  257 |  55.5
Apache POI |  814 |  3282 |  341 |  50
Apache Synapse |  414 |  1470 |  209 |  23.6
Apache Velocity |  356 |  1311 |  209 |  59
Apache Xalan |  979 |  4535 |  805 |  52.2
Apache Xerces |  514 |  1940 |  336 |  35.4
Table 4: Dataset Statistics

##  5 Experimental Results

During our experiments, many different techniques and setups were evaluated.
We wish to provide a few points of view on the different results, so this
section will be divided into a few subsections that each analyze a different
aspect of the results.

####  5.0.1 Best Results for Each Embedding Algorithm

As described in an earlier section, we evaluated two embedding techniques, two
anchor selection techniques, and two alignment techniques. In this section, we
will provide the results of our best model for each of the embedding
techniques. For LINE embedding, we achieved the best results (in AUC terms) by
using Orthogonal Transformation as the alignment and used the graph similarity
anchor selection. These results were statistically significant with $p=0.01$,
compared to the static metrics model. For Node2vec, we achieved the best
results (in AUC terms) again using Orthogonal Transformation but using KNN
anchor selection instead. The Node2vec results were also statistically
significant, with $p<0.043$, compared to static metrics model. Figure 4 shows
the AUC scores for the two methods just described and three baseline methods.
The Static method is simply a classifier with static code metrics. The Not
Aligned Embedding method is a classifier trained on both the static code
metrics and the embeddings, but without aligning the embeddings. The Linear
Regression method uses the same embedding but uses Linear Regression as an
embedding alignment mechanism. It is also interesting to note that for the
Linear Regression mapping, we achieved the best result when we used all
available code modules in both versions as our anchors. This result will be
discussed in a later section. The results show that using CDN data provides an
improvement in AUC performance. We also measured the F1-score of the different
methods we used. In most cases, we got very similar results to the baseline,
up to $\pm 0.5\%$ difference. The results also show that Orthogonal
Transformation alignment performs better than Linear Regression, although
these results were not statistically significant. The not aligned model
generally provides the worst results, but in some cases it outperforms. This
seems like an anomaly, as was discussed earlier.

Another interesting phenomenon we can see from the results in Figure 4 is that
the embedding techniques we used are somewhat complementary. In some projects,
the results are similar, but there are projects for which one embedding
technique is better than the other and vice versa. One possible explanation
can be that different embedding techniques (and parameters) extract different
information, specifically local vs. global information. Both local and global
information have been shown to be relevant to defect prediction [40]. This
difference in performance led us to create a meta-model using the two models
we described in this section, and we will discuss it and its results in the
next section.

Figure 3: AUC results of our best methods versus three baseline models

Figure 4: AUC results of the joint model versus the individual models

####  5.0.2 LINE and Node2vec joint model

As we described in the previous section, the results of the LINE model and the
Node2vec model complement each other. To utilize this result, we built a
Logistic Regression model on top of the individual models. We extracted from
each classifier the probability of a defect and used the Logistic Regression
model to calculate a better probability estimate. On average, the model
improves the individual model’s results by about 1%. The results are shown in
Figure 4. A representative ROC curve for the meta-model versus the static
metrics model is shown in Figure 7. We also checked the results for
statistical significance and concluded that they are significant with
$p<0.002$, compared to the static metrics model. They were also statically
significant when compared to the Linear Regression results, with $p<0.001$.

####  5.0.3 KNN Anchor Selection Analysis

As described earlier, KNN anchor selection has two parameters: The number of
anchors to select and $K$, which is the number of nearest neighbors for each
candidate anchor to compare. From the experiments, it appeared that the number
of anchors to select is the more significant parameter, especially when using
the Orthogonal Transformation embedding alignment. Figure 5 shows how the
number of anchors impacts the classification performance for all the embedding
techniques. For these experiments, $K$ was fixed at 10. Increasing $K$ values
gave us similar or worse results, in all experiments. It can be seen that
using this setup, Node2vec achieves the best performance.

(a)

(b)

Figure 5: KNN anchor selection method AUC (5(a)) and F1 (5(b)) results for all
embeddings

####  5.0.4 Graph Similarity Anchor Selection Analysis

Similarly to the KNN analysis, we evaluated the impact of changing the number
of anchors. The results of these experiments are shown in Figure 6. In terms
of AUC performance, it can be seen that LINE achieves better results than the
other two embedding techniques. This result is interesting because of how the
LINE embedding works. As described earlier, the main idea of LINE is to model
the neighborhoods of nodes. This anchor selection technique looks at precisely
that. We try to find the nodes in both graphs that have the most similar
neighborhoods. It seems reasonable that this technique would work best with
LINE and in general achieves the best AUC performance.

(a)

(b)

Figure 6: Graph similarity anchor selection method AUC (6(a)) and F1 (6(b))
results for all embeddings  Figure 7: ROC curve for the Meta Model vs Static
Metrics model on the (Xerces-init, Xerces-1.2) version pair Figure 8: Average
AUC for randomly selected anchors

####  5.0.5 Linear Regression and Orthogonal Transformation Comparison

During this work, we used Linear Regression as a baseline method for the
alignment process. Because Linear Regression learns a general linear
transformation, some properties of the original space might be modified. For
example, angles between vectors in the original domain can change after the
transformation. This change in angles does not occur when an Orthogonal
Transformation is used. Nevertheless, Linear Regression can still be a good
approximation, and our experiments show this.

In the section on the best model for each embedding, we presented the
performance of Linear Regression as an alignment technique, while using the
LINE embedding. The results with the Node2vec embedding were very similar and
slightly worse. It can be seen that the performance of Linear Regression is
usually worse or similar to that of the Orthogonal Transformation. These
results shows that Linear Regression distorts some of the information
available in the embedding. It appears that Orthogonal Transformations
preserves more of the information in the embedding, hence achieving better
results.

One more experiment we performed is to compare both alignment techniques in a
random anchor selection setup. We performed 30 experiments for every anchor
count and sampled randomly from the set of software modules that exist in both
versions. Figure 8 shows the results of this experiment. For this experiment
we used the Node2vec embedding. The results show an interesting phenomenon.
When we increase the number of anchors, Linear Regression achieves better
results. On the other hand, randomly selecting anchors when using an
Orthogonal Transformation does not achieve great results (less than with our
selection techniques). It seems that Linear Regression achieves better
alignment as more data points are added.

##  6 Discussion

The results presented in the previous section show an improvement over the
basic model, which is based on static code metrics. From analyzing the
results, one can see that the improvement is not uniform. Some projects
exhibit better performance and some worse. As we discussed earlier, the
different embedding techniques appeared to be complementary, and when these
techniques were combined in a joint model, the overall performance improved.
It still seems that there is more room for improvement because in some cases,
the individual models beat the meta-model’s performance. Analyzing these
phenomenons is something we are looking at for future work.

As we mentioned before, we achieved the best results for different embedding
techniques using different anchor selection techniques. This is an interesting
and somewhat surprising result. This means that the notion of similarity and
closeness in different embeddings is different. Because of this difference, it
appears that there is a connection between the embedding algorithm’s closeness
notion and the anchor selection technique that works best and how it selects
the best candidates. For this reason, a future direction will be to explore
new anchor selection methods and match similar embedding techniques.

##  7 Threats to Validity

Our work might suffer from threats to its validity. We discuss them briefly.

###  7.1 Threats to Internal Validity

In our work, we measured the performance of our techniques using the widely
used AUC and F1-Score. First, there are other performance measures which we
did not use and might have different performance than we observed. For this
reason, our results might not be relevant to some applications. Second, we
observed a slight decrease in F1-Score, and believe it to be negligible. In
some scenarios this might not be negligible, and so our conclusions might be
mistaken. Nevertheless, this difference was not statistically significant.

###  7.2 Threats to External Validity

We have used the dataset collected by Jureczko et al. in our evaluations. This
is a widely used dataset and contains several applications from different
domains and of different sizes. There is a possibility that on a different
dataset, we will achieve different results. This dataset dates back a few
years and might not reflect changes in the Software Development Community.
Another issue is that we analyzed Java applications, and on a different
programming language, the results might be different.

##  8 Conclusion And Future Work

In this work, we aimed at improving the results of CVDP using Class Dependency
Network data. For this purpose, we developed a framework for embedding and
aligning CDN data and used its results as inputs for a classifier. We also
suggested two anchor selection techniques and used them in different embedding
and alignment setups. We performed extensive experiments using two embedding
techniques on a publicly available dataset. Our results show that:

  1. 1.

As previously shown, CDN data is beneficial for defect prediction. We showed
that this is true for the CVDP scenario as well.

  2. 2.

We developed a framework for the generation and alignment of embeddings of
CDNs across versions.

  3. 3.

We performed multiple experiments and showed that our framework achieves
statistically better performance than the state-of-the-art baseline.

For future work, we are considering the following directions:

  1. 1.

Experiment with more embedding techniques and different parameter settings.
These settings can provide more local vs. global information into the
embedding process.

  2. 2.

Experiment with new datasets, in order to provide a broader performance
measure.

  3. 3.

Try new approaches for CDN embedding that take into account labels and
weights.

  4. 4.

Try to use multiple old versions (MOV) in the learning process, instead of
just a single old version (SOV).

## References

  * [1] Github.  https://github.com/.
  * [2] Java Software | Oracle.  https://www.oracle.com/java/.
  * [3] Node2vec.  https://github.com/aditya-grover/node2vec.
  * [4] OpenNE - An Open-Source Package for Network Embedding (NE).  https://github.com/thunlp/OpenNE.
  * Amasaki, [2018] Amasaki, S. (2018).  Cross-Version Defect Prediction Using Cross-Project Defect Prediction Approaches: Does It Work?  In Proceedings of the 14th International Conference on Predictive Models and Data Analytics in Software Engineering, PROMISE’18, pages 32–41, New York, NY, USA. ACM.
  * Bansiya and Davis, [2002] Bansiya, J. and Davis, C. G. (2002).  A hierarchical model for object-oriented design quality assessment.  IEEE Transactions on Software Engineering, 28(1):4–17.
  * Bennin et al., [2017] Bennin, K. E., Keung, J., Monden, A., Phannachitta, P., and Mensah, S. (2017).  The Significant Effects of Data Sampling Approaches on Software Defect Prioritization and Classification.  In Proceedings of the 11th ACM/IEEE International Symposium on Empirical Software Engineering and Measurement, ESEM ’17, pages 364–373, Piscataway, NJ, USA. IEEE Press.
  * Bennin et al., [2016] Bennin, K. E., Toda, K., Kamei, Y., Keung, J., Monden, A., and Ubayashi, N. (2016).  Empirical Evaluation of Cross-Release Effort-Aware Defect Prediction Models.  In 2016 IEEE International Conference on Software Quality, Reliability and Security (QRS), pages 214–221.
  * Breiman, [2001] Breiman, L. (2001).  Random Forests.  Machine Learning, 45(1):5–32.
  * Chidamber and Kemerer, [1994] Chidamber, S. R. and Kemerer, C. F. (1994).  A metrics suite for object oriented design.  IEEE Transactions on Software Engineering, 20(6):476–493.
  * D’Ambros et al., [2010] D’Ambros, M., Lanza, M., and Robbes, R. (2010).  An extensive comparison of bug prediction approaches.  In 2010 7th IEEE Working Conference on Mining Software Repositories (MSR 2010), pages 31–41.
  * Demšar, [2006] Demšar, J. (2006).  Statistical Comparisons of Classifiers over Multiple Data Sets.  J. Mach. Learn. Res., 7:1–30.
  * Fan et al., [2019] Fan, G., Diao, X., Yu, H., Yang, K., and Chen, L. (2019).  Software Defect Prediction via Attention-Based Recurrent Neural Network.  Scientific Programming, 2019:14.
  * Fenton and Bieman, [2014] Fenton, N. and Bieman, J. (2014).  Software metrics: a rigorous and practical approach.  CRC press.
  * Goyal and Ferrara, [2017] Goyal, P. and Ferrara, E. (2017).  Graph Embedding Techniques, Applications, and Performance: A Survey.  CoRR, abs/1705.02801.
  * Grover and Leskovec, [2016] Grover, A. and Leskovec, J. (2016).  node2vec: Scalable Feature Learning for Networks.  In Proceedings of the 22nd ACM SIGKDD International Conference on Knowledge Discovery and Data Mining.
  * Hall et al., [2012] Hall, T., Beecham, S., Bowes, D., Gray, D., and Counsell, S. (2012).  A Systematic Literature Review on Fault Prediction Performance in Software Engineering.  IEEE Transactions on Software Engineering, 38(6):1276–1304.
  * Henderson-Sellers, [1996] Henderson-Sellers, B. (1996).  Object-oriented Metrics: Measures of Complexity.  Prentice-Hall, Inc., Upper Saddle River, NJ, USA.
  * Jureczko and Madeyski, [2010] Jureczko, M. and Madeyski, L. (2010).  Towards Identifying Software Project Clusters with Regard to Defect Prediction.  In Proceedings of the 6th International Conference on Predictive Models in Software Engineering, PROMISE ’10, pages 9:1–9:10, New York, NY, USA. ACM.
  * Kamei and Shihab, [2016] Kamei, Y. and Shihab, E. (2016).  Defect Prediction: Accomplishments and Future Challenges.  In 2016 IEEE 23rd International Conference on Software Analysis, Evolution, and Reengineering (SANER), volume 5, pages 33–45.
  * Ma et al., [2016] Ma, W., Chen, L., Yang, Y., Zhou, Y., and Xu, B. (2016).  Empirical analysis of network measures for effort-aware fault-proneness prediction.  Information and Software Technology, 69:50 – 70.
  * Martin, [1994] Martin, R. (1994).  OO design quality metrics.
  * McCabe, [1976] McCabe, T. J. (1976).  A Complexity Measure.  IEEE Transactions on Software Engineering, SE-2(4):308–320.
  * Mikolov et al., [2013] Mikolov, T., Chen, K., Corrado, G., and Dean, J. (2013).  Efficient Estimation of Word Representations in Vector Space.  CoRR, abs/1301.3781.
  * Nam, [2014] Nam, J. (2014).  Survey on Software Defect Prediction.  Tech Report, The Hong Kong University of Science and Technology, Department of Compter Science and Engineerning.
  * Premraj and Herzig, [2011] Premraj, R. and Herzig, K. (2011).  Network Versus Code Metrics to Predict Defects: A Replication Study.  In 2011 International Symposium on Empirical Software Engineering and Measurement, pages 215–224.
  * Qu et al., [2018] Qu, Y., Liu, T., Chi, J., Jin, Y., Cui, D., He, A., and Zheng, Q. (2018).  Node2defect: Using Network Embedding to Improve Software Defect Prediction.  In Proceedings of the 33rd ACM/IEEE International Conference on Automated Software Engineering, ASE 2018, pages 844–849, New York, NY, USA. ACM.
  * Qu et al., [2019] Qu, Y., Zheng, Q., Chi, J., Jin, Y., He, A., Cui, D., Zhang, H., and Liu, T. (2019).  Using K-core Decomposition on Class Dependency Networks to Improve Bug Prediction Model’s Practical Performance.  IEEE Transactions on Software Engineering, pages 1–1.
  * Schönemann, [1966] Schönemann, P. H. (1966).  A generalized solution of the orthogonal procrustes problem.  Psychometrika, 31(1):1–10.
  * Shukla et al., [2018] Shukla, S., Radhakrishnan, T., Muthukumaran, K., and Neti, L. B. M. (2018).  Multi-objective cross-version defect prediction.  Soft Computing, 22(6):1959–1980.
  * Smith et al., [2017] Smith, S. L., Turban, D. H. P., Hamblin, S., and Hammerla, N. Y. (2017).  Offline bilingual word vectors, orthogonal transformations and the inverted softmax.  CoRR, abs/1702.03859.
  * Subelj and Bajec, [2011] Subelj, L. and Bajec, M. (2011).  Community structure of complex software systems: Analysis and applications.  CoRR, abs/1105.4276.
  * Tang et al., [2015] Tang, J., Qu, M., Wang, M., Zhang, M., Yan, J., and Mei, Q. (2015).  LINE: Large-scale Information Network Embedding.  CoRR, abs/1503.03578.
  * Tang et al., [1999] Tang, M.-H., Kao, M.-H., and Chen, M.-H. (1999).  An empirical study on object-oriented metrics.  In Proceedings Sixth International Software Metrics Symposium (Cat. No.PR00403), pages 242–249.
  * Xing et al., [2015] Xing, C., Wang, D., Liu, C., and Lin, Y. (2015).  Normalized Word Embedding and Orthogonal Transform for Bilingual Word Translation.  In Proceedings of the 2015 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, pages 1006–1011, Denver, Colorado. Association for Computational Linguistics.
  * Xu et al., [2019] Xu, Z., Li, S., Luo, X., Liu, J., Zhang, T., Tang, Y., Xu, J., Yuan, P., and Keung, J. (2019).  TSTSS: A two-stage training subset selection framework for cross version defect prediction.  Journal of Systems and Software, 154:59–78.
  * [37] Xu, Z., Li, S., Tang, Y., Luo, X., Zhang, T., Liu, J., and Xu, J. (2018a).  Cross Version Defect Prediction with Representative Data via Sparse Subset Selection.  In Proceedings of the 26th Conference on Program Comprehension, ICPC ’18, pages 132–143, New York, NY, USA. ACM.
  * [38] Xu, Z., Liu, J., Luo, X., and Zhang, T. (2018b).  Cross-version defect prediction via hybrid active learning with kernel principal component analysis.  In 2018 IEEE 25th International Conference on Software Analysis, Evolution and Reengineering (SANER), pages 209–220.
  * Yang and Wen, [2018] Yang, X. and Wen, W. (2018).  Ridge and Lasso Regression Models for Cross-Version Defect Prediction.  IEEE Transactions on Reliability, 67(3):885–896.
  * Zimmermann and Nagappan, [2008] Zimmermann, T. and Nagappan, N. (2008).  Predicting defects using network analysis on dependency graphs.  In 2008 ACM/IEEE 30th International Conference on Software Engineering, pages 531–540.
  * Zimmermann et al., [2007] Zimmermann, T., Premraj, R., and Zeller, A. (2007).  Predicting Defects for Eclipse.  In Proceedings of the Third International Workshop on Predictor Models in Software Engineering, PROMISE ’07, pages 9–, Washington, DC, USA. IEEE Computer Society.