Intelligent Software Defect Prediction 1st Edition Xiao-Yuan Jing - The Ebook Is Available For Instant Download, Read Anywhere
Intelligent Software Defect Prediction 1st Edition Xiao-Yuan Jing - The Ebook Is Available For Instant Download, Read Anywhere
com
https://ebookmeta.com/product/intelligent-software-defect-
prediction-1st-edition-xiao-yuan-jing/
OR CLICK HERE
DOWLOAD EBOOK
https://ebookmeta.com/product/challenges-of-software-verification-
intelligent-systems-reference-library-238-vincenzo-arceri-editor/
ebookmeta.com
https://ebookmeta.com/product/the-ethics-of-governance-moral-limits-
of-policy-decisions-1st-edition-shashi-motilal/
ebookmeta.com
Routine Blood Results Explained, 4th Edition Andrew Blann
https://ebookmeta.com/product/routine-blood-results-explained-4th-
edition-andrew-blann/
ebookmeta.com
https://ebookmeta.com/product/amidst-secrets-and-shadows-1st-edition-
stacy-jones-harper-wylde/
ebookmeta.com
https://ebookmeta.com/product/the-wellness-zone-your-guide-for-
optimal-wellness-3rd-edition-dominique-livkamal/
ebookmeta.com
https://ebookmeta.com/product/easy-french-reader-premium-fourth-
edition-r-de-roussy-de-sales/
ebookmeta.com
https://ebookmeta.com/product/the-serpent-lord-wren-murphy/
ebookmeta.com
101 Things I Learned in Culinary School 2nd Edition Louis
Eguaras
https://ebookmeta.com/product/101-things-i-learned-in-culinary-
school-2nd-edition-louis-eguaras/
ebookmeta.com
Xiao-Yuan Jing · Haowen Chen
Baowen Xu
Intelligent
Software Defect
Prediction
Intelligent Software Defect Prediction
Xiao-Yuan Jing • Haowen Chen • Baowen Xu
Baowen Xu
Computer Science & Technology
Nanjing University
Nanjing, Jiangsu, China
© The Editor(s) (if applicable) and The Author(s), under exclusive license to Springer Nature Singapore
Pte Ltd. 2023
This work is subject to copyright. All rights are solely and exclusively licensed by the Publisher, whether
the whole or part of the material is concerned, specifically the rights of translation, reprinting, reuse
of illustrations, recitation, broadcasting, reproduction on microfilms or in any other physical way, and
transmission or information storage and retrieval, electronic adaptation, computer software, or by similar
or dissimilar methodology now known or hereafter developed.
The use of general descriptive names, registered names, trademarks, service marks, etc. in this publication
does not imply, even in the absence of a specific statement, that such names are exempt from the relevant
protective laws and regulations and therefore free for general use.
The publisher, the authors, and the editors are safe to assume that the advice and information in this book
are believed to be true and accurate at the date of publication. Neither the publisher nor the authors or
the editors give a warranty, expressed or implied, with respect to the material contained herein or for any
errors or omissions that may have been made. The publisher remains neutral with regard to jurisdictional
claims in published maps and institutional affiliations.
This Springer imprint is published by the registered company Springer Nature Singapore Pte Ltd.
The registered company address is: 152 Beach Road, #21-01/04 Gateway East, Singapore 189721,
Singapore
With the increase of complexity and dependency of software, the software product
may suffer from low quality, high cost, hard-to-maintain, and even the occurrence
of defects. Software defect usually produces incorrect or unexpected results and
behaviors in unintended ways. Software defect prediction (SDP) is one of the most
active research fields in software engineering and plays an important role in software
quality assurance. According to the feedback of SDP, developers can subsequently
conduct defect location and repair under reasonable resource allocation, which is
helpful in reducing the maintenance cost.
The early task of SDP is performed within a single project. Developers can make
use of the well-labeled historical data of the currently maintained project to build the
model and predict the defect-proneness of the remaining instances. This process is
called within-project defect prediction (WPDP). However, the annotation for defect
data (i.e., defective or defective-free) is time-consuming and high-cost, which is a
hard task for practitioners in the development or maintenance cycle. To solve this
problem, researchers consider introducing other projects with sufficient historical
data to conduct the cross-project defect prediction (CPDP) which has received
extensive attention in recent years. As the special case of CPDP, heterogeneous
defect prediction (HDP) refers to the scenario that training and test data have
different metrics, which can relax the restriction on source and target projects’
metrics. Besides, there also exist other research questions of SDP to be further
studied, such as cross-version defect prediction, just-in-time (JIT) defect prediction,
and effort-aware JIT defect prediction.
In the past few decades, more and more researchers pay attention to SDP and
a lot of intelligent SDP techniques have been presented. In order to obtain the
high-quality representations of defect data, a lot of machine learning techniques
such as dictionary learning, semi-supervised learning, multi-view learning, and deep
learning are applied to solve SDP problems. Besides, transfer learning techniques
are also used to eliminate the divergence between different project data in CPDP
scenario. Therefore, the combination with machine learning techniques is conducive
to improving the prediction efficiency and accuracy, which can promote the research
of intelligent SDP to make significant progress.
v
vi Preface
We thank Li Zhiqiang, Wu Fei, Wang Tiejian, Zhang Zhiwu, and Sun Ying
from Wuhan University for their contributions to this research. We would like to
express our heartfelt gratitude to Professor Baowen Xu and his team from Nanjing
University for their selfless technical assistance in the compilation of this book. We
are so thankful for the invaluable help and support provided by Professor Xiaoyuan
Xie from Wuhan University, whose valuable advice and guidance was crucial to the
successful completion of this book. We wanted to express our sincere appreciation
for the unwavering support provided by Nanjing University, Wuhan University,
and Nanjing University of Posts and Telecommunications, as well as the editing
suggestions provided by Kamesh and Wei Zhu from Springer Publishing House.
We just wanted to thank you from the bottom of our hearts for your unwavering
support and guidance throughout the compilation of this book. Finally, we would
like to express our heartfelt appreciation to two master students, Hanwei and Xiuting
Huang, who participated in the editing process and made indelible contributions to
the compilation of this book.
vii
Contents
1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.1 Software Quality Assurance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.2 Software Defect Prediction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.3 Research Directions of SDP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.3.1 Within-Project Defect Prediction (WPDP) . . . . . . . . . . . . . . . . . . . . 3
1.3.2 Cross-Project Defect Prediction (CPDP) . . . . . . . . . . . . . . . . . . . . . . 4
1.3.3 Heterogeneous Defect Prediction (HDP) . . . . . . . . . . . . . . . . . . . . . . 4
1.3.4 Other Research Questions of SDP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.4 Notations and Corresponding Descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.5 Structure of This Book . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2 Machine Learning Techniques for Intelligent SDP. . . . . . . . . . . . . . . . . . . . . . . 13
2.1 Transfer Learning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
2.2 Deep Learning. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
2.3 Other Techniques. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
2.3.1 Dictionary Learning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
2.3.2 Semi-Supervised Learning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
2.3.3 Multi-View Learning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
3 Within-Project Defect Prediction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
3.1 Basic WPDP. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
3.1.1 Dictionary Learning Based Software Defect Prediction . . . . . . 19
3.1.2 Collaborative Representation Classification Based
Software Defect Prediction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
3.2 Semi-supervised WPDP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
3.2.1 Sample-Based Software Defect Prediction with
Active and Semi-supervised Learning . . . . . . . . . . . . . . . . . . . . . . . . . 28
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
ix
x Contents
© The Author(s), under exclusive license to Springer Nature Singapore Pte Ltd. 2023 1
X.-Y. Jing et al., Intelligent Software Defect Prediction,
https://doi.org/10.1007/978-981-99-2842-2_1
2 1 Introduction
The defect is a flaw in the component or system which can cause it to fail to perform
its desired function, that is, an incorrect statement or data definition. A defect, if
encountered during execution, may cause a failure of the system or a component.
Defect prediction helps in identifying the vulnerabilities in the project plan in
terms of lack of resources, improperly defined timelines, predictable defects, etc.
It can help organizations to fetch huge profits without getting delayed on schedules
planned or overrun on estimates of budget. It helps in modifying the parameters
in order to meet the schedule variations. The methods to estimate the software
defects are regression, genetic programming, clustering, neural network, statistical
technique of discriminate analysis, dictionary learning approach, hybrid attribute
selection approach, classification, attribute selection and instance filtering, Bayesian
belief networks, K-means clustering, and association rule mining. In the domain of
software defect prediction, people have developed many software defect prediction
models. These models are mostly described in two classes: one class is in the later
period of the software life cycle (testing phase), having gotten defect data, predicts
how many defects still in the software with these data. Models in this class include:
capture-recapture method based model, neural network based model, and measure
method based on scale and complexity of source code. The other class, which occurs
before the software development phase, aims to predict the number of defects that
will arise during the software development process by analyzing defect data from
previous projects. Presently, published models in this class include: phase based
1.3 Research Directions of SDP 3
model proposed by Gaffney and Davis, Ada programming defect prediction model
proposed by Agresti and Evanco, early prediction model proposed by USA ROME
lab, software development early prediction method proposed by Carol Smidts in
Maryyland University, and early fuzzy neural network based model. However,
there are a number of serious theoretical and practical problems in these methods.
Software development is an extremely complicated process. Defects relate to many
factors. If you want to measure exactly, you would consider as many correlative
factors as possible, but it would make the model more complicated. If considering
the solvability, you would have to simplify the model. However, it would not make
out the convinced answer. Neural network based prediction model, for instance, has
lots of problems in training and verifying the sample collection. Software test in
many organizations is still in the original phase, so lots of software hardly gives
the defects number requested, which would bring certain difficulties to sample
collection. Early models consider inadequately on the uncertain factors in software
develop process; the dependence to data factors is great besides. Therefore, many
methods have difficulty in application.
Some defect data in the same project are used as the training set to build the
prediction model, and the remaining small number of data are used as test set to
test the performance. At present, some researchers mainly use the machine learning
algorithm to construct the defect prediction model on the within-project defect
prediction. In addition, how to optimize the data structure and extract effective
feature are also the focus of current research. Some important research works
will be summarized below. Elish et al. [5] use support vector machine (SVM)
to conduct defect prediction and compare its predictive performance with eight
statistical and machine learning models on four NASA datasets. Lu et al. [6]
leverage active learning to predict defect, and they also use feature compression
techniques to make feature reduction on defect data. Li et al. [7] propose a novel
semi-supervised learning method—ACoForest—which can sample the prediction
modules that are most helpful for learning. Rodriguez et al. [8] compare different
methods for different data preprocessing problems, such as sampling method, cost
sensitive method, integration method, and hybrid method. The final experimental
results show that the above different methods can effectively improve the accuracy
of defect prediction after performing the class imbalance. Seiffert et al. [9] analyze
11 different algorithms and seven different data sampling techniques and find that
class imbalance and data noise would have the negative impact on prediction
performance.
4 1 Introduction
When data are insufficient or non-existent for building quality defect predictors,
software engineers can use data from other organizations or projects. This is called
cross-project defect prediction (CPDP). Acquiring data from other sources is a
non-trivial task when data owners are concerned about confidentiality. In practice,
extracting project data from organizations is often difficult due to the business
sensitivity associated with the data. For example, at a keynote address at ESEM’11,
Elaine Weyuker doubted that she will ever be able to release the AT&T data she used
to build defect predictors [10]. Due to similar privacy concerns, we were only able to
add seven records from two years of work to our NASA-wide software cost metrics
repository [11]. In a personal communication, Barry Boehm stated that he was able
to publish less than 200 cost estimation records even after 30 years of COCOMO
effort. To enable sharing, we must assure confidentiality. In our view, confidentiality
is the next grand challenge for CPDP in software engineering. In previous work, we
allowed data owners to generate minimized and obfuscated versions of their original
data. Our MORPH algorithm [12] reflects on the boundary between an instance
and its nearest instance of another class, and MORPH’s restricted mutation policy
never pushes an instance across that boundary. MORPH can be usefully combined
with the CLIFF data minimization algorithm [13]. CLIFF is an instance selector
that returns a subset of instances that best predict for the target class. Previously
we reported that this combination of CLIFF and MORPH resulted in 7/10 defect
datasets studied retaining high privacy scores, while remaining useful for CPDP
[13]. This is a startling result since research by Grechanik et al. [14] and Brickell
et al. [15] showed that standard privacy methods increase privacy while decreasing
data mining efficacy. While useful CLIFF and MORPH only considered a single-
party scenario where each data owner privatized their data individually without
considering privatized data from others. This resulted in privatized data that were
directly proportional in size (number of instances) to the original data. Therefore, in
a case where the size of the original data is small enough, any minimization might
be meaningless, but if the size of the original data is large, minimization may not be
enough to matter in practice.
Existing CPDP approaches are based on the underlying assumption that both
source and target project data should exhibit the same data distribution or are
drawn from the same feature space (i.e., the same software metrics). When the
distribution of the data changes, or when the metrics features for source and target
projects are different, one cannot expect the resulting prediction performance to be
satisfactory. We consider these scenarios as Heterogeneous Cross-Project Defect
Prediction (HCPDP). Mostly, the software defect datasets are imbalanced, which
1.3 Research Directions of SDP 5
means the number of the defective modules is usually much smaller than that of the
defective-free modules. The imbalanced nature of data can cause poor prediction
performance. That is, the probability of defect prediction can be low, while the
overall performance is high. Without taking this issue into account, the effectiveness
of software defect prediction in many real-world tasks would be greatly reduced.
Recently, some researchers have noticed the importance of these problems in
software defect prediction. For example, Nam et al. [16] used the metrics selection
and metrics matching to select similar metrics for building a prediction model with
heterogeneous metrics set. They discarded dissimilar metrics, which may contain
useful information for training. Jing et al. [17] introduced Canonical Correlation
Analysis (CCA) into HCPDP, by constructing the common correlation space to
associate cross-project data. Then, one can simply project the source and target
project data into this space for defect prediction. Like previous CPDP methods,
the class imbalance problem of software defect datasets was not taken into account.
Ryu et al. [18] designed the Value-Cognitive Boosting with Support Vector Machine
(VCB-SVM) algorithm which exploited sampling techniques to solve the class
imbalance issue for cross-project environments. Nevertheless, sampling strategy
alters the distribution of the original data, where it may discard some potentially
useful samples that could be important for prediction process. Therefore, these
methods are not good solutions for addressing the class imbalance issue under
heterogeneous cross-project environments.
the usage of alternative techniques for just-in-time quality assurance, such as cached
history, deep learning, and textual analysis, reporting promising results. We did not
investigate these further in the current chapter, but studies can be designed and
carried out to determine if and how these techniques can be used within the model
we present in this chapter to further increase its accuracy.
Traditional SDP models based on some binary classification algorithms are not
sufficient for software testing in practice, since they do not distinguish between a
module with many defects or high defect density (i.e., number of defects/lines of
source codes) and a module with a small number of defects or low defect density.
Clearly, both modules require a different amount of effort to inspect and fix, yet they
are considered equal and allocated the same testing resources. Therefore, Mende et
al. [27] proposed effort-aware defect prediction (EADP) models to rank software
modules based on the possibility of these modules being defective, their predicted
number of defects, or defect density. Generally, EADP models are constructed by
using learning to rank techniques [28]. These techniques can be grouped into three
categories, that is, the pointwise approach, the pairwise approach, and the listwise
approach [29–31]. There exists a vast variety of learning to rank algorithms in
literature. It is thus important to empirically and statistically compare the impact
and effectiveness of different learning to rank algorithms for EADP. To the best
of our knowledge, few prior studies [32–36] evaluated and compared the existing
learning to rank algorithms for EADP. Most of these studies, however, conducted
their study with few learning to rank algorithms across a small number of datasets.
Previous studies [34–36] conducted their study with as many as five EADP models
and few datasets. For example, Jiang et al. [34] investigated the performance of only
five classification-based pointwise algorithms for EADP on two NASA datasets.
Nguyen et al. [36] investigated three regression based pointwise algorithm and two
pairwise algorithms for EADP on five Eclipse CVS datasets.
We will briefly introduce some of the symbols and abbreviations that appear in this
book, as listed in the Table 1.1: Some parts are listed in the table, and the parts that
are not listed will be made in the corresponding text: Detailed description.
8 1 Introduction
In the second chapter of this book, several common learning algorithms and their
applications in software defect prediction are briefly introduced, including deep
learning, transfer learning, dictionary learning, semi-supervised learning, and multi-
view learning.
In Chap. 3, we discussed mainly about within-project defect prediction but first
introduced basic WPDP including dictionary learning based software defect pre-
diction, collaborative representation classification based software defect prediction
and then introduced the sample-based software defect prediction with active and
semi-supervised learning belonging to the semi-supervised WPDP.
In Chap. 4, we expounded some methodologies on cross-project defect pre-
diction, including basic CPDP, among which we introduced manifold embedded
distribution adaptation; for class imbalance problem in CPDP, we proposed an
improved SDA based defect prediction framework; finally, in semi-supervised
CPDP, we introduced cost-sensitive kernelized semi-supervised dictionary learning.
In Chap. 5, we introduce Heterogeneous Defect Prediction (HDP), first explain-
ing unified metric representation and CCA-based transfer learning in basic HDP;
then in class imbalance problem in HDP, we introduce cost-sensitive transfer kernel
canonical correlation analysis. Finally, regarding multiple sources and privacy
preservation problems in HDP, we have introduced multi-source selection based
References 9
References
12. Peters F, Menzies T (2012) Privacy and utility for defect prediction: Experiments with
MORPH. In: Proceedings of the 34th International Conference on Software Engineering, pp
189–199. https://doi.org/10.1109/ICSE.2012.6227194
13. Peters F, Menzies T, Gong L, Zhang H (2013) Balancing Privacy and Utility in Cross-Company
Defect Prediction. IEEE Trans Software Eng 39(8):1054–1068. https://doi.org/10.1109/TSE.
2013.6
14. Grechanik M, Csallner C, Fu C, Xie Q (2010) Is Data Privacy Always Good for Software
Testing?. In: Proceedings of the IEEE 21st International Symposium on Software Reliability
Engineering, pp 368–377. https://doi.org/10.1109/ISSRE.2010.13
15. Brickell J, Shmatikov V (2008) The cost of privacy: destruction of data-mining utility
in anonymized data publishing. In: Proceedings of the 14th ACM SIGKDD International
Conference on Knowledge Discovery and Data Mining, pp 70–78. https://doi.org/10.1145/
1401890.1401904
16. Nam J, Kim S (2015) Heterogeneous defect prediction. In: Proceedings of the 10th Joint Meet-
ing on Foundations of Software Engineering, pp 508–519. https://doi.org/10.1145/2786805.
2786814
17. Jing X, Wu F, Dong X, Qi F, Xu B (2015) Heterogeneous cross-company defect prediction
by unified metric representation and CCA-based transfer learning. In: Proceedings of the 2015
10th Joint Meeting on Foundations of Software Engineering, pp 496–507. https://doi.org/10.
1145/2786805.2786813
18. Ryu D, Choi O, Baik J (2016) Value-cognitive boosting with a support vector machine
for cross-project defect prediction. Empir Softw Eng 21(1):43–71. https://doi.org/10.1007/
s10664-014-9346-4
19. Bennin KE, Toda K, Kamei Y, Keung J, Monden A, Ubayashi N (2016) Empirical Evaluation
of Cross-Release Effort-Aware Defect Prediction Models. In: Proceedings of the 2016 IEEE
International Conference on Software Quality, pp 214–221. https://doi.org/10.1109/QRS.2016.
33
20. Premraj R, Herzig K (2011) Network Versus Code Metrics to Predict Defects: A Replication
Study. In: Proceedings of the 5th International Symposium on Empirical Software Engineering
and Measurement, pp 215–224. https://doi.org/10.1109/ESEM.2011.30
21. Holschuh T, Pauser M, Herzig K, Zimmermann T, Premraj R, Zeller A (2009) Predicting
defects in SAP Java code: An experience report. In: Proceedings of the 31st International Con-
ference on Software Engineering, pp 172–181. https://doi.org/10.1109/ICSE-COMPANION.
2009.5070975
22. Monden A, Hayashi T, Shinoda S, Shirai K, Yoshida J, Barker M, Matsumoto K (2013)
Assessing the Cost Effectiveness of Fault Prediction in Acceptance Testing. IEEE Trans Softw
Eng 39(10):1345–1357. https://doi.org/10.1109/TSE.2013.21
23. Khoshgoftaar TM, Seliya N (2003) Fault Prediction Modeling for Software Quality Estimation:
Comparing Commonly Used Techniques Empir. Softw Eng 8(3):255–283. https://doi.org/10.
1023/A:1024424811345
24. Zhao Y, Yang Y, Lu H, Liu J, Leung H, Wu Y, Zhou Y, Xu B (2017) Understanding the value
of considering client usage context in package cohesion for fault-proneness prediction Autom.
Softw Eng 24(2):393–453. https://doi.org/10.1007/s10515-016-0198-6
25. Yang Y, Zhou Y, Lu H, Chen L, Chen Z, Xu B, Leung HKN, Zhang Z (2015) Are Slice-Based
Cohesion Metrics Actually Useful in Effort-Aware Post-Release Fault-Proneness Prediction?
An Empirical Study IEEE Trans. Softw Eng 41(4):331–357. https://doi.org/10.1109/TSE.2014.
2370048
26. Wang S, Liu T, Tan L (2016) Automatically learning semantic features for defect prediction.
In: Proceedings of the 38th International Conference on Software Engineering, pp 297–308.
https://doi.org/10.1145/2884781.2884804
27. Mende T, Koschke R (2010) Effort-Aware Defect Prediction Models. In: Proceedings of the
14th European Conference on Software Maintenance and Reengineering, pp 107–116. https://
doi.org/10.1109/CSMR.2010.18
References 11
28. Wang F, Huang J, Ma Y (2018) A Top-k Learning to Rank Approach to Cross-Project Software
Defect Prediction. In: Proceedings of the 25th Asia-Pacific Software Engineering Conference,
pp 335–344. https://doi.org/10.1109/APSEC.2018.00048
29. Shi Z, Keung J, Bennin KE, Zhang X (2018) Comparing learning to rank techniques in hybrid
bug localization. Appl Soft Comput 62636-648. https://doi.org/10.1016/j.asoc.2017.10.048
30. Liu T (2010) Learning to rank for information retrieval. In: Proceedings of the Proceeding of
the 33rd International ACM SIGIR Conference on Research and Development in Information
Retrieval, pp 904. https://doi.org/10.1145/1835449.1835676
31. Yu X, Li Q, Liu J (2019) Scalable and parallel sequential pattern mining using spark. World
Wide Web 22(1):295–324. https://doi.org/10.1007/s11280-018-0566-1
32. Bennin KE, Toda K, Kamei Y, Keung J, Monden A, Ubayashi N (2016) Empirical Evaluation
of Cross-Release Effort-Aware Defect Prediction Models. In: Proceedings of the 2016 IEEE
International Conference on Software Quality, pp 214–221. https://doi.org/10.1109/QRS.2016.
33
33. Yang X, Wen W (2018) Ridge and Lasso Regression Models for Cross-Version Defect
Prediction. IEEE Trans Reliab 67(3):885–896. https://doi.org/10.1109/TR.2018.2847353
34. Jiang Y, Cukic B, Ma Y (2008) Techniques for evaluating fault prediction models. Empir Softw
Eng 13(5):561–595. https://doi.org/10.1007/s10664-008-9079-3
35. Mende T, Koschke R (2009) Revisiting the evaluation of defect prediction models. In:
Proceedings of the 5th International Workshop on Predictive Models in Software Engineering,
pp 7. https://doi.org/10.1145/1540438.1540448
36. Nguyen TT, An TQ, Hai VT, Phuong TM (2014) Similarity-based and rank-based defect
prediction. In: Proceedings of the 2014 International Conference on Advanced Technologies
for Communications (ATC 2014), pp 321–325.
Chapter 2
Machine Learning Techniques
for Intelligent SDP
Abstract In this chapter, several common learning algorithms and their applica-
tions in software defect prediction are briefly introduced, including deep learning,
transfer learning, dictionary learning, semi-supervised learning, and multi-view
learning.
© The Author(s), under exclusive license to Springer Nature Singapore Pte Ltd. 2023 13
X.-Y. Jing et al., Intelligent Software Defect Prediction,
https://doi.org/10.1007/978-981-99-2842-2_2
14 2 Machine Learning Techniques for Intelligent SDP
Deep learning (DL) is an extension of prior work on neural networks where the
“deep” refers to the use of multiple layers in the network. In the 1960s and 1970s,
it was found that very simple neural nets can be poor classifiers unless they are
extended with (a) extra layers between inputs and outputs and (b) a nonlinear
activation function controlling links from inputs to a hidden layer (which can be
very wide) to an output layer. Essentially, deep learning is a modern variation
on the above which is concerned with a potentially unbounded number of layers
of bounded size. In the last century, most neural networks used the “sigmoid”
activation function .f (x) = 1+e1 −x , which was subpar to other learners in several
tasks. It was only when the ReLU activation function .f (x) = max(0, x) was
introduced by Nair and Hinton [4] that their performance increased dramatically,
and they became popular.
With its strong representation learning ability, deep learning technology has
quickly gained favor in the field of software engineering. In software defect
prediction (SDP), researchers began to use DL techniques to extract deep features
of defect data. Wang et al. [6] first introduced the Deep Belief Network (DBN)
[5] that learns semantic features and then uses classical learners to perform defect
prediction. In this approach, for each file in the source code, they extract tokens,
disregarding ones that do not affect the semantics of the code, such as variable
names. These tokens are vectorized and given unique numbers, forming a vector
of integers for each source file. Wen et al. [7] utilized Recurrent Neural Network
(RNN) to encode features from sequence data automatically. They propose a novel
approach called FENCES, which extracts six types of change sequences covering
different aspects of software changes via fine-grained change analysis. It approaches
defect prediction by mapping it to a sequence labeling problem solvable by RNN.
2.3 Other Techniques 15
Both sparse representation and dictionary learning have been successfully applied
to many application fields, including image clustering, compressed sensing as
well as image classification tasks. In sparse representation based classification,
the dictionary for sparse coding could be predefined. For example, Wright et al.
[8] directly used the training samples of all classes as the dictionary to code the
query face image and classified the query face image by evaluating which class
leads to the minimal reconstruction error. However, the dictionary in his method
may not be effective enough to represent the query images due to the uncertain
and noisy information in the original training images. In addition, the number of
atoms of dictionary that is made up of image samples can also be very large, which
increases the coding complexity. Dictionary learning (DL) aims to learn from the
training samples’ space where the given signal could be well represented or coded
for processing. Most DL methods attempt to learn a common dictionary shared by
all classes as well as a classifier of coefficients for classification.
Usually, the dictionary can be constructed by directly using the original training
samples, whereas the original samples have much redundancy and noise, which are
adverse to prediction. For the purpose of further improving the classification ability,
DL techniques have been adopted in SDP tasks recently to represent project modules
well. For example, Jing et al. [14] are the first to apply the DL technology to the field
of software defect prediction and proposed a cost-sensitive discriminative dictionary
learning (CDDL) approach. Specifically, CDDL introduces misclassification costs
and builds the over-complete dictionary for software project modules.
Due to the lack of labeled data, Semi-Supervised Learning (SSL) has always been
a hot topic in machine learning. A myriad of SSL methods have been proposed.
For example, co-training is a well-known disagreement-based SSL method, which
trains different learners to exploit unlabeled data. Pseudo-label style methods
label unlabeled data with pseudo labels. Graph-based methods aim to construct a
similarity graph, through which label information propagates to unlabeled nodes.
Local smoothness regularization-based methods represent another widely recog-
nized category of semi-supervised learning (SSL) techniques, which leverage the
inherent structure of the data to improve learning accuracy. Different methods apply
different regularizers, such as Laplacian regularization, manifold regularization, and
virtual adversarial regularization. For example, Miyato et al. [11] proposed a smooth
regularization method called virtual adversarial training, which enables the model
16 2 Machine Learning Techniques for Intelligent SDP
to output a smooth label distribution for local perturbations of a given input. There
are other popular methods, for example, Ladder Network.
Since large unlabeled data exist in software projects, many SSL techniques have
been considered in SDP tasks. Wang et al. [9] proposed a non-negative sparse-based
semiboost learning approach for software defect prediction. Benefit from the idea
of semi-supervised learning, this approach is capable of exploiting both labeled and
unlabeled data and is formulated in a boosting framework. Besides, Zhang et al. [10]
used graph-based semi-supervised learning technique to predict software defect.
This approach utilizes not only few labeled data but also abundant unlabeled ones
to improve the generalization capability.
References
1. Nam, Jaechang and Pan, Sinno Jialin and Kim, Sunghun. Transfer defect learning. 35th
international conference on software engineering (ICSE), 382–391, 2013.
2. Krishna, Rahul and Menzies, Tim. Bellwethers: A baseline method for transfer learning. IEEE
Transactions on Software Engineering, 45(11):1081–1105, 2018.
References 17
3. Jing, Xiaoyuan and Wu, Fei and Dong, Xiwei and Qi, Fumin and Xu, Baowen. Heterogeneous
cross-company defect prediction by unified metric representation and CCA-based transfer
learning. In Proceedings of the 2015 10th joint meeting on foundations of software engineering,
pages 496–507, 2015.
4. Nair, Vinod and Hinton, Geoffrey E. Rectified linear units improve restricted Boltzmann
machines. In Icml’10, 2010.
5. Hinton, Geoffrey E. Deep belief networks. Scholarpedia, 4(5):5947, 2009.
6. Wang, Song and Liu, Taiyue and Tan, Lin. Automatically learning semantic features for defect
prediction. In IEEE/ACM 38th International Conference on Software Engineering (ICSE),
pages 297–308, 2016.
7. Wen, Ming and Wu, Rongxin and Cheung, Shing-Chi. How well do change sequences
predict defects? sequence learning from software changes. IEEE Transactions on Software
Engineering, 46(11):1155–1175, 2018.
8. Wright, John and Yang, Allen Y and Ganesh, Arvind and Sastry, S Shankar and Ma, Yi. Robust
face recognition via sparse representation. IEEE transactions on pattern analysis and machine
intelligence, 31(2):210–227, 2008.
9. Wang, Tiejian and Zhang, Zhiwu and Jing, Xiaoyuan and Liu, Yanli. Non-negative sparse-
based SemiBoost for software defect prediction. Software Testing, Verification and Reliability,
26(7):498–515, 2016.
10. Zhang, Zhi-Wu and Jing, Xiao-Yuan and Wang, Tie-Jian. Label propagation based semi-
supervised learning for software defect prediction. Automated Software Engineering,
24(7):47–69, 2017.
11. Miyato, Takeru and Maeda, Shin-ichi and Koyama, Masanori and Ishii, Shin. Virtual
adversarial training: a regularization method for supervised and semi-supervised learning.
IEEE transactions on pattern analysis and machine intelligence, 41(8):1979–1993, 2018.
12. Chen, Ning and Zhu, Jun and Sun, Fuchun and Xing, Eric Poe. Large-margin predictive latent
subspace learning for multiview data analysis. IEEE transactions on pattern analysis and
machine intelligence, 34(12):2365–2378, 2012.
13. Jing, Xiao-Yuan and Hu, Rui-Min and Zhu, Yang-Ping and Wu, Shan-Shan and Liang, Chao
and Yang, Jing-Yu. Intra-view and inter-view supervised correlation analysis for multi-view
feature learning. In Proceedings of the AAAI Conference on Artificial Intelligence, pages 1882–
1889, 2014.
14. Kan, Meina and Shan, Shiguang and Chen, Xilin. Multi-view deep network for cross-view
classification. In Proceedings of the IEEE Conference on Computer Vision and Pattern
Recognition, pages 4847–4855, 2016.
15. Harwath, David and Torralba, Antonio and Glass, James. Unsupervised learning of spoken
language with visual context. In Advances in Neural Information Processing Systems, pages
1858–1866, 2016.
16. Hu, Junlin and Lu, Jiwen and Tan, Yap-Peng. Sharable and individual multi-view metric
learning. IEEE transactions on pattern analysis and machine intelligence, 40(9):2281–2288,
2017.
Chapter 3
Within-Project Defect Prediction
To fully exploit the discriminative information of training samples for improving the
performance of classification, we design a supervised dictionary learning approach,
which learns a dictionary that can represent the given software module more
effectively. Moreover, the supervised dictionary learning can also reduce both
the number of dictionary atoms and the sparse coding complexity. Instead of
learning a shared dictionary for all classes, we learn a structured dictionary .D =
[D1 , . . . , Di , . . . , Dc ], where .Di is the class-specified sub-dictionary associated
with class i, and c is the total number of classes. We use the reconstruction error
to do classification with such a dictionary D, as the SRC method does.
© The Author(s), under exclusive license to Springer Nature Singapore Pte Ltd. 2023 19
X.-Y. Jing et al., Intelligent Software Defect Prediction,
https://doi.org/10.1007/978-981-99-2842-2_3
20 3 Within-Project Defect Prediction
where .r(A, D, X) is the discriminative fidelity term; .‖X‖1 is the sparsity constraint;
λ is a balance factor.
.
j
Let .Xi = [Xi1 , Xi2 , Xic ], where .Xi is the coding coefficient matrix of .Ai over
the sub-dictionary .Dj . Denote the representation of .Dk to .Ai as .Rk = Dk Xik . First
of all, the dictionary D should be able to well represent .Ai , and, therefore, .Ai ≈
DXi = D1 Xi1 + · · · + Di Xii + · · · + Dc Xic . Secondly, since .Di is associated with the
ith class, it is expected that .Ai should be well represented by .Di (not by .Dj , j /= i),
2
j 2
which means both .Ai − Di Xii F and .Dj Xi should be minimized. Thus the
F
discriminative fidelity term is
c
r(A, D, X) = r (Ai , D, Xi )
i=1
.
⎛ ⎞
c 2 c 2
⎜ i j ⎟
= ⎝‖Ai − DXi ‖F + Ai − Di Xi +
2
Dj Xi ⎠
F F
i=1 j =1
j /=i
(3.2)
the .‖Ai − DXi ‖2F on the total dictionary D, .Ri may deviate much from .Ai so
that sub-dictionary .Di could not well represent .Ai . In order to achieve better
powerful reconstruction capability and powerful discriminative capability, we add
2
another two parts .Ai − Di Xii F (which minimizes the reconstruction error on sub-
j 2
dictionary of its own class) and .Dj Xi (which minimizes the reconstruction
F
term on sub-dictionary of the other class); both of them should also be minimized.
Figure 3.1b shows that the proposed discriminative fidelity term could overcome the
problem in Fig. 3.1a.
As previously stated, misclassifying defective-free modules leads to increasing
the development cost, and misclassifying defective ones is related with risk cost.
Cost-sensitive learning can incorporate the different misclassification costs into the
classification process. In this section, we emphasize the risk cost such that we add
the penalty factor .cost (i, j ) to increase the punishment when a defective software
module is predicted as a defective-free software module. As a result, cost-sensitive
dictionary learning makes the prediction incline to classify a module as a defective
one and generates a dictionary for classification with minimum misclassification
cost. The discriminative fidelity term with penalty factors is
c
r(A, D, X) = r (Ai , D, Xi )
i=1
. ⎡ ⎤
c 2 c 2
⎣‖Ai − DXi ‖2F + Ai − Di Xii +
cost(i, j ) Dj Xi ⎦
j
=
F F
i=1 j =1
(3.3)
Since there are only two classes in software defect prediction (the defective class and
the defective-free class), that is, .c = 2, the model of cost-sensitive discriminative
dictionary learning is
2
2
J(D,X) = arg min ‖Ai − DXi ‖2F + Ai − Di Xii
(D,X) F
i=1
. ⎤ ⎫ (3.4)
2 ⎬
j 2 ⎦
+ cost(i, j ) Dj Xi + λ‖X‖1
F ⎭
j =1
The CDDL objective function in Formula 3.4 can be divided into two sub-
problems: updating X by fixing D and updating D by fixing X. The optimization
procedure is iteratively implemented for the desired discriminative dictionary D
and corresponding coefficient matrix X. At first, suppose that D is fixed, the
objective function in formula is reduced to a sparse coding problem to compute
.X = [X1 , X2 ]. Here .X1 and .X2 are calculated one by one. We calculate .X1 with
fixed .X2 and then compute .X2 with fixed .X1 . Thus, formula is rewritten as
2
J(Xi ) = arg min ‖Ai − DXi ‖2F + Ai − Di Xii
(Xi ) F
⎫ (3.5)
⎬
.
2
j 2
+ cost(i, j ) Dj Xi + λ ‖Xi ‖1
F ⎭
j =1
Formula 3.5 can be solved by using the IPM algorithm in [1]. When X is fixed,
we in turn update .D1 and .D2 . When we calculate .D1 , .D2 is fixed, then we compute
.D2 , .D1 is fixed. Thus Formula 3.4 is rewritten as
⎧ 2
⎪
⎨ 2
J(Di ) = arg min −Di Xi − Dj X j
⎪
(Di ) ⎩
j =1
j /=i
. F (3.6)
⎫
2
2 ⎬
j 2
+ Ai − Di Xii + cos(i, j ) Dj Xi
F F⎭
j =1
where .Xi is the coding coefficient matrix of A over .Di . Formula 3.6 is a quadratic
programming problem, and we can solve it by using the algorithm in [2].
By utilizing the PCA technique, we are able to initialize the sub-dictionary for
each class. Given the low data dimension of software defect prediction, PCA can
create a fully initialized sub-dictionary for every class. This means that all sub-
dictionaries have an equal number of atoms, which is generally equivalent to the
data dimension.
The algorithm of CDDL converges since its two alternative optimizations are
both convex. Figure 3.2 illustrates the convergence of the algorithm.
3.1.1.2 Experiments
To evaluate our CDDL approach, we conduct some experiments. For all selected
datasets, we use the 1:1 random division to obtain the training and testing sets for
all compared methods. The random division treatment may affect the prediction
performance. Therefore, we use the random division, perform prediction 20 times,
and report the average prediction results in the following discussions.
3.1 Basic WPDP 23
a b
2 10
Total objective function value
0 0
1 5 10 15 20 25 30 1 5 10 15 20 25 30
Iteration number Iteration number
c d
2 5
Total objective function value
0 0
1 5 10 15 20 25 30 1 5 10 15 20 25 30
Iteration number Iteration number
Fig. 3.2 Convergence of the realization algorithm of CDDL on four NASA benchmark datasets.
(a) CM1 dataset. (b) KC1 dataset. (c) MW1 dataset. (d) PC1 dataset
In our approach, in order to emphasize the risk cost, the parameters cost (1,2) and
cost (2,1) are set as 1:5. For various projects, users can select a different cost ratio,
such as cost(1,2) to cost(2,1) [3]. And the parameter is determined by searching a
wide range of values and choosing the one that yields the best F-measure value.
We compare the proposed CDDL approach with several representative methods,
particularly presented in the last five years, including support vector machine (SVM)
[4], Compressed C4.5 decision tree (CC4.5) [5], weighted Naïve Bayes (NB) [6],
coding based ensemble learning (CEL) [7], and cost-sensitive boosting neural
network (CBNN) [8]. In this section, we present the detailed experimental results of
our CDDL approach and other compared methods.
3.1.1.3 Discussions
Table 3.2 shows the Pd and Pf values of our approach and other compared methods
on 10 NASA datasets. For each dataset, Pd and Pf values of all methods are the
mean values calculated from the results of 20 runs. The results of Pf values suggest
that in spite of not acquiring the best Pf values on most datasets, CDDL can achieve
24 3 Within-Project Defect Prediction
comparatively better results in contrast with other methods. We can also observe
that the Pd values of CDDL, which are presented with boldface, are higher than
the corresponding values of all other methods. CDDL achieves the highest Pd
values on all datasets. The results indicate that the proposed CDDL approach takes
the misclassification costs into consideration, which makes the prediction tend to
classify the defective-free modules as the defective ones in order to obtain higher
Pd values.
We calculate the average Pd values of 10 NASA datasets in Table 3.3. As
compared with other methods, the average Pd value of our approach is higher in
contrast with other related methods, and CDDL improves the average Pd value at
least by .0.15(= 0.79 − 0.64).
Table 3.4 shows the F-measure values of our approach and the compared methods
on 10 NASA datasets. In Table 3.4, F-measure values of CDDL are better than
other methods on all datasets, which means that our proposed approach outperforms
other methods and achieves the ideal prediction effects. According to the average F-
measure values shown in Table 3.4, CDDL improves the average F-measure value at
3.1 Basic WPDP 25
Table 3.4 F-measure values Datasets SVM CC4.5 NB CEL CBNN CDDL
on ten NASA datasets
CM1 .0.20 .0.25 .0.32 .0.27 .0.33 .0.38
Table 3.5 P -values between CDDL and other compared methods on ten NASA datasets
.CDDL
.CM1 .1.23 × 10−8 .3.51 × 10−6 .4.24 × 10−4 .1.80 × 10−4 .1.01 × 10−4
.JM1 .7.51 × 10
−18 .2.33 × 10
−13 .1.27 × 10
−14 .1.58 × 10
−13 .0.0564
.KC1 .1.20 × 10
−14 .1.23 × 10
−9 .8.38 × 10
−13 .2.80 × 10
−11 .9.69 × 10
−6
.MC2 .1.26 × 10
−4 .2.61 × 10
−5 .1.13 × 10
−8 .7.58 × 10
−6 .1.01 × 10
−4
.MW1 .1.14 × 10
−3 .2.31 × 10
−4 .1.10 × 10
−3 .1.84 × 10
−5 .2.20 × 10
−3
.PC1 .2.64 × 10
−4 .2.41 × 10
−5 .1.60 × 10
−8 .1.69 × 10
−5 .1.68 × 10
−8
.PC3 .7.79 × 10
−14 .7.73 × 10
−9 .1.04 × 10
−8 .4.03 × 10
−5 .4.31 × 10
−5
.PC4 .7.32 × 10
−8 .7.26 × 10
−4 .2.81 × 10
−16 .4.26 × 10
−6 .1.75 × 10
−10
.PC5 .3.01 × 10
−18 .7.00 × 10
−9 .1.90 × 10
−14 .1.30 × 10
−12 .2.13 × 10
−11
least by (.0.47 − 0.39 = 0.08). To sum up, Tables 3.3 and 3.4 show that our approach
has the best achievement in the Pd and F-measure values.
To statistically analyze the F-measure results given in Table 3.4, we conduct a sta-
tistical test, that is, Mcnemar’s test [9]. This test can provide statistical significance
between CDDL and other methods. Here, the Mcnemar’s test uses a significance
level of 0.05. If the p-value is below 0.05, the performance difference between two
compared methods is considered to be statistically significant. Table 3.5 shows the
p-values between CDDL and other compared methods on 10 NASA datasets, where
only one value is slightly above 0.05. According to Table 3.5, the proposed approach
indeed makes a significant difference in comparison with other methods for software
defect prediction.
26 3 Within-Project Defect Prediction
Figure 3.3 shows the flowchart of defect prediction in our approach, which includes
three steps. The first step is Laplace sampling process for the defective-free modules
to construct the training dataset. Second, the prediction models is trained by
using the CRC based learner. Finally, the CRC based predictor classifies whether
new modules are defective or defective-free. In the metric based software defect
prediction, the number of defective-free modules is much larger than that of
defective ones, that is, the class imbalance problem may occur. In this section, we
conduct the Laplace score sampling for training samples, which solves the class
imbalance problem effectively.
Sparse representation classification (SRC) represents a testing sample collabo-
ratively by samples of all classes. In SRC, there are enough training samples for
each class so that the dictionary is over-completed. Unfortunately, the number of
defective modules is usually much small. If we use this under-complete dictionary
to represent a defective module, the representation error may be much big and the
classification will be unstable. Fortunately, one fact in software defect prediction
is that software modules share similarities. Some samples from one class may be
very helpful to represent the testing sample of other classes. In CRC, this “lack of
samples” problem is solved by taking the software modules from the other class as
the possible samples of each class.
The main idea of CRC technique is that information of a signal can be
collaboratively represented by a linear combination of a few elementary signals.
We utilize .A = [A1 , A2 ] ∈ R m×n to denote the set of training samples which
is processed by Laplace sampling, and y denotes a testing sample. In order to
collaboratively represent the query sample using A with low computational burden,
we use the regularized least square method as follows:
X̂ = arg min ‖y − A · X‖22 + λ‖X‖22
. (3.7)
X
Training Instances
Test Instances
Laplace
Sampling
Building a Prediction Results
CRC_RLS (defective/defective-free)
Prediction Model
Software Defect Prediction
Database CRC Based Learner CRC Based Predictor
3.1.2.2 Experiments
In the experiment, ten datasets from NASA Metrics Data Program are taken as the
test data. We compare the proposed approach with several representative software
defect prediction methods, including Compressed C4.5 decision tree (CC4.5),
weighted Naïve Bayes (NB), cost-sensitive boosting neural network (CBNN), and
coding based ensemble learning (CEL).
3.1.2.3 Discussions
We use recall (Pd), false positive rate (Pf), precision (Pre), and F-measure as
prediction accuracy evaluation indexes. A good prediction model desires to achieve
high value of recall rate and precision. However, there exists trade-off between
precision and recall. F-measure is the harmonic mean of precision and recall rate.
Note that these quality indexes are commonly used in the field of software defect
prediction. Table 3.6 shows the average Pd, Pf, Pre, and F-measure values of our
CSDP approach and other compared methods on ten NASA datasets, where each
value is the mean of 20 random runs. Our approach can acquire better prediction
28 3 Within-Project Defect Prediction
accuracy than other methods. In particular, our approach improves the average Pd at
least by 16.95% (.= (0.745 − 0.637)/0.637) and the average F-measure at least by
19.23% (.= (0.465 − 0.390)/0.390).
set with the defect-proneness labels. Thus, the key for the sample-based defect
prediction to be cost-effective is to learn a well-performing classifier while keeping
the sample size small.
To improve the performance of sample-based defect prediction, we propose to
apply semi-supervised learning for classifier construction, which firstly learns an
initial classifier from a small sample of labeled training set and refines it by further
exploiting a larger number of available unlabeled data.
In semi-supervised learning, an effective paradigm is known as disagreement-
based semi-supervised learning, where multiple learners are trained for the same
task and the disagreements among the learners are exploited during learning. In
this paradigm, unlabeled data can be regarded as a special information exchange
“platform.” If one learner is much more confident on a disagreed unlabeled example
than other learner(s), then this learner will teach other(s) with this example; if
all learners are comparably confident on a disagreed unlabeled example, then this
example may be selected for query. Many well-known disagreement-based semi-
supervised learning methods have been developed.
In this study, we apply CoForest for defect prediction. It works based on a
well-known ensemble learning algorithm named random forest [10] to tackle the
problems of determining the most confident examples to label and producing the
final hypothesis. The pseudocode of CoForest is presented in Table 3.1. Briefly,
it works as follows. Let L denote the labeled dataset and U denote the unlabeled
dataset. First, N random trees are initiated from the training sets bootstrap-sampled
from the labeled dataset L for creating a random forest. Then, in each learning
iteration, each random tree is refined with the original labeled examples L and the
newly labeled examples .L' selected by its concomitant ensemble (i.e., the ensemble
of the other random trees except for the current tree). The learning process iterates
until certain stopping criterion is reached. Finally, the prediction is made based
on the majority voting from the ensemble of random trees. Note that in this way,
CoForest is able to exploit the advantage of both semi-supervised learning and
ensemble learning simultaneously, as suggested in Xu et al. [11].
In CoForest, the stopping criterion is essential to guarantee a good performance
Li and Zhou [12] derived a stopping criterion based on the theoretical findings
in Angluin and Laird [13]. By enforcing the worst case generalization error of a
random tree in the current round to be less than that in the preceded round, they
derived that semi-supervised learning process will be beneficial if the following
condition is satisfied
êi,t Wi,t−1
. < <1 (3.9)
êi,t−1 Wi,t
where .êi,t and .êi,t−1 denote the estimated classification error of the i-th random tree
in the t-th and (.t − 1)-th round, respectively, and .Wi,t and .Wi,t−1 denote the total
weights of its newly labeled sets L .i, t and L.i, t − 1 in the t-th and (.t − 1)-th round,
respectively, and .i ∈ {1, 2, . . . , N}. For detailed information on the derivation,
please refer to Li and Zhou [12].
30 3 Within-Project Defect Prediction
3.2.1.2 Experiments
tp
P =
. (3.10)
tp + fp
tp
. R= (3.11)
tp + f n
2P R
F =
. (3.12)
P +R
1 !2 !2 "
fn fp
.B = 1 − + (3.13)
2 tp + f n tn + fp
where tp, fp, tn, f n are the number of defective modules that are predicted as
defective, the number non-defective modules that are predicted as defective, the
number non-defective modules that are predicted as non-defective, and the number
defective module that are predicted as non-defective, respectively.
32 3 Within-Project Defect Prediction
3.2.1.3 Discussions
Our experiments show that a smaller sample can achieve similar defect prediction
performance as larger samples do. The sample can serve as an initial labeled training
set that represents the underlying data distribution of the entire dataset. Thus if there
is no sufficient historical datasets for building an effective defect prediction model
for a new project, we can randomly sample a small percentage of modules to test,
obtain their defect status (defective or non-defective), and then use the collected
sample to build a defect prediction for this project.
Our experiments also show that, in general, sampling with semi-supervised
learning and active learning can achieve better prediction performance than sam-
pling with conventional machine learning techniques. A sample may contain much
information that a conventional machine learner has already learned well but may
contain little information that the learner needs for improving the current prediction
accuracy. The proposed CoForest and ACoForest learners take the needs for learning
into account and obtain information needed for improving performance from the
unsampled modules.
Both CoForest and ACoForest methods work well for sample-based defect
prediction. ACoForest also supports the active selection of the modules—it can
actively suggest the QA team which modules to be chosen in order to increase the
prediction performance. Thus in order to apply ACoForest, interactions with test
engineers are required. If such interactions is allowed (which implies that more time
and efforts are allowed), we can apply the ACoForest method. If such interaction is
not allowed due to limited time and resources, we can apply the CoForest method.
In our approach, we draw a random sample from the population of modules.
To ensure proper statistical inference and to ensure the cost effectiveness of the
proposed method, the population size should be large enough. Therefore, the
proposed method is suitable for large-scale software systems.
The simple random sampling method requires that each individual in a sample
to be collected entirely by chance with the same probability. Selection bias may
be introduced if the module sample is collected simply by convenience, or from a
single developer/team. The selection bias can lead to non-sampling errors (errors
caused by human rather than sampling) and should be avoided.
The defect data for a sample can be collected through quality assurance activities
such as software testing, static program checking, and code inspection. As the
sample will be used for prediction, these activities should be carefully carried out so
that most of defects can be discovered. Incorrect sample data may lead to incorrect
estimates of the population.
In our experiments, we used the public defect dataset available at the PROMISE
dataset. Although this dataset has been used by many other studies [14–18], our
results may be under threat if the dataset is seriously flawed (e.g., there were
major problems in bug data collection and recording). Also, all the data used are
collected from open source projects. It is desirable to replicate the experiments on
industrial, in-house developed projects to further evaluate their validity. This will be
our important future work.
Exploring the Variety of Random
Documents with Different Content
marked, both as a restless and unbelieving man, he was more
assiduous than any one in his attendance at the court chapel, and
joined in singing hymns, which must have possessed all the charm
of novelty for him.[17]
How little feeling that most miserable of monarchs, Christian, really
had in the whole matter, is seen by a perusal of the Danish journals
at the time. The amusements of the court offer a most revolting
exhibition of apathy and want of sympathy.
On April 23, there was a masked ball, en domino, at which the king,
the queen dowager, and their suite were present; on the 24th,
instead of the play, a concert at the Danish theatre, where the royal
family were present; on the 25th, the sentence on Counts Struensee
and Brandt was pronounced in open court; in the evening, the opera
of Adrien en Syrie was performed. The small-pox continuing its
ravages, on the 26th, Sunday, profane amusements were interdicted
by the new government. On the 27th, the king dined with his court
at Charlottenlund, and returned to town at 7 P.M.; he signed the
sentences, and proceeded to the Italian Opera. On the 28th, the day
of the execution, there was a grand concert at court. Well may a
writer in the Annales Belgiques for May, 1772, remark:—
"If the king has unfortunately reached such a stage of unfeelingness,
what praise does not Caroline Matilda deserve for having succeeded
in captivating him so greatly that up to the present it was not even
suspected that he possessed such a disposition?"
In the meanwhile, Dr. Münter had informed Struensee, on April 26th,
of the promulgation of the sentences, and that they would be carried
into effect two days after. Struensee listened to him patiently, and
then remarked, as to the circumstances which were to throw infamy
upon his death—
"I am far above all this, and I hope my friend Brandt may be the
same. Here in this world—since I am on the point of leaving it—
neither honour nor infamy can affect me any more. It is equally the
same to me after death, whether my body putrifies under ground or
in the open air; whether it serves to feed the worms or the birds.
God will know very well how to preserve those particles of my body
which, on the day of resurrection, are to constitute my future
glorified body. It is not my all which is to be laid on the wheel.
Thank God! I know now very well that this dust is not my whole
being."
After this they conversed quietly about various matters concerning
Struensee's administration. The decision whether his government
had been politically bad he left to posterity, and many times
repeated his assurance that he was not conscious of any wrong
intentions. When Dr. Münter left him, Struensee handed him the
following letter for Frau von Berkentin at Pinneberg. This was the
patroness who, as chief gouvernante to the prince royal, had
recommended Struensee as physician in ordinary for the king's
foreign tour:—
Permit me to bewail with you and with the gracious lady your
mother, the fate of our dear Enevold. Do not think me unworthy
of sharing your grief with you, though, accidentally, I have been
the cause of it. You know how much I love him. He was the
man of all the world who possessed the largest share of my
friendship. His misfortunes cause me the greatest anxiety, and
my own have been on his account most painful to me. He has
shared my prosperity with me, and I trust that we shall now
together enjoy that happiness which our Redeemer has
promised us. I do not know anything wherewith I could comfort
you. You are acquainted with religion. In that I found a refuge
to comfort me on account of my misfortune. I pray to God that
he may at this very moment let you feel all its power. I shall not
cease to entertain a most lively sense of gratitude toward all
those persons who are dear to me at Rantzau. I am wholly
yours, &c.
April 27, 1772.
P.S.—I have been in hopes, and still flatter myself, that the
sentence of my friend will be mitigated.
The mangled remains, after they had been thrown into the cart,
were conveyed all through the city to the field at the other extremity,
where they were to be left to moulder or be devoured by the fowls
of the air. For each, four stout balks were, at equal distances, driven
into the earth; a taller pole was fixed in the centre; the entrails, &c.,
were buried in a hole dug at the foot of the central pole; on the top
the head was fixed, the pole being forced up inside the skull,
through which a spike was driven to make it fast; the hand was
nailed on a piece of board, placed transversely below the head; a
cart wheel was fixed horizontally on the top of each of the four posts
or pillars, on which a quarter of the body was exposed, made fast to
the wheel by iron chains.
The countless crowd, whose curiosity was now fully satisfied,
returned to the city, shaken by the scenes they had witnessed, and
the deep impression produced by the awful drama could be noticed
for a long time. Convicts had to be employed on the next day in
removing the scaffold, as no honest man would have a hand in it;
but Gallows Hill preserved its decorations for some years, and even
in 1775, Mr. Coxe saw Struensee's and Brandt's skulls and bones
there.[21] All this was done to satiate the vengeance of the queen
dowager. With a telescope in her hand, Juliana Maria had witnessed
the whole execution from the tower of the Christiansborg, and when
the turn arrived for the special object of her hatred, Struensee, she
rubbed her hands joyously, and exclaimed, "Now comes the fat one."
[22]
But the queen did not neglect to observe decorum even in this affair,
and hence, soon after the execution, sent for Dr. Münter, in order to
hear all the details of the judicial murder from this immediate
witness of the fearful scene. When he had ended his report, the
queen burst into tears; but, as our Danish authority remarks, "it is
notorious that a crocodile can weep." Then she said to Münter—
"I feel sorry for the unhappy man. I have examined myself whether
in all I have done against him I have acted through any feeling of
personal enmity; but my conscience acquits me of it."
After this, the queen dowager gave Dr. Münter a snuff-box of rock
crystal, while a similar gift in porcelain was forwarded to Dean Hee.
[23]
But the historian, Suhm, who was attached to the court, and was
one of the most zealous enemies of Struensee, tells us how far we
are justified in believing the queen dowager's statement. As the
queen occupied the upper floor of Christiansborg Palace, whence a
view of the Gallows Hill was obtained, Chamberlain Suhm asked her
some years later, why her Majesty, who had so many splendid
palaces at her service, inhabited these unpretending rooms, and
received the answer:—
"And yet these rooms are dearer to me than all my most splendid
apartments; for from these windows I saw my bitterest foe exposed
on the wheel."
Such was the end of a man whose miserable story is indubitably one
of the most romantic episodes of his century; and it only required a
Danish Walter Scott, in order to make of it an historical romance of
the first class. For such a work the matter is fully sufficient. But for
the same reason all efforts must fail to convert Struensee into the
hero of a tragedy. Many poets, some of them in the first flight, have
undertaken this ungrateful task, but have not attained any success
worth mentioning. The reason can easily be found. Struensee was
no hero; not even an original: he possessed no distinct character,
but was merely a type of his age, and in spite of his undeniable
talents, he was an ordinary adventurer after all. Fortune is as much
the touchstone of minds as misfortune is. It subjected this man to a
trial, and he came out of it badly. Arrogant and unbridled in fortune,
he proved himself in misfortune despondent, cowardly, and even
worthless. The fortune which he at first did not turn to a bad use,
brought a king's sceptre into his hand, and he allowed it to be
shamefully torn from him by people far inferior to him in intellect. A
queen, young and beautiful as a May morning, supported him, and
he betrayed her. He had felt a pride in being an avowed free-thinker,
and he died with wailing and gnashing of teeth, as a penitent sinner.
No, he was not a tragic hero. Even the genius of a Shakspere would
have failed in rendering him one.
It is a fact worthy of attention that Struensee possessed none of the
qualities which generally presuppose success at court. He was not
an amiable man, in the conventional sense of the term. The English
envoy, Gunning, who was not ill-disposed toward him, expressly
stated, in a despatch of April, 1770, that Struensee did not at all
display in his conversation the liveliness and pleasantry by which
other men pave the way to fortune. "His mode of behaving and
expressing himself is dry and even unpleasant, so that it was a
subject of general surprise how he contrived to acquire such
unbounded influence over the king and queen." Further, the envoy
allows the favourite "no inconsiderable acquirements," but denies
him all statesman-like ability and political tact. At the same time he
was deficient in sufficient insight into Danish affairs. He was
tolerably free from vanity, but not from an immoderate self-
confidence, which not unfrequently degenerated into "impudence."
The envoy, however, supplies us with the key to the enigma of
Struensee's sudden elevation, when he mentions that he was "bold
and enterprising," and such a man is sure to make his way among
women.[24]
Still, in spite of Struensee's deficiency and all his mistakes, so much
justice must be done him as to allow that he desired the welfare of
the state. He originally possessed a not ignoble mind, which was
lowered and degraded by his fabulous elevation and sudden fall.
Being formed of much softer and more worthless stuff than the
metal out of which great, or even second-rate statesmen are
composed, he could not endure either fortune or misfortune. An
idealist, trained in the school of enlightened despotism, he did not
understand that a nation must be raised from the bottom to the top.
This was the mistake of the age. The reasons of state of a Frederick
the Great or a Joseph II. were, after all, only an improvement of the
breed. We have all due respect for those enlightened despots who
have so far freed themselves from the swaddling-clothes of the
Byzantine ideas about the divine right of kings, as to wish
themselves to be merely regarded as the first servants of the state;
but, at the same time, we are inclined to say with old Wieland, "May
Heaven protect us from the luck of being obliged to live under the
sceptre or stick of such first servants of the state." Struensee acted
on the principle that, in order to make nations progress, nothing
further was required than to realise by edicts the principles of the
French philosophers and German illuminati. After the fashion of
many other world-betterers of the age, he did not know or reflect
that it is far more difficult to lead the unjudging masses to what is
good, than to what is bad; that the most absurd prejudices of the
plebs must be humoured far more than the noblest human
privileges; that the coarse diplomacy of pot-house demagogues is
sufficient to make the ignorant mob throw away the diamonds of
truth and eagerly clutch at the strass of falsehood and absurdity;
and that, lastly, the people in all times are most willing, at the desire
of their enemies, to hate, persecute, stone, and crucify their friends.
It is possible, even probable, that, if Struensee had held the power
longer, he would have passed from the experimentalising stage to
really beneficial results. The beginning of his display of power was
not so bad. Denmark had long sighed under the brutal dictatorship
which the envoys of Russia exercised. Struensee broke this yoke,
and did it so cleverly, that the ambitious czarina in Petersburg was
obliged to give way, whether she liked it or not. The management of
the foreign policy by Struensee least of all deserves blame, because
it was based on the sensible principle that Denmark must live in
peace and amity with all states, but not be subject to any one of
them. The same praise cannot be afforded to Struensee's home
administration. The tendency generally was good and reasonable
here, but the execution left much, very much, to be desired. We find
everywhere hasty attempts, but no thorough carrying through. A
despotic theorising, which was followed by no energetic practice,
and the most correct designs destroyed and confused by the
interference of personal interests, sympathies, and antipathies,
characterised the administration.
Struensee's great fault was that he did not, and would not,
understand that in statesman-like calculations, not abstract ideas but
men are the figures employed in reckoning—men with all their
weaknesses, follies, prejudices, and passions. Through mistaking this
great fact, he contrived to embitter all classes of the nation. He
offended the nobles without winning the peasants; he made the
officers, soldiers, and sailors his enemies, without making the
citizens his friends. And he did this among a people whose education
was behindhand, and to whom he was an object of hatred, from the
fact of his being a foreigner.
After his fall, which every one but himself had foreseen—and we
may fairly say that he signed his own death-warrant by the maniacal
cabinet decree which placed all the authority in his hands—
Struensee behaved like a miserable coward and traitor. It has been
said that his judges, or, more correctly, executioners, terrified the
ruined man by a menace of the torture, and, at the same time,
deluded him by the idea that his sole chance of salvation was in
compromising Caroline Matilda most deeply. But, for all this, a man
would never do, and only a weakling and coward would do what he
did, when he confessed, on February 21, that he had been the
queen's lover. From this moment he could only lay claim to a feeling
of contempt. It would not even excuse him were it true, as has been
alleged, that a pretended confession of Caroline Matilda's guilt was
shown him.
Still the means employed to get rid of the favourites were most
reprehensible. It is true that the queen dowager and Prince
Frederick had a right to feel irritated at having no credit at a court
where a Struensee domineered, and that they wished to remove him
and his partisans. We can understand that Queen Juliana Maria, who
had no experience of business, and Prince Frederick, who had scarce
emerged from boyhood, should not suspect the extremities to which
Guldberg's faction would lead them; and it may be true that it was
owing to their generosity that the children of Caroline Matilda were
not deprived of their rights. Nor can we positively condemn Guldberg
for wishing to tear from Struensee powers which Struensee had torn
from others. Perhaps Guldberg possessed more capacity, or a better
claim to hold the power than he. But, as to the means employed in
gaining the object, we cannot help agreeing with Falckenskjold when
he says:
"To make Struensee perish in order to seize on his office, was not
this purchasing it very dearly? and especially to add the punishment
of the unfortunate Brandt to that of Struensee, and to assail the
liberties and fortunes of so many persons who were innocent of the
ambition of these two men. And, in order to give a legal appearance
to these proscriptions, they do not hesitate to abuse whatever is
most sacred in human laws; they convert private intrigues into
judicial proceedings; they employ calumnious libels as authentic
documents and sentences; they raise the veil and expose to the
public the domestic secrets of the king's house! They do not fear
violently to break the happy union of the king with his consort; to
render doubtful the rights of the issue of that union, by
compromising the future tranquillity of the state; and, lastly, to cast
on a young queen the affront of a mortal stain, and to condemn her
to expire in a lengthened agony!
"Was the post of a principal minister of the King of Denmark so
important, or desirable at such a price?"
CHAPTER IV.
THE HIGH COMMISSION.
After the execution of the two counts, the turn came for the other
ten prisoners of state to be disposed of. In order to justify in the
sight of Europe the sanguinary treatment of the two principal
victims, these prisoners must also appear in the light of state
criminals, although no actual offence could be proved against a
single one of them. Although the grounds for their sentences are of
the most paltry description, it is easy to discover in them that, after
the removal of their real enemies, the dominant faction wished to
affect a display of mercy, probably through fear of public opinion,
which was beginning to be loudly expressed both at home and
abroad, about the cruel fate of the two counts.
The court believed it necessary to lay before the nation in print the
sentences of Counts Struensee and Brandt, and with them a list of
the crimes for which they were tried. This measure, however, had
the contrary effect to what was expected. Nothing was seen in this
sentence but a desire to prove the counts guilty, and a long series of
absurd conclusions, by which it was sought to attain this object: the
sentence on Count Brandt, more especially, revolted every one, and
the general dissatisfaction was unmistakable.[25] Hence, although it
was proposed in the council to lop off one or two more heads, one
of the judges, Kofod Ancher, thought it was time to say to the king,
as was said to Augustus, siste carnifex. It was therefore decided that
the only victim of judicial vengeance should be Falckenskjold, who
had dared to be an honest admirer of Struensee, and was really at
the same time an enlightened statesman and politician.
On April 21 a royal command was sent to the commissioners to hand
in an accurate representation of the offences of all the other persons
arrested on January 17, and more especially those who had been
guilty of minor crimes. This order was executed in a "most humble"
report, dated May 5. The poor wretches had been allowed to pass all
this time in prison, suffering from the most painful uncertainty.
Frau von Gähler was placed at the head of the list as the least guilty
sinner. She had attracted suspicion—so it was stated in the report—
by her intercourse with Struensee, by an uninterrupted
correspondence during the Holstein progress with her husband in
Copenhagen, by her being selected to be constantly in attendance
on the queen, by her and her husband's decoration with the queen's
Order of Matilda; and lastly, by the rumour that important papers
had been entrusted to her care. As, however, the closest
investigation had not produced a tittle of proof against her, and her
correspondence with her husband proved to be of the most innocent
nature, while other ladies who stood under no suspicion had enjoyed
equal favour at court, the commission had discovered nothing that
could be brought as a charge against her.
A similar declaration was issued by the commission in the matter of
Lieutenant-Colonel von Hesselberg. This officer who—on account of
the acquirements he had gained on foreign service, and the
intelligence displayed by him while holding an appointment at the
Academy of Military Cadets, had been proposed by Falckenskjold as
lieutenant-colonel of the king's regiment, because the latter wished
to have an efficient representative, while he went on diplomatic
business to Russia—had received orders to have an eye on
Struensee's youngest brother, who was appointed to his regiment.
Such was the state crime brought against this man of honour by the
exalted commissioners.
As an example of the condition of the Danish army at that day, the
circumstances connected with Hesselberg's appointment will be
perused with interest. When Falckenskjold, shortly after his arrival
from Russia, was appointed colonel of the king's regiment, the
quartermaster delivered to him an account of the state of the
regimental chest, according to which there ought to be 25,000
dollars in it. Falckenskjold replied, that he would take over the chest
after a committee of inquiry had sat. The quartermaster objected
that this was displaying an unusual suspicion, but Falckenskjold
stuck to his text, and lo and behold! there were but 95 dollars in the
chest. On his threatening to report the affair, 5,000 dollars were
produced, and the quartermaster bolted. A close investigation
proved that the missing sum had been stolen by frauds, in which the
officers were mixed up, and Falckenskjold was at last obliged to let
the matter drop, but for this very reason selected Hesselberg, in
whom he could trust, as his second in command.
The third ill-used man, against whom the commission could not
produce a scintilla of evidence either, was Rear-Admiral Hansen. He
had first formed Struensee's acquaintance when he received orders
to join the Algerine Committee, and afterwards assumed a special
command in the expedition. He had never spoken on any matters
but those connected with the navy to Struensee, and yet was kept
for months in prison as a dangerous criminal.
Equally little could be alleged against Councillor of Legation Sturtz.
His connection with Struensee had never possessed an intimate
character, which was proved by the fact, that he had remained
attached to Bernstorff. The sole reason for his lengthened residence
at Hirschholm, in the summer of 1771, was, that he, as a clever
amateur in portrait-painting, had received a commission to take the
likeness of the queen and prince royal, and the diamond ring
presented to him by the queen for his bride, was only an
acknowledgment given him for these works of art, which are still in
existence, and said to be excellent likenesses. Nor was anything in
the slightest degree incriminating found among his papers.
Lieutenant Aboe, of the navy, was the next prisoner declared to be
innocent. When a cadet he had formed the acquaintance of Brandt,
and became intimate with him, partly on account of the pecuniary
assistance the latter gave him, partly to be recommended to
Chamberlain Struensee, through whose application he obtained the
interim post of master of the crews at the navy docks, and of
adjutant to the Algerine expedition. In the latter capacity he
frequently waited on Struensee, and handed in some pretended
ameliorations in the administration of the navy, which, however, only
proved his ignorance. He had no further connection with Struensee,
and was, indeed, offended with the cabinet minister, because the
latter did not sufficiently recognise his merits.
The examination had thus proved that five innocent persons had
been kept in a state of torturing uncertainty as to their fate, and in
cruel imprisonment for four months and a half, while their relatives
were exposed to public contumely.
Of Etats-rath Willebrandt it was alleged that he had been so simple
and bold as to wish to reform the Admiralty College, without having
gained a proper insight of the administration of the navy, much less
of the difference in the business of the department during peace and
war, as he had solely obeyed the order given him to establish the
Admiralty College after the pattern of that of the Generalty. The
commissioners, it is true, declared that it was not within their
competence to judge the value of a plan which in any case had been
approved by his Majesty, and for this reason did not dare to express
dissatisfaction with it. Still they thought themselves at liberty to state
that which the result proved, that a portion of the plan, owing to
Willebrandt's ignorance, produced irregularity and inconveniences,
which could only be prevented by alterations and fresh expenses for
the king's treasury. After this, an allusion was made to the affair with
the enrolled sailors, who marched on Hirschholm in 1771.
Willebrandt's offence, therefore—the report went on to say—
consisted in his having undertaken to reform things of which he had
no thorough knowledge, and he thus produced scenes which might
easily have had dangerous consequences. It was not mentioned in
the report, however, that the king had given him this order, that
Count Haxthausen took part in it, and that both, when they drew up
the plan, expressly requested that the new scheme might be
previously examined by professional men.
Professor Berger, the physician in ordinary, also appeared to the
commission to have committed an offence. It was true that all the
medicines found in his house proved to be innocuous; there was no
proof that the steel cure attempted on his Majesty was improper; in
the matter of the rearing of the crown prince he had not agreed in
all points with Struensee, but rather had been the cause that
warmer clothing and better food were granted his royal highness
toward the close: it was also true that he expressed his anger at
Struensee having acquired a power which he considered prejudicial
to the nation; but he had given serious offence by concurring with
Struensee, and giving his advice and propositions in reforms of
which he probably knew nothing, more especially in things which did
not concern his trade as physician, or the res literariæ generally. As
a proof of this, it was alleged that he had proposed some persons to
fill the places of the dismissed members of the magistracy, and that
Struensee requested him to mention a person who would be suitable
for the chief post in the navy yards. Still the commission would not
venture to judge of the use or disadvantage of such propositions, as
the papers found on the accused and the other prisoners, on which
their argument must be founded, contained no information about
them.
This was everything that could be brought against a professional
man, who, in spite of his zealous attention to the king's health, and
his well-earned reputation, was dragged to the fortress, and, like a
murderer, prohibited the use of knife and fork, and was not allowed
to shave himself, or sleep on his own mattress.
If the conduct of the commission had hitherto retained a varnish of
justice, the royal resolution, minuted by Councillor of Conference
Schumacher, and issued on May 18, was a strange proof of tyranny,
which smote truth on the face with open falsehoods. For it was
stated in this resolution, that the persons who had been guilty of the
"smallest crimes" should be punished in the following way:—
Frau von Gähler would be set at liberty, but must refrain from
appearing at court so long as her husband's affair was not
concluded.
Rear-Admiral Hansen and Lieutenant Aboe would be discharged from
arrest, and report themselves to the Admiralty College, where they
would learn the king's commands with respect to them.
Legations-rath Sturtz would also be released from arrest, and
ordered to proceed to Holstein. He would retain his pension of 500
dollars, which had been granted him by the royal resolution of
January 26, but must expend it away from the court.
Etats-rath Willebrandt, after being discharged, would proceed to one
of the small towns in Seeland, where an annual pension of 300
dollars would be paid him.
Professor Berger, lastly, after being set at liberty, would go to
Aalborg, in northern Jütland, where a pension of 300 dollars would
be paid him, until a post of provincial surgeon became vacant in
Jütland.
These decisions the commissioners made known to the persons
concerned with the solemn warning that, after the king had
pardoned them this time, through special mercy, for their incautious,
thoughtless, and criminal conduct, they must be very careful not to
give rise to greater suspicion by word or writing, as, in that case,
they would be subjected to a further examination, and might expect
the king's most serious displeasure.
The sovereign lord over the life and death of his subjects was
consequently of a different opinion from the commissioners, who
had found the accused guilty of no offence. But it was considered
desirable to get rid of those persons most hated, and, in order to
convict them, it was requisite to accuse them of offences at the
expense of truth.
Lieutenant-Colonel von Hesselberg, who was referred to the
Commissariat College, learnt there that the king had appointed him
Commander of the 2nd National Battalion of Schleswig-Holstein. This
distinguished officer afterwards became colonel of an infantry
regiment in Norway, where he died in 1808, a lieutenant-general,
and commandant of the fortress of Bergenhuus.
Rear-Admiral Hansen was informed by the Admiralty that he had
forfeited his post as deputy of the latter college, but would continue
to serve the state. He died a few years after the catastrophe.
Lieutenant Aboe, who also learnt his future fate from the Admiralty,
received orders to pass two years abroad, but retained his
commission and pay. Eventually, he left the service with the rank of
captain, set up as a merchant in Copenhagen, failed, made voyages
to the East Indies, and died after many hard adventures in
Copenhagen.
The three exiles, Legations-rath Sturtz, Etats-rath Willebrandt, and
Professor Berger, in obedience to the royal commands, quitted the
capital, and proceeded to their several destinations. When
Falckenskjold was recalled from Switzerland by the crown prince in
1788, he found Willebrandt still in exile: Berger was a practising
physician at Kiel, but Sturtz had died of grief.[26]
The public of Copenhagen were astonished at this mild treatment of
persons who had been kept in such close arrest. Much worse had
been anticipated. But three state criminals still remained in prison,
and what had been spared their associates, who were punished for
having been proved innocent, could be done to them.
Lieutenant-General von Gähler, Colonel and Chamberlain von
Falckenskjold, and Justiz-rath Struensee, were still awaiting their
sentence. But on May 10 an order had been issued to the
commission to lay before the king a full report of the crimes of these
men, for his Majesty's most gracious consideration and resolution. In
obedience with this command, the commission sent in its report on
May 30.
With respect to Gähler, it was alleged that he was mixed up both in
the Traventhal league and the abolition of the council. It was true
that he had denied both, but, on the first point, the letters found at
his house contradicted him. As regards the council, he had not, as
his duty ordered, sufficiently represented the value of the council in
his answers to the questions laid before him for explanation on Sept.
24, 1770, and there were even strong reasons for conjecturing that
he proposed and promoted the abolition of the council, because he
was Struensee's principal adviser about this time. In the same way
he had recommended to his friend Struensee, the abolition of the
verbal reports of the colleges. By this, the general had helped to
conceal Struensee's audacious conduct from the king, and given
him, Struensee, opportunity for filching all the power and authority.
It was allowed that Von Gähler, by his propositions, had no intention
of sustaining Struensee in his situation and promoting his autocracy.
Still, he ought, and must have noticed Struensee's boundless
ambition, when he perceived that the latter "wished to apply the
practice of his profession to the state, and began by amputating
from it so important a limb as the council was." General von Gähler
ought the less to have attempted to promote Struensee's views, as
he was not adapted either by nature or Providence to regulate or
remodel a state. He ought not to have furnished Struensee with
projects, all the consequences of which he could not foresee. More
especially, he ought not to have advised the suppression of verbal
reports, but to have always opposed it. But he appeared to have
been possessed by a mania for reformation. As a proof, it might be
mentioned that he proposed the reform for which was introduced
into Norway by the regulation of January 14, 1771, that lands, after
ten years' tenure, should become freehold, which no man of
perspicuity could have advised.[27] The commission found a second
instance in the reform of the two Chanceries, although the division
of business, according to provinces, had had the best results.
Before all, however, Von Gähler wished to remodel the navy. It was
quite incredible what tricks he employed to get it into his hands, and
the commission reports that the misfortune which befel the Algerine
expedition gave Von Gähler the desired opportunity for effecting it.
Herr von Gähler's crime, therefore, principally consisted in the fact,
that he interfered in everything, and wished to reform all the
regulations of the state, without possessing the requisite knowledge
and insight, without knowing the advantages or defects of what
existed, and without sufficiently pondering over the consequences of
his propositions. The commission, however, could find no excuse in
the circumstance that Von Gähler's proposed reforms only consisted
of ideas and thoughts, whose trial by experiments injured nobody,
because most of the affairs in which he interfered in no way
concerned him, and the trouble he took in order to obtain a
justification for doing so, proved a greater offence; for he had
applied to Struensee, a man who was even more ignorant than
himself in such things, and blindly followed everything that was
proposed to him, especially when such propositions suggested
radical changes. The commission, however, would not omit
mentioning that the general, since May, 1771, had possessed no
special influence over Struensee, because he had joined the
opposition against the reduction of the Horse Guards, and besides,
he had not commended himself to the cabinet minister, by
representing to him how little the power he had appropriated agreed
with the royal law. Lastly, the general also displayed firmness when
the Foot Guards were disbanded; he had likewise resisted the
removal of the two regiments, and in the Generalty represented to
Chamberlain von Falckenskjold how improper it was to propose the
regiment of the hereditary prince for such a dislocation, without first
asking whether this would be agreeable to the prince.
The second of the criminal three was Colonel and Chamberlain von
Falckenskjold. According to the opinion of the commission, he was
the man who, next to Brandt, stood in the closest intimacy with
Struensee. Perhaps, however, Falckenskjold's notorious dislike of the
hereditary prince, and his bold and manly behaviour in the presence
of the commission, had their share in prejudicing his judges against
him, so that they, through personal hatred, behaved in the most
unscrupulous way toward a man of honour. Professor Sevel acted as
inquisitor, and seemed to find a pleasure in insulting the fallen friend
of Struensee by all sorts of cruel questions. We can form an idea of
this man's moral value on seeing that Sevel, in his examination, so
far forgot what he owed to himself as a judge, as to express his
regret that Struensee had not been murdered by the sailors. In their
report, the commissioners first made Falckenskjold's intimacy with
Struensee a capital offence, and asserted that he had sought to
maintain this intimacy so eagerly, because he and Brandt had
received the greatest benefactions from Struensee. The latter not
only conferred on him offices and honorary posts, but also gave him
money out of the royal treasury.
Thus, Falckenskjold, although on May 2, 1771, he had received from
the cabinet treasury, in payment of his travelling expenses to
Petersburg, the usual sum of 400 dollars, obtained on the 19th of
the same month 2,000 dollars more, under the same excuse, from
the private treasury, and, after his return, or in a period of three
months, a further sum of 3,500 dollars. Of these amounts, Struensee
paid him 1,000 dollars under the false allegation that Falckenskjold
had spent them on the journey from his private means, while the
2,000 dollars were paid him without the king's cognizance. How he
had earned these presents, neither he nor Struensee would have
been able to specify, and the assertion that the king had promised to
pay Von Falckenskjold's debts by degrees, was only an empty
pretext, for the latter had deposited 2,000 dollars with the minister
of finances, and therefore could only have had debts to the amount
of 400 dollars; and moreover, he never expressed the proper thanks
to his Majesty for such large gifts in money. The commission
consequently assumed that Struensee desired to acquire
Falckenskjold's gratitude, and declared in their report that they had
strong grounds for believing that it had been arranged between the
couple, that Struensee should be supported under all circumstances,
and guarded against any possible surprise, on which Falckenskjold's
own fortunes also depended.
In understanding with Struensee, he proposed the abolition of the
Chevalier guard, and no other had been more busy than
Falckenskjold in setting at work the cabinet order of December 21. If
any event occurred, and Struensee believed himself in danger,
Falckenskjold was immediately at hand; he had not merely proved
his devotedness to Struensee in this way, but also, for the sake of
pleasing the minister, had neglected the reverence due to the
hereditary prince, and in this had gone so far that he had furnished
proofs of it in the presence of the entire public. Two facts had
convinced the commission of this daring sentiment of Falckenskjold,
which was based on affection for Struensee, namely, the removal of
the prince's regiment, and more especially the occurrence on the
walls. The latter event, the commission represented as follows:—
In the spring of 1771, the prince was, one day, riding along the walls
at the moment when Colonel Falckenskjold was "exercising" his
band, composed of hautboists and fifers; the colonel blocked the
road, and marched straight upon the prince. Both majors of the
regiment called his attention to the fact, that the prince was coming
toward them; but Falckenskjold let his men march on. A groom of
the prince's now rode up, and requested room for his royal highness
to pass. The adjutant reported it to the colonel, and asked whether
the band should not leave off playing, and room be made for the
prince? but Falckenskjold answered: "No, not even if the good God
were to come along Himself." He allowed the band to continue
playing, and the prince, in order to pass, was compelled to ride close
to the parapet.
Falckenskjold alleged, in his excuse, that he had orders to let the
band play in public places, especially when the king came past, and
for this reason there would have been an impropriety in his stopping
the band on the arrival of the prince. The colonel also observed that,
in France, where he had served a long time, an officer was rarely on
guard without hearing the sentinel shout, "Aux armes! le bon Dieu
arrive!" when the Catholic priests passed with the host, and hence it
had grown into a habit to confirm a negative by saying, "No, I would
not do it, even if le bon Dieu were to come." The commission,
however, considered that this sort of defence contradicted itself, and
the colonel ought certainly to have made way for the prince.
Colonel Falckenskjold's crime, consequently, consisted in his having
sold himself to Struensee, in having always had an understanding
with him, in having advised the reduction of both Guards, in having
expressed himself for Struensee's conservation, in having given
proofs, on every occasion, how anxious he was that Struensee
should escape a surprise, and lastly, in having tried, for the sake of
pleasing Struensee, to cause annoyance to his Royal Highness Prince
Frederick, and, for this object, having been so audacious as to
neglect the respect due to his royal highness. Without dwelling on
Falckenskjold's numerous and high services to the king and country,
the commission concluded their report with the disgraceful
statement, that they could not refrain from seeing in Colonel and
Chamberlain von Falckenskjold a foolhardy, detrimental, and the
more dangerous man, because he would do anything for money.
The third and last upon whom the commission had to express an
opinion was Justiz-rath Struensee. As he had only been released
from his chains by special favour, after his brother's execution, it
might have been expected that the commission would depict him as
a great criminal. It was quite different, however, though through no
love of truth and justice on the part of the Inquisition, but in
consequence of commands from higher quarters. For Frederick II. of
Prussia, who had kept Struensee's place, as professor at Liegnitz,
open for him, while he went to try his luck, allowed his minister, Herr
von Arnim, whose tutor Struensee had been, to employ his master's
name in claiming him.[28]
The report on this prisoner of state, after opening with the
statement that Justiz-rath Struensee, though he only possessed a
theoretical knowledge of the laws and constitution of Denmark,
readily accepted a seat as deputy in the Financial Department, and
had the special inspection of the Mint, the Bank, and the course of
Exchange—in the hope of obtaining a better knowledge of these
branches of the administration by industry and work—acknowledged
his irreproachable conduct in the latter respect, and added the
remark, that the commission could express this with the greater
confidence, as the College of Finances, at their request, had had the
matter examined by an authority on the subject. As concerned his
functions as deputy of the finances generally, however, the
commission must blame Justiz-rath Struensee for a tendency to
foolhardy boasting about services which he had not rendered, and
arbitrariness in financial matters, as he wrote to a friend that all the
others in the Financial College understood nothing, and eventually
strove to become Contrôleur Général des Finances.
Although, as regarded his official administration as deputy, there
were no positive proofs that he had abused his charge to the injury
of the king and country for his own interest, yet there was a
tolerably strong presumption that, with the help of his brother and
his office, he wished to render all the subjects in Denmark tributary
to a few Brandenburg partners, who were to hold the salt and
tobacco monopolies, in exchange for profits promised to him and his
brother. As regards the salt-farming, the commission allowed that
the Justiz-rath had accepted no benefit for himself, but annually paid
over to the king the 10,000 dollars intended for himself. In the
matter of the tobacco-farming, however, some suspicion clung to
him that he, contrary to his brother's advice, accepted the two
shares offered him to promote the affair. But although, in spite of all
Justiz-rath Struensee's allegations to the contrary, the strongest
presumptions existed against him and his integrity, the
commissioners felt themselves bound to state that it was not his
intention to deprive the Danish tobacco-planters and spinners of
their livelihood, as the farming proposition was not carried into
effect.[29]
However—thus runs the forced conclusion of the report:—the reports
as to the Justiz-rath's former life in Prussia are generally satisfactory,
and he is honoured with the distinguished favour of Prince Henry,
the brother of Frederick II., who takes a lively interest in him, and
considers him incapable of any serious crime. Besides, no traces had
been found that the Justiz-rath had intrigued with his brother, and
just as few that he had interfered in things that did not concern him.
Finally, it could not be alleged as an offence that he received 4,000
dollars from the private treasury, under the title of gratifications,
because the first 2,000 were given him with the king's assent, and
there was no evidence of his being aware that the other 2,000 were
paid him without the cognizance of the king.
After the commissioners, probably with a heavy heart, had closed
their report in so mild a way, there followed, on June 12, 1772, a
royal resolution, containing his Majesty's "will and commands"
respecting the crimes of Lieutenant-General von Gähler, Colonel and
Chamberlain von Falckenskjold, and Justiz-rath and Deputy of
Finances Struensee. The king had learned from the report of the
commissioners that—
Von Gähler generally undertook to remodel and reform the whole
arrangements of the state, though he possessed no vocation or
knowledge for it; further, that Von Falckenskjold devoted himself
entirely to Struensee, was joined with him in a portion of his
injurious enterprises, and declared himself in favour of his
conservation, and on all occasions furnished proof of this, and
displayed a further audacious mode of behaviour; and that, lastly,
Strong presumptions existed against Justiz-rath Struensee and his
honest performance of his duties, and that he had not fully
consulted with the other persons concerned on matters that came
before the College of Finances.
For this reason, the commission would make known to Lieutenant-
General von Gähler, that, on account of his thoughtless and improper
undertaking, he was dismissed from the king's service, had forfeited
the royal favour granted him in the decree of March 26, 1767,[30]
and must at once select a spot in the Danish monarchy—Seeland,
Fühnen, and Schleswig excepted—where he would permanently