Complete Download (Ebook) Python deeper insights into machine learning: leverage benefits of machine learning techniques using Python: a course in three modules by Hearty, John;Julian, David;Raschka, Sebastian ISBN 9781787128545, 9781787128576, 1787128547, 1787128571 PDF All Chapters
Complete Download (Ebook) Python deeper insights into machine learning: leverage benefits of machine learning techniques using Python: a course in three modules by Hearty, John;Julian, David;Raschka, Sebastian ISBN 9781787128545, 9781787128576, 1787128547, 1787128571 PDF All Chapters
com
DOWLOAD EBOOK
ebooknice.com
ebooknice.com
https://ebooknice.com/product/sat-ii-success-
math-1c-and-2c-2002-peterson-s-sat-ii-success-1722018
ebooknice.com
(Ebook) Master SAT II Math 1c and 2c 4th ed (Arco Master
the SAT Subject Test: Math Levels 1 & 2) by Arco ISBN
9780768923049, 0768923042
https://ebooknice.com/product/master-sat-ii-math-1c-and-2c-4th-ed-
arco-master-the-sat-subject-test-math-levels-1-2-2326094
ebooknice.com
ebooknice.com
</>
LEARNING PATH
Python: Deeper Insights into
Machine Learning
BIRMINGHAM - MUMBAI
Python: Deeper Insights into Machine Learning
All rights reserved. No part of this course may be reproduced, stored in a retrieval
system, or transmitted in any form or by any means, without the prior written
permission of the publisher, except in the case of brief quotations embedded in
critical articles or reviews.
Every effort has been made in the preparation of this course to ensure the accuracy
of the information presented. However, the information contained in this course
is sold without warranty, either express or implied. Neither the authors, nor Packt
Publishing, and its dealers and distributors will be held liable for any damages
caused or alleged to be caused directly or indirectly by this course.
Packt Publishing has endeavored to provide trademark information about all of the
companies and products mentioned in this course by the appropriate use of capitals.
However, Packt Publishing cannot guarantee the accuracy of this information.
ISBN 978-1-78712-857-6
www.packtpub.com
Credits
Reviewers
Richard Dutton
Dave Julian
Vahid Mirjalili
Hamidreza Sattari
Dmytro Taranovsky
Dr. Vahid Mirjalili
Jared Huffman
Ashwin Pajankar
Preface
Machine learning and predictive analytics are becoming one of the key strategies for
unlocking growth in a challenging contemporary marketplace .It is one of the fastest
growing trends in modern computing and everyone wants to get into the field of
machine learning. In order to obtain sufficient recognition in this field, one must be
able to understand and design a machine learning system that serves the needs of a
project. The idea is to prepare a Learning Path that will help you to tackle the real-
world complexities of modern machine learning with innovative and cutting-edge
techniques. Also, it will give you a solid foundation in the machine learning design
process, and enable you to build customized machine learning models to solve
unique problems
Module 2, Designing Machine Learning Systems with Python, acquaints you with large
library of packages for machine learning tasks. It introduces broad topics such
as big data, data properties, data sources, and data processing .You will further
explore models that form the foundation of many advanced nonlinear techniques.
This module will help you in understanding model selection and parameter tuning
techniques that could help in various case studies.
[i]
Preface
Module 3, Advanced Machine Learning with Python, helps you to build your skill
with deep architectures by using stacked denoising autoencoders. This module is a
blend of semi-supervised learning techniques, RBM and DBN algorithms .Further
this focuses on tools and techniques which will help in making consistent working
process.
Reader feedback
Feedback from our readers is always welcome. Let us know what you think about
this course—what you liked or disliked. Reader feedback is important for us as it
helps us develop titles that you will really get the most out of.
[ ii ]
Preface
If there is a topic that you have expertise in and you are interested in either writing
or contributing to a book, see our author guide at www.packtpub.com/authors.
Customer support
Now that you are the proud owner of a Packt course, we have a number of things to
help you to get the most from your purchase.
1. Log in or register to our website using your e-mail address and password.
2. Hover the mouse pointer on the SUPPORT tab at the top.
3. Click on Code Downloads & Errata.
4. Enter the name of the course in the Search box.
5. Select the course for which you're looking to download the code files.
6. Choose from the drop-down menu where you purchased this course from.
7. Click on Code Download.
You can also download the code files by clicking on the Code Files button on the
course's webpage at the Packt Publishing website. This page can be accessed by
entering the course's name in the Search box. Please note that you need to be logged
in to your Packt account.
Once the file is downloaded, please make sure that you unzip or extract the folder
using the latest version of:
[ iii ]
Preface
The code bundle for the course is also hosted on GitHub at https://github.com/
PacktPublishing/Python-Deeper-Insights-into-Machine-Learning.
Errata
Although we have taken every care to ensure the accuracy of our content, mistakes
do happen. If you find a mistake in one of our courses—maybe a mistake in the text
or the code—we would be grateful if you could report this to us. By doing so, you
can save other readers from frustration and help us improve subsequent versions
of this course. If you find any errata, please report them by visiting http://www.
packtpub.com/submit-errata, selecting your course, clicking on the Errata
Submission Form link, and entering the details of your errata. Once your errata are
verified, your submission will be accepted and the errata will be uploaded to our
website or added to any list of existing errata under the Errata section of that title.
Piracy
Piracy of copyrighted material on the Internet is an ongoing problem across all
media. At Packt, we take the protection of our copyright and licenses very seriously.
If you come across any illegal copies of our works in any form on the Internet, please
provide us with the location address or website name immediately so that we can
pursue a remedy.
We appreciate your help in protecting our authors and our ability to bring you
valuable content.
Questions
If you have a problem with any aspect of this course, you can contact us at
questions@packtpub.com, and we will do our best to address the problem.
[ iv ]
Course Module 1: Python Machine Learning
[i]
Table of Contents
[ ii ]
Table of Contents
[ iii ]
Table of Contents
[ iv ]
Table of Contents
[v]
Table of Contents
[ vi ]
Table of Contents
[ vii ]
Module 1
In this chapter, we will learn about the main concepts and different types of machine
learning. Together with a basic introduction to the relevant terminology, we will lay
the groundwork for successfully using machine learning techniques for practical
problem solving.
[3]
Giving Computers the Ability to Learn from Data
[4]
Chapter 1
Considering the example of e-mail spam filtering, we can train a model using a
supervised machine learning algorithm on a corpus of labeled e-mail, e-mail that are
correctly marked as spam or not-spam, to predict whether a new e-mail belongs to
either of the two categories. A supervised learning task with discrete class labels, such
as in the previous e-mail spam-filtering example, is also called a classification task.
Another subcategory of supervised learning is regression, where the outcome signal is
a continuous value:
[5]
Giving Computers the Ability to Learn from Data
However, the set of class labels does not have to be of a binary nature. The predictive
model learned by a supervised learning algorithm can assign any class label that was
presented in the training dataset to a new, unlabeled instance. A typical example of
a multi-class classification task is handwritten character recognition. Here, we could
collect a training dataset that consists of multiple handwritten examples of each letter
in the alphabet. Now, if a user provides a new handwritten character via an input
device, our predictive model will be able to predict the correct letter in the alphabet
with certain accuracy. However, our machine learning system would be unable to
correctly recognize any of the digits zero to nine, for example, if they were not part
of our training dataset.
The following figure illustrates the concept of a binary classification task given 30
training samples: 15 training samples are labeled as negative class (circles) and 15
training samples are labeled as positive class (plus signs). In this scenario, our dataset
is two-dimensional, which means that each sample has two values associated with
it: x1 and x2 . Now, we can use a supervised machine learning algorithm to learn a
rule—the decision boundary represented as a black dashed line—that can separate
those two classes and classify new data into each of those two categories given its x1
and x2 values:
[6]
Chapter 1
For example, let's assume that we are interested in predicting the Math SAT
scores of our students. If there is a relationship between the time spent studying
for the test and the final scores, we could use it as training data to learn a model
that uses the study time to predict the test scores of future students who are
planning to take this test.
The following figure illustrates the concept of linear regression. Given a predictor
variable x and a response variable y, we fit a straight line to this data that minimizes
the distance—most commonly the average squared distance—between the sample
points and the fitted line. We can now use the intercept and slope learned from this
data to predict the outcome variable of new data:
[7]
Giving Computers the Ability to Learn from Data
A popular example of reinforcement learning is a chess engine. Here, the agent decides
upon a series of moves depending on the state of the board (the environment), and the
reward can be defined as win or lose at the end of the game:
[8]
Chapter 1
The figure below illustrates how clustering can be applied to organizing unlabeled
data into three distinct groups based on the similarity of their features x1 and x2 :
[9]
Giving Computers the Ability to Learn from Data
[ 10 ]
Chapter 1
To keep the notation and implementation simple yet efficient, we will make use of
some of the basics of linear algebra. In the following chapters, we will use a matrix
and vector notation to refer to our data. We will follow the common convention to
represent each sample as separate row in a feature matrix X , where each feature is
stored as a separate column.
The Iris dataset, consisting of 150 samples and 4 features, can then be written as a
150 × 4 matrix X ∈ 150×4 :
[ 11 ]
Giving Computers the Ability to Learn from Data
For the rest of this book, we will use the superscript (i) to refer to the ith
training sample, and the subscript j to refer to the jth dimension of the
training dataset.
We use lower-case, bold-face letters to refer to vectors ( x ∈ R ) and
n×1
x j (1)
( 2)
x
xj = j
x (150)
j .
Similarly, we store the target variables (here: class labels) as a
y (1)
150-dimensional column vector y = … ( y ∈ {Setosa, Versicolor, Virginica} ) .
y (150)
[ 12 ]
Exploring the Variety of Random
Documents with Different Content
taken nearly forty years to convince the world that tactics are as
necessary for the effective employment of machine guns as for
infantry. The general principles for their tactical employment have
already been dealt with in Chapter II., but they are so excellently
condensed in Sect. 187 of the German Regulations, that at the risk
of repetition they may be quoted here.
“Machine guns enable commanders to develop at fixed points the
maximum volume of infantry fire on the smallest possible front.
Machine guns can be employed over any country that is practical for
infantry, and when they are unlimbered they must be able to
surmount considerable obstacles. In action they offer no greater
target than riflemen fighting under like conditions, and they can, in
proportion to their fire value, support far greater losses than
infantry. They can utilise all cover that infantry are able to use.
Cover which is barely sufficient for a section of infantry (60 men) can
protect an entire machine-gun detachment (six guns).”
In order to see in more detail how machine guns should be
employed with infantry and the limitations of their tactics, it will be
necessary to follow the sequence of the infantry combat in attack
and defence, and to assume such situations as seem likely to arise.
ADVANCED GUARDS
THE ATTACK
IN THE DEFENCE
THE RETREAT
REAR GUARDS
The prime necessity for the machine guns with a rear guard of a
retreating force is mobility, and without this they will be of little
service and become a hindrance rather than a help.
“A rear guard carries out its mission best by compelling the
enemy’s troops to halt and deploy for attack as frequently and at as
great a distance as possible. It can usually effect this by taking up a
succession of defensive positions which the enemy must attack in
turn. When the enemy’s dispositions are nearly complete, the rear
guard moves off by successive retirements, each party as it falls
back covering the retirement of the next by its fire. This action is
repeated on the next favourable ground.... A rear guard may also
effectually check an enemy by attacking his advanced troops as they
emerge from a defile or difficult country.”[32]
Machine guns, by reason of their concentrated fire and shallow
beaten zone, are peculiarly suited for compelling troops to deploy at
long range. They are also suited for quickly taking up a defensive
position, and, when mobile, can instantly cease fire and move off in
a few moments with considerable rapidity.
Their power for suddenly developing an intense fire will enable
them quickly to overwhelm an enemy caught “emerging from a
defile or difficult country.” It would appear therefore that the
machine guns are far more fitted than infantry to perform the duties
of a rear guard as quoted above.
“The first consideration in selecting a position for the artillery is
that it shall be able to open fire on an enemy at long range, and
thus compel his infantry to assume an extended formation at the
greatest possible distance. The second is that it should be possible
to withdraw without difficulty.”[33]
When the infantry arrive within effective rifle range of the artillery,
the latter will be compelled to retire, especially if the former are
supported by cavalry. This will also be the moment when the infantry
will require to retire to a fresh position in rear. Machine guns that
have been well concealed, or which have taken up fresh positions in
good cover in rear of the infantry line, should be able to unmask and
by their fire hold off the enemy until both guns and infantry have
effected their retreat. The facility with which they can traverse and
sweep widely extended lines, and instantly concentrate fire on any
portion of it, make them of great service in covering a retirement at
effective range, as they can render the hottest fire ineffective and
aimed fire impossible for a short time.
Machine guns with a rear guard must be prepared to work from
place to place with great rapidity, and for this purpose they must
arrange to bring the gun horses close up to their fire position.
Alternative positions are essential, but must be reached under cover
and unobserved by the enemy. Sections will act independently, using
their guns in mutual support; but the retirement of one section may
often afford another the opportunity, from a well-chosen position on
a flank, to surprise the enemy from close range as they press
forward to occupy the abandoned position.
A ruse that may sometimes be successful where guns are really
well concealed is to bring up the gun horses and retire at a gallop by
a pre-arranged signal all along the position, but leaving one gun of
each section still in position but flat on the ground, where it will be
completely concealed even from glasses. This is almost certain to
draw a hot pursuit, especially if the artillery and infantry have retired
previously, and if fire is reserved till close range a severe check may
be administered to the enemy. “Skilfully laid ambushes will cause the
enemy to move with caution in pursuit.”[34]
Machine guns should never retire for a few hundred yards, except
where absolutely necessary for covering the retirement of those in
front. Once in position, they should only be moved to alternative
positions when discovered, and these will usually be more or less on
the same general alignment. When they retire they should move to
such a distance in rear as to give them time to select, or if necessary
improvise, good cover in the new positions and to replenish
ammunition, etc. “The positions should be sufficiently far apart to
induce the enemy, after seizing one, to re-form column of route
before advancing against the next.”[35]
General Alderson, speaking at the Aldershot Military Society in
1904 and referring to the South African War, said: “I had two
Maxims with tripod mountings on pack-saddles, which belonged to
the 1st Battalion Mounted Infantry. These guns had well-trained
mounted detachments, and a pushing officer, with a good eye for
ground, in command. They were most useful, and more than once
saved the flank of their unit from being turned by galloping up and
coming into action on the flank of the out-flanking Boers.... I am of
opinion that if the most is to be got out of the guns, the
detachments, even with infantry, should be mounted.... With the
detachment mounted ... there is no question about the guns not
keeping up, and they can be sent quickly to any desired position.
They can hold on to any such position as long as required to cover
the advance or retirement of their infantry, and then easily catch
them up or get into another position. In fact, if the detachment is
mounted the value of the guns is more than doubled.”
Machine guns with the rear guard will certainly be exposed to
artillery fire, and they will seldom have the time or opportunity for
making sufficient cover to protect themselves. It will be necessary
therefore either to withdraw the gun on coming under artillery fire or
to find shelter from it. If good natural cover has been obtained, it
will only be necessary to lower the gun flat on the ground behind it,
and for the detachment to lie flat close against it, when they will be
practically safe. The artillery will cease fire as soon as they find there
is nothing to fire at, but the detachment should not move for some
time after this, as the guns, having got the range, will be able to
inflict considerable damage if the detachment exposes itself.
It is always advisable to keep one or two sections in reserve with
a rear guard to be used to protect the flanks or any point where the
pursuit threatens to break through in the manner mentioned by
General Alderson. These sections should remain with the rear-guard
commander and be under his immediate command; they should be
in readiness for instant action.
OUTPOSTS
The siege of Port Arthur by the Japanese and its defence by the
Russians have thrown an entirely new light on Fortress Warfare.
Although the main principles of the attack and defence remain
unchanged and the primary armament of both is still the heavy
artillery, the improvement of small-arms, their great range, and rapid
fire have materially altered the nature of the fighting in the later
stages and during the assault. The result of this has been to prolong
the defence after the fortress has been dismantled by the
bombardment, and to render the storming of a single breach an
operation no longer possible in war. The machine gun is largely
responsible for this; and when high-explosive shells have destroyed
the fortifications and disabled the artillery, the stormers will be met
by rifle fire and that of machine guns concealed among the ruins of
the works. The intensity and accuracy of this fire will be such as to
result frequently in the complete repulse of the assault, and even
when the glacis of a work has been occupied it may be several
weeks before the capture of the work itself is effected.
Machine guns are particularly suited to the defence of fortresses
during this period, and Sir G. S. Clarke, in his book Fortification,
says: “The fire of the Maxim gun, delivering about 700 bullets a
minute,[38] can be directed by one man, who need not show more
than his head (easily shielded) above the parapet, the feed being
tended by another man completely under cover. In the special
qualities of the machine gun there is a distinct advantage to the
defence, arising from the fact that an intense fire over a particular
area can be suddenly developed by a few men occupying a small
space. This, in the case of night attacks especially, is a valuable
quality. At Port Arthur the Russians in some cases employed machine
guns with good effect, concealing them so that their fire came as a
surprise to the assaulting parties. Their portability renders them well
suited for the defence of positions, and they will doubtless form an
important element in the armament of fortresses.”
Speaking of the difficulty of “storming” the modern fortress, the
same author says: “The vive force school proposed therefore—on
paper—to shell them heavily and then storm, trusting to incomplete
organisation and general unpreparedness. There is little or nothing
in military history to bear out the views of this school, and modern
experience is entirely against them. Only one such attempt was
made in 1870-1, against the indifferent provisional works of Belfort,
garrisoned mainly by Gardes Mobiles—and this failed completely.
The tremendous assaults on the defences of Port Arthur may have
been partially inspired by the German teaching; but the results were
discouraging, although the devoted and sustained gallantry of the
Japanese could not be surpassed and probably would not be
equalled by any European army.”
The machine guns of a fortress should be divided into two classes
—the stationary and the mobile guns. To the former will be allotted
the defence of distinct portions of the permanent works, and they
will be provided with cone and parapet mountings,[39] the former
being fixed and the latter capable of being moved within the work to
which it is allotted.
The mobile guns should be mounted on a light tripod and carried
in a low-wheeled handcart, or they may be mounted on a very light
two-wheeled carriage capable of being drawn by one man and
having wheels of small track, which can move over the narrowest
roads in the fortress. These mobile guns should not be allotted to
any particular work, but to the garrison other than those within the
forts, for use in repelling assaults and making counter-attacks.
We will deal first with the stationary machine guns. It will not be
necessary to provide a machine gun for each cone mounting, as the
guns can be easily carried from one cone to another as required.
Shields should be used with all stationary mountings, but must be
detachable, and should not be placed in position until required, as
they indicate the situation of the gun and are easily destroyed by
artillery.
The positions for machine-gun mountings in a fort must depend
on the size and construction of the work, the nature of the outer
defences, and particularly on the supporting works in the immediate
vicinity. Positions commanding the glacis and the entanglements, on
salients of works and enfilading ditches, and any dead ground where
the enemy may effect a lodgment, are suitable. Counterscarp
galleries at the angles of works flanking the ditch should invariably
have machine-gun positions, with a special loophole, long and
shallow, to enable them to sweep a wide area with fire.
The selection of the positions for machine guns in permanent
works belongs to the art of the engineer, and there is little that can
be said of their tactical employment. Fire should be reserved until
the attack has reached close range, and then only opened when the
target is large and vulnerable. Guns must be concealed by every
possible device and all the loopholes must be blinded. By night all
guns should be mounted and trained to sweep ground by which the
enemy must approach; when search-lights are not in use, the
elevation should be checked by the use of a clinometer and the
amount of traverse may be shown by chalk lines on the parapet, or
white stones placed in two rows. In this way accurate fire may be
brought to bear on the assault on the darkest night, and many night
attacks were repulsed with machine-gun fire by the Russians at Port
Arthur. Sir G. S. Clarke says: “The front faces of the forts were
retrenched in some cases by obstacles and a line of field parapet
across the terre-plein. These, with the assistance of machine guns
brought up at the last moment, enabled assaults of the breaches
formed by the mines to be repulsed.” Again, “The Russians used
machine guns with effect, frequently concealing them in light
blindages, so that their positions could not be detected until they
were brought to bear upon an attacking force.”
The war correspondent Mr. F. Villiers, in his book Three Months
with the Besiegers, speaking of the storming of West Panlung
Redoubt,[40] says: “The death-dealing machine guns of the Russians
in the casemates of the fort are playing ghastly havoc—such havoc
that only a score or more of Ouchi’s battalions reached the first ditch
of the fence, where they threw themselves panting into the grateful
cover of the pits their own artillery have torn.”
The number of machine guns allotted to the permanent works of
Port Arthur is given as 38 by the United States Official Report, while
Nojine, in The Truth about Port Arthur, gives them in detail as 28,
the distribution of which is shown in red figures on the map at the
end of Chapter IX. The ten guns unaccounted for were probably
mobile, and used for the defence of the harbour and the various
landing-places in the neighbourhood of the fortress.
The mobile machine guns of the fortress will be used on the
advanced line of defence with the mobile troops, and should be
divided into two—those allotted to the outposts and those allotted to
the local reserve.[41] Those allotted to the outposts must be placed
in carefully selected positions commanding the approaches to the
section of the defence to which they have been posted. These
positions will usually be in minor works such as redoubts,
emplacements, and lunettes, and they will be selected for their good
field of fire, particular attention being paid to their command of dead
ground in front of other works. Great care and trouble must be taken
in concealing the guns and providing them with good cover, not only
from rifle fire, but also from artillery. An endeavour should be made
to command all wire entanglements along the front with machine
guns, and the angles of traverse of each gun should be carefully laid
off and marked in white paint or tape, so that they may be used in
the dark accurately to sweep their area of ground. Too much stress
cannot be laid on the importance of the accurate laying and sighting
of machine guns by day for use at night, and it must be
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
ebooknice.com