Introduction to Algorithms for Data Mining and Machine Learning 1st edition - eBook PDF pdf download
Introduction to Algorithms for Data Mining and Machine Learning 1st edition - eBook PDF pdf download
https://ebookluna.com/download/introduction-to-algorithms-for-
data-mining-and-machine-learning-ebook-pdf/
https://ebookluna.com/download/big-data-analytics-introduction-to-
hadoop-spark-and-machine-learning-ebook-pdf/
ebookluna.com
https://ebookluna.com/product/ebook-pdf-introduction-to-machine-
learning-with-python-a-guide-for-data-scientists/
ebookluna.com
https://ebookluna.com/product/ebook-pdf-introduction-to-business-data-
mining-1st-edition/
ebookluna.com
(eBook PDF) Machine Learning Refined: Foundations,
Algorithms, and Applications
https://ebookluna.com/product/ebook-pdf-machine-learning-refined-
foundations-algorithms-and-applications/
ebookluna.com
https://ebookluna.com/product/ebook-pdf-introduction-to-data-mining-
global-edition-2nd-edition/
ebookluna.com
Big Data Mining for Climate Change 1st edition - eBook PDF
https://ebookluna.com/download/big-data-mining-for-climate-change-
ebook-pdf/
ebookluna.com
https://ebookluna.com/product/ebook-pdf-introduction-to-data-
mining-2nd-edition-by-pang-ning-tan/
ebookluna.com
https://ebookluna.com/download/machine-learning-for-planetary-science-
ebook-pdf/
ebookluna.com
Xin-She Yang
Introduction to
Algorithms for Data Mining
and Machine Learning
Introduction to Algorithms for Data Mining and
Machine Learning
This page intentionally left blank
Introduction to
Algorithms for Data
Mining and Machine
Learning
Xin-She Yang
Middlesex University
School of Science and Technology
London, United Kingdom
Academic Press is an imprint of Elsevier
125 London Wall, London EC2Y 5AS, United Kingdom
525 B Street, Suite 1650, San Diego, CA 92101, United States
50 Hampshire Street, 5th Floor, Cambridge, MA 02139, United States
The Boulevard, Langford Lane, Kidlington, Oxford OX5 1GB, United Kingdom
Copyright © 2019 Elsevier Inc. All rights reserved.
No part of this publication may be reproduced or transmitted in any form or by any means, electronic or
mechanical, including photocopying, recording, or any information storage and retrieval system, without
permission in writing from the publisher. Details on how to seek permission, further information about the
Publisher’s permissions policies and our arrangements with organizations such as the Copyright Clearance Center
and the Copyright Licensing Agency, can be found at our website: www.elsevier.com/permissions.
This book and the individual contributions contained in it are protected under copyright by the Publisher (other
than as may be noted herein).
Notices
Knowledge and best practice in this field are constantly changing. As new research and experience broaden our
understanding, changes in research methods, professional practices, or medical treatment may become necessary.
Practitioners and researchers must always rely on their own experience and knowledge in evaluating and using
any information, methods, compounds, or experiments described herein. In using such information or methods
they should be mindful of their own safety and the safety of others, including parties for whom they have a
professional responsibility.
To the fullest extent of the law, neither the Publisher nor the authors, contributors, or editors, assume any liability
for any injury and/or damage to persons or property as a matter of products liability, negligence or otherwise, or
from any use or operation of any methods, products, instructions, or ideas contained in the material herein.
ISBN: 978-0-12-817216-2
1 Introduction to optimization 1
1.1 Algorithms 1
1.1.1 Essence of an algorithm 1
1.1.2 Issues with algorithms 3
1.1.3 Types of algorithms 3
1.2 Optimization 4
1.2.1 A simple example 4
1.2.2 General formulation of optimization 7
1.2.3 Feasible solution 9
1.2.4 Optimality criteria 10
1.3 Unconstrained optimization 10
1.3.1 Univariate functions 11
1.3.2 Multivariate functions 12
1.4 Nonlinear constrained optimization 14
1.4.1 Penalty method 15
1.4.2 Lagrange multipliers 16
1.4.3 Karush–Kuhn–Tucker conditions 17
1.5 Notes on software 18
2 Mathematical foundations 19
2.1 Convexity 20
2.1.1 Linear and affine functions 20
2.1.2 Convex functions 21
2.1.3 Mathematical operations on convex functions 22
2.2 Computational complexity 22
2.2.1 Time and space complexity 24
2.2.2 Complexity of algorithms 25
2.3 Norms and regularization 26
2.3.1 Norms 26
2.3.2 Regularization 28
2.4 Probability distributions 29
2.4.1 Random variables 29
2.4.2 Probability distributions 30
vi Contents
3 Optimization algorithms 45
3.1 Gradient-based methods 45
3.1.1 Newton’s method 45
3.1.2 Newton’s method for multivariate functions 47
3.1.3 Line search 48
3.2 Variants of gradient-based methods 49
3.2.1 Stochastic gradient descent 50
3.2.2 Subgradient method 51
3.2.3 Conjugate gradient method 52
3.3 Optimizers in deep learning 53
3.4 Gradient-free methods 56
3.5 Evolutionary algorithms and swarm intelligence 58
3.5.1 Genetic algorithm 58
3.5.2 Differential evolution 60
3.5.3 Particle swarm optimization 61
3.5.4 Bat algorithm 61
3.5.5 Firefly algorithm 62
3.5.6 Cuckoo search 62
3.5.7 Flower pollination algorithm 63
3.6 Notes on software 64
Bibliography 163
Index 171
About the author
Xin-She Yang obtained his PhD in Applied Mathematics from the University of Ox-
ford. He then worked at Cambridge University and National Physical Laboratory (UK)
as a Senior Research Scientist. Now he is Reader at Middlesex University London, and
an elected Bye-Fellow at Cambridge University.
He is also the IEEE Computer Intelligence Society (CIS) Chair for the Task Force
on Business Intelligence and Knowledge Management, Director of the International
Consortium for Optimization and Modelling in Science and Industry (iCOMSI), and
an Editor of Springer’s Book Series Springer Tracts in Nature-Inspired Computing
(STNIC).
With more than 20 years of research and teaching experience, he has authored
10 books and edited more than 15 books. He published more than 200 research pa-
pers in international peer-reviewed journals and conference proceedings with more
than 36 800 citations. He has been on the prestigious lists of Clarivate Analytics and
Web of Science highly cited researchers in 2016, 2017, and 2018. He serves on the
Editorial Boards of many international journals including International Journal of
Bio-Inspired Computation, Elsevier’s Journal of Computational Science (JoCS), In-
ternational Journal of Parallel, Emergent and Distributed Systems, and International
Journal of Computer Mathematics. He is also the Editor-in-Chief of the International
Journal of Mathematical Modelling and Numerical Optimisation.
This page intentionally left blank
Preface
Both data mining and machine learning are becoming popular subjects for university
courses and industrial applications. This popularity is partly driven by the Internet and
social media because they generate a huge amount of data every day, and the under-
standing of such big data requires sophisticated data mining techniques. In addition,
many applications such as facial recognition and robotics have extensively used ma-
chine learning algorithms, leading to the increasing popularity of artificial intelligence.
From a more general perspective, both data mining and machine learning are closely
related to optimization. After all, in many applications, we have to minimize costs,
errors, energy consumption, and environment impact and to maximize sustainabil-
ity, productivity, and efficiency. Many problems in data mining and machine learning
are usually formulated as optimization problems so that they can be solved by opti-
mization algorithms. Therefore, optimization techniques are closely related to many
techniques in data mining and machine learning.
Courses on data mining, machine learning, and optimization are often compulsory
for students, studying computer science, management science, engineering design, op-
erations research, data science, finance, and economics. All students have to develop
a certain level of data modeling skills so that they can process and interpret data for
classification, clustering, curve-fitting, and predictions. They should also be familiar
with machine learning techniques that are closely related to data mining so as to carry
out problem solving in many real-world applications. This book provides an introduc-
tion to all the major topics for such courses, covering the essential ideas of all key
algorithms and techniques for data mining, machine learning, and optimization.
Though there are over a dozen good books on such topics, most of these books are
either too specialized with specific readership or too lengthy (often over 500 pages).
This book fills in the gap with a compact and concise approach by focusing on the key
concepts, algorithms, and techniques at an introductory level. The main approach of
this book is informal, theorem-free, and practical. By using an informal approach all
fundamental topics required for data mining and machine learning are covered, and
the readers can gain such basic knowledge of all important algorithms with a focus
on their key ideas, without worrying about any tedious, rigorous mathematical proofs.
In addition, the practical approach provides about 30 worked examples in this book
so that the readers can see how each step of the algorithms and techniques works.
Thus, the readers can build their understanding and confidence gradually and in a
step-by-step manner. Furthermore, with the minimal requirements of basic high school
mathematics and some basic calculus, such an informal and practical style can also
enable the readers to learn the contents by self-study and at their own pace.
This book is suitable for undergraduates and graduates to rapidly develop all the
fundamental knowledge of data mining, machine learning, and optimization. It can
xii Preface
also be used by students and researchers as a reference to review and refresh their
knowledge in data mining, machine learning, optimization, computer science, and data
science.
Xin-She Yang
January 2019 in London
Acknowledgments
I would like to thank all my students and colleagues who have given valuable feedback
and comments on some of the contents and examples of this book. I also would like to
thank my editors, J. Scott Bentley and Michael Lutz, and the staff at Elsevier for their
professionalism. Last but not least, I thank my family for all the help and support.
Xin-She Yang
January 2019
This page intentionally left blank
Introduction to optimization
Contents
1.1 Algorithms
1 1
1.1.1 Essence of an algorithm 1
1.1.2 Issues with algorithms 3
1.1.3 Types of algorithms 3
1.2 Optimization 4
1.2.1 A simple example 4
1.2.2 General formulation of optimization 7
1.2.3 Feasible solution 9
1.2.4 Optimality criteria 10
1.3 Unconstrained optimization 10
1.3.1 Univariate functions 11
1.3.2 Multivariate functions 12
1.4 Nonlinear constrained optimization 14
1.4.1 Penalty method 15
1.4.2 Lagrange multipliers 16
1.4.3 Karush–Kuhn–Tucker conditions 17
1.5 Notes on software 18
This book introduces the most fundamentals and algorithms related to optimization,
data mining, and machine learning. The main requirement is some understanding of
high-school mathematics and basic calculus; however, we will review and introduce
some of the mathematical foundations in the first two chapters.
1.1 Algorithms
An algorithm is an iterative, step-by-step procedure for computation. The detailed
procedure can be a simple description, an equation, or a series of descriptions in
combination with equations. Finding the roots of a polynomial, checking if a natu-
ral number is a prime number, and generating random numbers are all algorithms.
Example 1
As an example, if x0 = 1 and a = 4, then we have
1 4
x1 = (1 + ) = 2.5. (1.2)
2 1
Similarly, we have
1 4 1 4
x2 = (2.5 + ) = 2.05, x3 = (2.05 + ) ≈ 2.0061, (1.3)
2 2.5 2 2.05
x4 ≈ 2.00000927, (1.4)
√
which is very close to the true value of 4 = 2. The accuracy of this iterative formula or algorithm
is high because it achieves the accuracy of five decimal places after four iterations.
The convergence is very quick if we start from different initial values such as
x0 = 10 and even x0 = 100. However, for an obvious reason, we cannot start with
x0 = 0 due to division by
√zero.
Find the root of x = a is equivalent to solving the equation
f (x) = x 2 − a = 0, (1.5)
which is again equivalent to finding the roots of a polynomial f (x). We know that
Newton’s root-finding algorithm can be written as
f (xk )
xk+1 = xk − , (1.6)
f (xk )
where f (x) is the first derivative or gradient of f (x). In this case, we have
f (x) = 2x. Thus, Newton’s formula becomes
(xk2 − a)
xk+1 = xk − , (1.7)
2xk
1.2 Optimization
V = πr 2 h. (1.12)
There are only two design variables r and h and one objective function S to be min-
imized. Obviously, if there is no capacity constraint, then we can choose not to build
the container, and then the cost of materials is zero for r = 0 and h = 0. However,
Introduction to optimization 5
the constraint requirement means that we have to build a container with fixed volume
V0 = πr 2 h = 10 m3 . Therefore, this optimization problem can be written as
πr 2 h = V0 = 10. (1.14)
To solve this problem, we can first try to use the equality constraint to reduce the
number of design variables by solving h. So we have
V0
h= . (1.15)
πr 2
Substituting it into (1.13), we get
S = 2πr 2 + 2πrh
V0 2V0
= 2πr 2 + 2πr 2 = 2πr 2 + . (1.16)
πr r
This is a univariate function. From basic calculus we know that the minimum or max-
imum can occur at the stationary point, where the first derivative is zero, that is,
dS 2V0
= 4πr − 2 = 0, (1.17)
dr r
which gives
V0 3 V0
r3 = , or r = . (1.18)
2π 2π
Thus, the height is
h V0 /(πr 2 ) V0
= = 3 = 2. (1.19)
r r πr
6 Introduction to Algorithms for Data Mining and Machine Learning
This means that the height is twice the radius: h = 2r. Thus, the minimum surface is
It is worth pointing out that this optimal solution is based on the assumption or re-
quirement to design a cylindrical container. If we decide to use a sphere with radius R,
we know that its volume and surface area is
4π 3
V0 = R , S = 4πR 2 . (1.21)
3
We can solve R directly
3V0 3 3V0
R =
3
, or R = , (1.22)
4π 4π
which gives the surface area
3V 2/3 √
0 4π 3 9 2/3
S = 4π =√ 3
V0 . (1.23)
4π 16π 2
√3 √ √ 3
Since 6π/ 4π 2 ≈ 5.5358 and 4π 3 9/ 16π 2 ≈ 4.83598, we have S < S∗ , that is, the
surface area of a sphere is smaller than the minimum surface area of a cylinder with
the same volume. In fact, for the same V0 = 10, we have
√
4π 3 9 2/3
S(sphere) = √ 3
V0 ≈ 22.47, (1.24)
16π 2
which is smaller than S∗ = 25.69 for a cylinder.
This highlights the importance of the choice of design type (here in terms of shape)
before we can do any truly useful optimization. Obviously, there are many other fac-
tors that can influence the choice of design, including the manufacturability of the
design, stability of the structure, ease of installation, space availability, and so on. For
a container, in most applications, a cylinder may be much easier to produce than a
sphere, and thus the overall cost may be lower in practice. Though there are so many
factors to be considered in engineering design, for the purpose of optimization, here
we will only focus on the improvement and optimization of a design with well-posed
mathematical formulations.
Introduction to optimization 7
where f (x), φj (x), and ψk (x) are scalar functions of the design vector x. Here the
components xi of x = (x1 , . . . , xD )T are called design or decision variables, and they
can be either continuous, discrete, or a mixture of these two. The vector x is often
called the decision vector, which varies in a D-dimensional space RD .
It is worth pointing out that we use a column vector here for x (thus with trans-
pose T ). We can also use a row vector x = (x1 , . . . , xD ) and the results will be the
same. Different textbooks may use slightly different formulations. Once we are aware
of such minor variations, it should cause no difficulty or confusion.
In addition, the function f (x) is called the objective function or cost function,
φj (x) are constraints in terms of M equalities, and ψk (x) are constraints written as
N inequalities. So there are M + N constraints in total. The optimization problem
formulated here is a nonlinear constrained problem. Here the inequalities ψk (x) ≤ 0
are written as “less than”, and they can also be written as “greater than” via a simple
transformation by multiplying both sides by −1.
The space spanned by the decision variables is called the search space RD , whereas
the space formed by the values of the objective function is called the objective or
response space, and sometimes the landscape. The optimization problem essentially
maps the domain RD or the space of decision variables into the solution space R (or
the real axis in general).
The objective function f (x) can be either linear or nonlinear. If the constraints φj
and ψk are all linear, it becomes a linearly constrained problem. Furthermore, when
φj , ψk , and the objective function f (x) are all linear, then it becomes a linear pro-
gramming problem [35]. If the objective is at most quadratic with linear constraints,
then it is called a quadratic programming problem. If all the values of the decision
variables can be only integers, then this type of linear programming is called integer
programming or integer linear programming.
On the other hand, if no constraints are specified and thus xi can take any values
in the real axis (or any integers), then the optimization problem is referred to as an
unconstrained optimization problem.
As a very simple example of optimization problems without any constraints, we
discuss the search of the maxima or minima of a univariate function.
8 Introduction to Algorithms for Data Mining and Machine Learning
2
Figure 1.2 A simple multimodal function f (x) = x 2 e−x .
Example 2
For example, to find the maximum of a univariate function f (x)
f (x) = x 2 e−x ,
2
−∞ < x < ∞, (1.26)
is a simple unconstrained problem, whereas the following problem is a simple constrained mini-
mization problem:
subject to
x1 ≥ 1, x2 − 2 = 0. (1.28)
It is worth pointing out that the objectives are explicitly known in all the optimiza-
tion problems to be discussed in this book. However, in reality, it is often difficult to
quantify what we want to achieve, but we still try to optimize certain things such as the
degree of enjoyment or service quality on holiday. In other cases, it may be impossible
to write the objective function in any explicit form mathematically.
From basic calculus we know that, for a given curve described by f (x), its gradient
f (x) describes the rate of change. When f (x) = 0, the curve has a horizontal tangent
at that particular point. This means that it becomes a point of special interest. In fact,
the maximum or minimum of a curve occurs at
f (x∗ ) = 0, (1.29)
Example 3
To find the minimum of f (x) = x 2 e−x (see Fig. 1.2), we have the stationary condition
2
f (x) = 0 or
Figure 1.3 (a) Feasible domain with nonlinear inequality constraints ψ1 (x) and ψ2 (x) (left) and linear
inequality constraint ψ3 (x). (b) An example with an objective of f (x) = x 2 subject to x ≥ 2 (right).
f (x) = 2e−x (1 − 5x 2 + 2x 4 ),
2
two maxima that occur at x∗ = ±1 with fmax = e−1 . At x = 0, we have f (0) = 2 > 0, thus
the minimum of f (x) occurs at x∗ = 0 with fmin (0) = 0.
Whatever the objective is, we have to evaluate it many times. In most cases, the
evaluations of the objective functions consume a substantial amount of computational
power (which costs money) and design time. Any efficient algorithm that can reduce
the number of objective evaluations saves both time and money.
In mathematical programming, there are many important concepts, and we will
first introduce a few related concepts: feasible solutions, optimality criteria, the strong
local optimum, and weak local optimum.
In January 1887, after having previously made six exploring expeditions to the
interior of Somáliland, I started upon my first sporting trip after big game, my
caravan consisting of eight Somális with four camels. Marching thirty-five miles
inland from Berbera, we pitched our first shooting camp at Hulkabóba, and the
following day we ascended the Golis Range by the Sheikh Pass, halting in Mirso, a
ledge two miles wide, situated two thousand feet above our last camp, and about
half-way up the mountain, where there is excellent pasturage. We here formed our
bivouac beside a spring of clear water, and in the sandy torrent beds which formed
its approaches we found many lion and koodoo tracks. Before leaving the coast I had
sent two Somális on horseback to the cedar forests which clothe the flat top of Gólis
to search for fresh elephant tracks. On this evening they arrived to report having
found no recent sign, so I decided to go to Sheikh, twelve miles to the east, and
thence to try Wagar Mountain.
At about 3 p.m. we loaded up and started on our march. The path led over rocky
country along the side of Gólis, through thick belts of jungle and across sandy
torrent beds, which in many places showed the fresh tracks of lion and antelope, but
not of elephants. It was very hot and the sharp stones were fearfully trying to the
camels, nevertheless we had to push on in order to reach water while daylight
lasted; we failed, and night overtaking us, we were compelled to camp on the
hillside without it.
Next morning our march took us through a maze of ravines, about the worst
ground I have ever traversed with baggage animals; then descending abruptly to
Lower Sheikh, we found a plot of green turf bordering a stream and surrounded on
all sides by steep mountains. The Sheikh Pass takes its name from the tomb of a
sheikh built in the form of a sugar-loaf plastered with a white substance, which
forms a very conspicuous landmark at the top of the pass. While forming camp at
Lower Sheikh we were passed by a large caravan, which was fording the stream on
its way with hides, gum, feathers, and other commodities, from the Ogádén country
to Berbera, and soon afterwards my trackers arrived with the welcome news that
they had struck the path of a herd of elephants,—a bull and four cows,—two
marches to the south of the sheikh’s grave. They had followed and marked down the
elephants to a jungle where they were likely to stay, at the back of Wagar, and they
further reported the bull to be a fine tusker. I engaged three horsemen from among
the Habr Gerhajis, whose pastures were at Lower Sheikh, to take up the tracks, and
on sighting the herd to send one of their number back to guide us to the spot;
meanwhile I waited at Lower Sheikh, looking about for koodoo. Soon afterwards my
people led in a shepherd boy, who had seen a bull and cow koodoo retire up one of
the steep gorges of the Sheikh valley to take their noon rest under a large tree. A
hot walk along the banks of the Sheikh river, at this time a mere brook, brought us
to the karia where the boy had first seen the koodoos. On the left bank of the river a
gorge ran up into the mountains, and opposite to its mouth stood the karia, a circle
of half a dozen poor-looking huts.
I waited here while my Midgán hunter and the boy went to the foot of the hills;
soon they reported that the position of the game was unchanged. The koodoos were
still under the large tree at the head of the gorge some four or five hundred feet
above us. The only way to get at them was to go up another gorge parallel to the
one which contained the tree, and to leeward of it. On nearing the tree, after a
tedious climb, I happened to crack a stick, and immediately there followed a crash
and stampede below us. All noise soon ceased, but I caught sight of something
moving down the gorge in front. Stooping cautiously, I looked through a thorn-bush,
placing the muzzle of my express within the network of twigs; after a second or two
I could make out one large brown spiral horn and a bit of striped skin lying
somewhere over the shoulder, so taking a quick aim a little below this, I touched the
trigger and a beautiful bull koodoo rolled twenty feet down into the torrent bed in
the centre of the gorge, and was stopped by a large mass of rock. The cow galloped
madly away, loosening a shower of stones with her hoofs, and soon there came from
below the sound of two shots from a Snider as she raced past my camelman, Núr
Osman, who had been posted at the mouth of the gorge; but crossing the Sheikh
stream, she took to the hills on the opposite side of the valley and escaped. Leaving
orders at the karia for a camel to follow us with the koodoo meat we started home.
The return walk in the evening down the valley was as wild and picturesque as
one could wish. Núr Osman and the Midgán led the way, carrying the head and skin
of my first koodoo, at which I could not help looking admiringly from time to time,
for it was a great prize. Our path led close to the stream, over dark slippery rocks,
with here and there a plot of rich turf running down to the water’s edge. At our
backs the sun was setting behind the crest of Golis, and in front rose gigantic
precipices, the hills having been quarried out by the river into a deep canon. As it
grew dusk my reflections were disturbed by a wart-hog boar, which had come down
to drink in the cool stream after a hot day, but I had no reason for firing at him, his
tusks being poor.
The next day one of the three horsemen came back to tell me that he had marked
down the herd of elephants, and that it was being watched by his companions. He
carried in his hand pieces of half-chewed aloes with the saliva still damp upon them,
which the elephants had torn up a few hours ago. Leaving most of the baggage
behind in the camp at Lower Sheikh, and posting Núr Osman and another of the
men in charge, I mounted the Sheikh Pass the next morning at sunrise, accompanied
by two camels and five men. At the top of the pass I shot a spotted hyæna, to the
delight of the mullahs living at the village of Guldu Hamed close by, as it had stolen
several of their sheep.
Half an hour before sunset two horsemen came racing over the plain from the
Wagar direction, and poising their spears circled round us at full speed. They pulled
up shouting “Mót!” (Hail!) and reported the latest tidings about the herd. I learned
the melancholy news that it had got away in the night. My men, however, tried to
comfort me by saying, “Insh’ Allah Bukera” (Please God, to-morrow). We camped at
an empty zeríba in a strip of bush near Soksodi, where there was firewood and
water, intending to search for the elephants next day. We lit a roaring fire and threw
ourselves down on the sand to sleep. At dawn, while my men were preparing coffee,
I took a stroll round camp, and saw by several broad footprints in the sand that a
large lion had been prowling round our bivouac all night Later on my men pointed
out old tracks of elephants, broken branches, and aloe clumps, indicating the course
of a herd which must have passed two or three days before. I sent all the men into
the covert to look for fresh tracks, but at noon they returned unsuccessful.
At two in the afternoon some shepherds came to water a flock of
sheep on their way to the Berbera market, and they said that they had
passed a herd of elephants only an hour ago in a valley to the south. On
my asking for a guide they refused, hoping to get me to pay heavily for
their information, so I shouldered my double four-bore rifle and started
with the two Midgán trackers on the back trail of the sheep, hoping to
find the elephants without a guide. The path led past two small
sandstone hills, and we then entered a sloping valley, down the centre
of which ran a sand-river bordered by dense jungle. Heavy masses of
armo creeper draped the branches of the trees, and as we advanced
fragments of creeper, which had evidently been torn down by the
elephants, lay across our path.
We soon came to the fresh tracks of a herd which must have passed
early in the day, and the Midgáns began to follow the footprints with
great interest. The signs became every moment more distinct; at one
spot the elephants had taken a long halt, rolling in the sand; and after
half an hour’s tracking we found evidences that we were quite close to
them. Sitting down with one of the Midgáns, I sent the other up a small
hill to look around; he soon returned, whispering “Maródi, Maródi!”
(elephants). Having joined us, he shaded his eyes to have another look,
and then stretching out his hand, he pointed to two reddish brown spots
among the lower branches of a clump of high trees on the farther side
of a glade. As we looked six large elephants and four calves walked
solemnly by twos or in single file out into the open. Even in this moment
of excitement, for I had never seen a wild elephant before, I noticed the
huge ears of the African species, the high fore-quarters and quick, active
pace, and a beautiful sight it was! Swinging their heads from side to
side, they crossed the glade and entered a clump of trees. Here they
stopped and began feeding about, the swaying and snapping of the
branches, and the peculiar low rumbling which they give out when
feeding, indicating where they stood, though we could not see them.
The Midgáns, who were new to the work of attacking elephants on
foot, did not quite like the prospect of going with me into the middle of
the herd, so taking the four-bore, and telling them to watch from a low
hill, I began creeping into the jungle alone. In thick forests the chief
difficulty of elephant hunting consists in picking out the one with the
best tusks, and then getting close up to it without being winded or seen
by the others.
I threw up some sand to try the direction of the wind, and then
advanced very silently for a hundred yards into the thickest jungle. I
heard the rustle of some creepers in front of me, and then peeping
through the underwood I saw three elephants fanning themselves with
their ears under a very large camel-thorn-tree, whose branches rose to
a flat fan shape high above their heads. It was from this thorn-tree that
one of them had just been pulling down the creepers. From my left
came the rumbling sound made by a fourth elephant, but I could see
nothing there. I had on entering the jungle unconsciously walked into
the very centre of the herd, and there was now no time to be lost in
making my choice, because one of them might at any moment get down
wind of me and sound the alarm.
The elephants I had seen were standing about forty yards away, one
being a little apart from the other two, close to a tree, and I could see
that a pair of tusks protruded from its lips. I advanced to within fifteen
yards of the foremost one, which looked quietly at me for some
moments, its trunk feeling the wind, as if wondering whether I might or
might not be the stump of a tree. Raising my rifle I fired at the centre of
the temple, half-way between the eye and the ear. The smoke obscured
my view, but I the next instant could hear the jungle stirring all round
me as the elephants made off. Then every living thing seemed to have
left the place. As the smoke cleared away it disclosed, fifteen yards off,
the body of the elephant sitting motionless with its knees tucked under
its chest, a single hole in the temple showing where the bullet had
entered. This turned out to be the largest cow in the herd, and I
afterwards found, by a thorough examination of the tracks in the
neighbourhood, that there was not a single bull.
Satisfied with my success so far as it went, I did not follow the herd,
and in answer to my whistle the Midgáns came up, astonished to see
that a single bullet had done the business. The camels were brought up,
and we formed our bivouac by the dead elephant, and at dusk the tusks
lay beside the camp-fire. Next day we marched to Sheikh, and found the
camp safe, and in the evening began our march back to Berbera.
Two months later I set out again, beginning by a dhow voyage of one
hundred and fifty miles across the Gulf of Aden. I hired four camels and
two camelmen at five rupees a day, or about £10 for a whole month.[14]
I also engaged a caravan leader, three servants, two Somáli trackers,
and a Midgán, not a large party to go into an unknown country with. To
guard against the possible attack by robbers at a time when the English
even at the coast were very little known, I lent my three servants a
Snider carbine each. The remainder of the men had their spears and
shields, and the Midgán, Adan, carried his bow and arrows. My “butler,”
Núr Osman, had been a camelman in the Nile expedition for the relief of
Gordon, and had become a very fair shot.
By the light of a full moon we started across the Berbera Maritime
Plain, going south-west; and at 1 a.m. we reached a small tree called
“Nasíya” (the resting-place), sixteen miles from the coast. Early in the
night we passed several karias of trading caravans which were halted
round Berbera for the trading season, each circle of mat huts pouring
out a crowd of Midgán dogs to give us a surly salute. At the last karia I
fired at a spotted hyæna, but missed him. At Nasíya we threw ourselves
down on the sand, and unloading the camels took a short sleep to
refresh ourselves for the work yet before us, and at 4 a.m. we pushed on
again towards the first water, Deregódleh, which is twenty-two miles
from Berbera. As we advanced the bare-looking Maritime Plain began to
break up into stony watercourses and thorny bush. We passed, to our
right, a detached flat-topped hill of trap formation called Sýene, part of
the first low Maritime Range.
Near Sýene I saw two buck Sœmmering’s gazelles, looking large and
white by the light of the rising sun, which was at my back. The wind
was blowing from the front, and I made a careful stalk, but on raising
my head from the last watercourse the aoul had removed themselves
three hundred yards distant, and were stopping to gaze. They had seen
my camels coming along. Then with whisking tails they trotted away,
and I never saw them again. Very nearly related to this gazelle is the
Cape springbuck. Sœmmering’s gazelle carries a pair of graceful, lyre-
shaped black horns, about fourteen inches in length and well ringed.
When still scarcely clear of Sýene, catching a glimpse of dark red in a
watercourse two hundred yards to my left, I walked towards it, put up a
Waller’s gazelle, and bagged him with my Martini-Henry rifle.
At 10 a.m. we reached Deregódleh, a watercourse which has cut its
way deep into the limestone rock of the interior plain and hollowed it
out into caves, in which sheep, when waiting at the wells, take shelter
from the sun. There is some very low cover on each bank, in which
hares and the little Sakáro antelopes are to be found.
We left Deregódleh and marched to Mandeira, a delightful
headquarters. It is a valley about three miles wide, under Gán Libah
mountain, a bluff of the great Gólis Range. The mountains overlooking
this valley rise to about six thousand feet above sea-level. The high
country beyond them is called Ogo, the interior and Maritime Plains
below them are called Guban. The Ogo climate is much cooler than that
of Guban, and the grass and jungle more luxuriant. At Mandeira, all
along the foot of Gólis, is more or less dense forest of the large gudá
thorn-tree, with a thick undergrowth of aloes and thorny bushes. Here
are found leopards, lesser koodoo, Walleri, and wart-hog. The pugs of
an occasional lion may be seen, and in the gorges of the mountain is to
be found the large koodoo, with his splendid spiral horns, and the
Alakud or klipspringer. In the stony interior plains between Gólis and the
Maritime Range are found oryx, wild ass, the ubiquitous Walleri, the
lowland gazelles, and a few shy ostriches. Spotted hyænas are common,
striped hyænas rare.
We camped near the water at Mandeira at midday, and found the
valley occupied by a section of the Habr Gerhajis tribe, who were
friendly. While here I shot a buck lesser koodoo and missed a splendid
bull koodoo, which crossed a ledge of rock two hundred feet above us.
The buck lesser koodoo is, I think, the most beautiful wild animal in
Somáliland; his coat is fairly long, of a French gray colour in old males,
and nicely marked with white bands across the body. The horns are
spiral, and about twenty-five inches long, and he has a bushy tail tipped
with white. When disturbed he goes away in great bounds, flying the
bushes and clumps of aloes, and presenting a most difficult shot.
Whilst I stood admiring the herd disappearing among the trees like a
dissolving view, I was reminded by the bloodthirsty Hussein that we had
come to destroy elephants, and not to stare at them, so, the temptation
being too much for me, we took up their tracks through the heavy
timber, with bad aloe undergrowth, the crash, as an elephant now and
then playfully broke a tree ahead of us, being carried to our ears. Once
we followed too close, for a prolonged crash in our direction told that an
old cow was investigating the taint in the air. We, of course, gave her
plenty of room, as I wanted to have another look for a bull before
advancing to the attack, and when all was quiet we resumed our
tracking. The jungle was very fine, so that while we were following the
elephants we were generally in the shade. We found the small Sakáro
antelopes very numerous, standing behind the aloes to gaze at us and
then darting off with their whistling alarm-note. Sometimes we came on
several tortoises, some of their shells measuring quite two feet long and
a foot wide. They seemed to live in small families of four or five, and are
very common in the aloe jungles.
At last, after a walk of little more than a mile, we again sighted the
elephants standing at the edge of the forest belt, crowded together in
three large groups, looking uncommonly suspicious. Some high ground
overlooked the jungle, and circling round as far as possible under cover,
we reached a position very open and exposed, but otherwise good,
being down wind and sixty yards from the nearest group. We were
standing on a spur of the Damel Plain, covered with loose gravel and
sprinkled with a few small bushes. After a rapid examination of the
ground I opened fire at the biggest elephant, and with indescribable
commotion and clouds of dust the three groups dissolved into a long
string, rushing past us headlong through the forest, only intent on
escape.
The big cow which I had fired at was hidden in dust for a moment,
and then spinning round in a semicircle, she made off after the others,
her stern quite closing up the path. Following on in her wake we caught
up with some of the herd which were lagging, and I fired at one which
appeared to be a young bull, bringing it down stone dead on its side,
the bullet having caught it behind the shoulders while going by at full
speed. Unfortunately, on inspection it proved to be a cow. Then,
continuing in the direction taken by the herd, we at length saw the cow
which had been first hit standing within forty yards of a large tree, and
stalking up to the tree, which was to leeward of her, I fired at her
temple. She went down and rolled over on her side, the men, delighted
at my success, running up to jump on her back. Suddenly I shouted
“Look out, she’s getting up!” and I had scarcely time to cover her temple
with the foresight from where I stood, twenty yards away, before she
was on her legs again, with ears stuck out at right angles. Another shot
from the four-bore, and she fell dead.
The severe kick of the rifle generally sent me back a couple of yards,
and I must have been standing wrong, for as I fired something gave
way in my right leg, and I came down in a sitting posture on to a clump
of aloes, unable to rise at once, and wondering whether the elephant
was dead or not. I was laid up in camp for three days, but on the fourth
I could limp about very creditably, and killed a fine wart-hog boar near
camp, besides firing at five striped hyænas, which were prowling about
at dusk among the rocks. When we had cut out the tusks of the two
cows we resolved to try fresh ground, and getting astride of my mule I
marched with my caravan to Hembeweina, sixteen miles lower down the
river. Here we found in the sand the tracks of six lions of different ages,
which had been prowling about in the river-bed and in the bordering
reeds. Close to camp we found the half-eaten carcase of a spotted
hyæna which they had caught. They must have been badly off for food
to have eaten a hyæna; indeed, from the absence of fresh tracks, we
thought the rest of the game must have been frightened from the
vicinity by the lions.
The day after our arrival at Hembeweina I was again disturbed before
dawn by Núr Osman, with the report that a lot of elephants had been
heard trumpeting near the water during the night, and after a good
breakfast we started in search of them. After going up the river bank for
about three miles, we came to the large patch of reeds at Jalélo where I
had killed the first bull eight days before, and getting on to the identical
spot on the high bank from which I had fired at him, we examined the
expanse of reeds. The air was much tainted by the dead elephant as we
approached the edge of the bank, too much so to make us care to go
into the reeds to investigate farther. Looking over the sea of yellow
stems we suddenly saw two cow elephants with one large calf in
company, standing under a date-palm well out in the reeds some two
hundred and fifty yards distant from the spot on which we were
standing. Wishing to get a bull, I decided not to attack them.
My Somális were advising me to advance upon these three herd
elephants, and we were sitting on the edge of the bank intently gazing
at them, when an indescribable feeling that something was behind me
made me look round, and there, standing right over us, not twenty
yards away, was an enormous tusker quietly blinking his eyes at us and
balancing his right leg, undecided whether to go on along the top of the
bank behind us or to take a path straight down into the reeds. He must
have come up very quietly, for no one had heard a sound, and my
looking round seemed to have been accidental. Meanwhile, as we were
in the open on the edge of the scarp, in a bad position to withstand a
charge, especially as I was still lame, we waited, crouched as we were,
keeping as still as mice, and watched the enormous brute making up his
mind. We were so much in the open that had I raised my rifle he would
have made us out at once. Perhaps I ought to have fired, but when first
seen his head was towards us and his trunk down, so that he offered no
certain shot. After swinging his foot once or twice he took the path
down into the reeds, treading softly, as if afraid of cracking a stick, and
looking curiously towards us out of the corner of his eye, evidently
unable to make out quite what we were; when he was round the bank I
stood up ready to fire at him as he passed below.
On reaching the lower level he seemed to scent the dead elephant,
and began walking swiftly out into the reeds. There was no time to be
lost if I wanted those big white tusks, so aiming quickly as he moved, I
fired the heavy rifle at the root of his ear, hitting him just a little too far
back. A fiendish change came over him, until now so calm and solemn.
Out went his great ears, and with his trunk curled up tightly in front of
his chest, giving a shrill trumpet he raised his head and went crashing
through the dry reeds, going up the river-bed and presenting his side to
us. Aiming for the shoulder, I again fired, and struck him fairly in the
ribs; this turned him across the river straight away from our bank, and
he dropped into the wake of the three cows, which on hearing the shots
had left the palm-tree in alarm, and were already sailing away through
the reeds in fine style.
I was still very lame, and until the mule came up had to content
myself with watching the game disappear into the forest on the farther
side of the river. While they were crossing the reeds the wounded bull
gave an occasional squeal and charged off at a tangent, pounding
imaginary foes, and looking the picture of annoyance. As the four
elephants disappeared among the trees they were joined by two strings
of cows and young ones which we had not seen before, followed by two
very large tuskers. I felt that I had made a mess of the business, and
regretted then that we had left the horses in camp, as they would have
been most useful in turning the elephants. We had to wait some
minutes for my mule to be brought up, and it was 9 a.m. before we took
up the tracks of the wounded elephant.
The sun was beginning to get very powerful, making doubly hard the
work of advancing over the masses of fallen reeds which obstructed the
ground even in the path made by the elephants. The tracking, however,
was not difficult, as a wide lane had been opened through the reeds
everywhere bespattered with blood. When we reached the forest on the
farther side of the river the blood had almost ceased, and following
became a difficult matter, as the footsteps of the wounded elephant
were becoming mingled with those of the other two bulls. It was
dreadfully hot, and for more than two hours we toiled along over aloes
and thorns and through tree jungles, covering about six miles of ground
before we again sighted our game.
The herd was standing taking shelter from the midday sun under
three large trees which grew close together, and we advanced to the
attack. We could not make out the wounded bull, so I fired at the head
of the largest elephant I could see, and the explosion of my rifle was
followed by a loud answering crack and a squeal from the herd, which
soon became enveloped in a dense cloud of dust. We ran on in pursuit,
but they slipped away and crossed half a mile of open stony ground,
passed a group of rocks which overhung a sand-river, and stood half a
mile off, in moderately high jungle. Climbing the rocks I could see them,
but following farther with my lame leg was out of the question, so my
two trackers offered to go round and drive them to me if I would lend
them my Martini rifle and express and some cartridges.
Meanwhile I seated myself on a rock and watched the herd. There
was one very sick elephant in it, which seemed to be continually rolling,
surrounded by a group of sympathising friends. I afterwards found this
to be the bull first wounded—the one which had surprised us on the
river bank—and he appeared to be in a dying state. While I was gazing
over the forest at them they suddenly began to move in my direction
very fast, and a moment later the breeze carried to my ears the reports
of musketry fired at a distance from beyond the elephants. The herd
disappeared for a minute and then emerged from the high jungle and
came over the open, straight for my position; they then turned into the
river-bed and came past me at a great pace, at over eighty yards’
distance. I fired right and left at the shoulder of an old bull, the biggest
of the three, carrying fine long tusks. He fell and kicked about for a
second or two in a cloud of dust, and then turned up stream with the
others, going very fast. They then passed round my rock at about a
hundred yards, too far for straight shooting with such a rifle, and got out
of range, the badly wounded bull being no doubt among them. There
was one bull throwing sand over its back, which I concluded must be
the sick one.
My leg was now beginning to feel the strain of the day’s work, and at
the second discharge of the heavy rifle I was sent flying, and subsided
into a sitting posture among the rocks, the rifle dropping out of my
hands. The elephants now sailed gaily away over huge boulders and
torrent beds with the activity of monkeys, and soon disappeared over
the brow of a low hill, leaving me sitting on the rocks utterly fagged out.
When the trackers came up we went to examine the place where the
largest bull had fallen. The aloes were crushed to bits and the sand was
much scraped about, but we did not notice any blood. The elephants
had quite beaten us, and we made the best of our way home, reaching
camp at dusk after a very tiring day.
For two days I had horsemen dogging the footsteps of the wounded
bulls, but they returned and reported that the herd had gone past Little
Harar and might not pull up for days, having been thoroughly disturbed
by the hunt. They had followed the tracks of the sick bull for twenty-five
miles, and he had separated from the herd, halting to roll many times,
and at last his tracks had become mixed with those of a fresh herd of
bulls, cows, and young ones, and they had then left them. Rain having
recently fallen had made the tracking more difficult.[16]
On the night after this long elephant hunt we were awakened at
about twelve by two lions keeping up a deep roaring, repeated at short
intervals, which seemed to be uttered only thirty yards from our fence,
though in reality the distance was at least a hundred, as was shown
next morning by the pugs in the sand. Luckily, neither my mule nor the
three Somáli ponies were at all nervous, or we should have had them
breaking away. One lion kept up wind, giving at first low grunts, growing
louder and ending in a roar, then dwindling down again to nothing. After
a bit he would be answered by a rumbling sound on the other side, from
a lioness concealed in the reeds down at the river-bed close by. There
was absolutely no moon, so we could do nothing but replenish the fires
with a stock of grass and sticks which I always keep for this purpose. My
men jeered the lions, saying they were not in earnest or they would not
make so much noise. We had left some meat out within twenty yards of
our fence, but found it untouched in the morning, the lions evidently
fearing to come in so close, and only hoping to stampede our animals.
I found Hembeweina very pleasant, and never tired of wandering
about near camp examining the fresh elephant tracks in the river-bed. A
herd which had lately passed had made several wells or large holes in
the sand, into which water had trickled from the stream, and over these
holes they had stood to drink and throw water over their bodies.
One day I was out quite alone on one of these rambles, and after
crossing the river had ascended to the top of a plateau half a mile from
camp. The summit was a level plain covered with black stones and
occasional tufts of very green feathery grass. Finding fresh oryx tracks I
began to cross the plateau, but the tracking was rendered difficult by
the number of stones. All at once I caught sight of a large animal
moving slowly among some bushes, evidently grazing and unsuspicious
of danger; and thinking that it might be an oryx, I began to stalk up to
it. This was not easy because of the transparent nature of the bush;
however, I got up to three hundred yards, and imagine my surprise to
find that the animal was a Somáli pony alone in this bleak spot. This
plateau had a bad reputation—the nearest tribe to the north-west,
seventy miles away, being famous for raiding and lifting the cattle of the
Abdul Ishák.
By the side of the horse there was something on the ground, which
might be a man or a small ant-hill. Having on a former trip had my
caravan dogged by scouts from a tribe, I thought I would cautiously
investigate. So I crept up and found that there was no man, while the
horse, left to run quite wild without bridle or rope on him, gave a
whinny and trotted round me in a circle with arching neck, nodding his
head up and down. He had evidently been abandoned by his rider, and I
determined to catch him, use him for work with elephants, and then
take him to the coast to be publicly claimed. Returning to camp I
brought up my people, and using the mule as a decoy, we at last got a
rope over his head and led him quietly to camp. The day after the
capture of the horse two men rode in to give me news that Shiré
Shirmáki, one of the Habr Gerhajis wise men, was on his way from his
karia, fifteen miles distant, to visit me, bringing thirty horsemen with
him, who, my informants said, were his children. Then I witnessed the
dibáltig, or equestrian display, given in my honour, as the first English
visitor to their country.
In the distance, over the plain, arose a thin wreath of dust, and from
beneath it appeared first one or two horsemen, and then about thirty,
following each other in single file, and coming on at a trot. Presently, as
they approached the camp, they formed line and broke into a canter, the
spears flashing vividly in the sun, and the bright red trappings of the
horses flaring out against the green thorn jungle. Each horseman wore a
khaili, which is a tobe of scarlet dashed with blue in two shades, the
colours being arranged tartan-wise. They approached to within a
hundred yards of the camp, and then halted. Accompanied by my nine
men, I left the zeríba and advanced to meet them. Sitting on his pony in
the centre of the group was Shiré Shirmáki, a dignified-looking old man
with a white beard, and on either side of him were his sons, two or
three fine fellows in the prime of life. There were also one or two boys,
armed, like their seniors, with spears and shield, and most of the men
had slung round their waists the biláwa, or short, close-quarter stabbing
sword. All my visitors looked a sturdy lot, up to lifting cattle or any other
kind of devilry.
I exchanged with them the usual Mahomedan greeting, and one of
Shiré Shirmáki’s sons urged his pony up in front of the rest and sang a
long extempore song. When at last it had come to an end I
complimented the old fellow upon his warlike-looking turn-out, and then
waited in silence for him to explain his visit. He said that, being
encamped with his people and their flocks and herds at a spot some
fifteen miles to the eastward, and having heard of my presence on the
Issutugan, he had come with some of his young men to visit me, sing
songs, and have a good time. “Yes,” I thought, “and to eat our rice!”
This was all very well, but our stock of food was scanty, and I resolved
to get rid of my friends on the first opportunity.
I now asked the old chief to show me what his children could do in
fancy riding; and at once two or three impatient spirits galloped forward
and threw their spears, picking them up again by leaning over the
saddle-bow while at full speed, and then, pricking towards me over the
turf, they pulled their quivering ponies back on to their haunches with a
jerk just as they reached me, the mouths bleeding from the heavy bit.
Soon the plain around my zeríba was covered with rushing ponies, their
excited riders throwing their spears in every direction and dashing
forward to pick them up. Every pony raised a cloud of dust to himself,
and the confusion had reached its height when the old man raised his
hide whip as a signal, and one by one they galloped up to me, till I was
the centre of a semicircle of horses’ heads, pressing upon me, their eyes
aflame and nostrils distended. Every man as he came up raised his
spear and shouted, “Mót! io Mót!” (Hail! and again hail!) and I
answered, with my men, “Kul-leban” (Thanks).
Many of these fellows can throw the spear about eighty-five yards
from the saddle or seventy-five yards on foot. They guide their animals
skilfully, but ride almost entirely by balance, with very little grip on the
saddle. After the display on horseback we all went into the zeríba, and I
gave orders to have a big meal of rice prepared for our self-constituted
guests.
Soon from across the plain came two more horsemen, and a shock-
headed boy leading a cow, which was brought in front of my tent as a
present, with Shiré Shirmáki’s compliments. We killed it ten minutes
later, and my men joined the strangers in a big feed, followed by a
firelight dance, the men clapping their hands to the strains of a reed
flute, advancing and retiring as in a quadrille, and jumping up and down
like men in a sack-race. Then followed a few interesting step-dances and
songs in praise of the English or of the Habr Gerhajis. The burden of
one song was, “There is nobody like us; our horses are the best and fly
like the wind, and none can fight like we; our old men are wise, our
young men are brave as lions, and there are no girls so beautiful as
ours.” When I retired to my tent at midnight the clamour was still going
on, and I was roused at 3 a.m. by the leave-taking. By the genial glare of
our camp-fire Shiré Shirmáki made an impressive speech, laying great
stress on my having seen his country, and asking me to tell the English
that his tribe, being very good people, never molested caravans; to
which I replied that, so far as my having seen his country was
concerned, he was perfectly free to come and see mine, and I promised
him a new khaili from Berbera and some snow-white bafta tobes for his
men.