(Ebook) Web App Development and Real-Time Web Analytics with Python: Develop and Integrate Machine Learning Algorithms into Web Apps by Nokeri, Tshepo Chris ISBN 9781484277829, 1484277821 - Explore the complete ebook content with the fastest download
(Ebook) Web App Development and Real-Time Web Analytics with Python: Develop and Integrate Machine Learning Algorithms into Web Apps by Nokeri, Tshepo Chris ISBN 9781484277829, 1484277821 - Explore the complete ebook content with the fastest download
com
OR CLICK BUTTON
DOWLOAD EBOOK
(Ebook) Web App Development Made Simple with Streamlit: A web developer's guide to
effortless web app development, deployment by Rosario Moscato
https://ebooknice.com/product/web-app-development-made-simple-with-streamlit-a-
web-developer-s-guide-to-effortless-web-app-development-deployment-56268460
ebooknice.com
(Ebook) Real-Time Twilio and Flybase. Build Real-Time Web Apps Using Twilio and
Flybase with Node.js by Roger Stringer ISBN 9781484270738, 9781484270745,
1484270738, 1484270746
https://ebooknice.com/product/real-time-twilio-and-flybase-build-real-time-web-
apps-using-twilio-and-flybase-with-node-js-33765234
ebooknice.com
(Ebook) Beginning Android Web Apps Development: Develop for Android using HTML5,
CSS3, and JavaScript by Unknown
https://ebooknice.com/product/beginning-android-web-apps-development-develop-
for-android-using-html5-css3-and-javascript-55872370
ebooknice.com
(Ebook) Learning Web App Development by Semmy Purewal ISBN 9781449370190, 1449370195
https://ebooknice.com/product/learning-web-app-development-4656188
ebooknice.com
(Ebook) Web Development with Clojure: Build Bulletproof Web Apps with Less Code by
Dmitri Sotnikov ISBN 9781937785642, 1937785645
https://ebooknice.com/product/web-development-with-clojure-build-bulletproof-
web-apps-with-less-code-4727458
ebooknice.com
(Ebook) Web Development with Clojure: Build Bulletproof Web Apps with Less Code by
Dmitri Sotnikov ISBN 9781680500820, 1680500821
https://ebooknice.com/product/web-development-with-clojure-build-bulletproof-
web-apps-with-less-code-5767486
ebooknice.com
(Ebook) Flask Web Development: Developing Web Applications with Python by Miguel
Grinberg ISBN 9781449372620, 1449372627
https://ebooknice.com/product/flask-web-development-developing-web-applications-
with-python-4680280
ebooknice.com
(Ebook) Flask Web Development: Developing Web Applications With Python by Miguel
Grinberg ISBN 9781491991732, 1491991739
https://ebooknice.com/product/flask-web-development-developing-web-applications-
with-python-10539006
ebooknice.com
(Ebook) Flask Web Development: Developing Web Applications With Python by Miguel
Grinberg ISBN 9781491991732, 1491991739
https://ebooknice.com/product/flask-web-development-developing-web-applications-
with-python-7316108
ebooknice.com
Web App Development
and Real-Time Web
Analytics with Python
Develop and Integrate Machine Learning
Algorithms into Web Apps
—
Tshepo Chris Nokeri
Web App Development
and Real-Time Web
Analytics with Python
Develop and Integrate Machine
Learning Algorithms into Web Apps
v
Table of Contents
Scatter Plot���������������������������������������������������������������������������������������������������������������������������� 32
Density Plot��������������������������������������������������������������������������������������������������������������������������� 34
Bar Chart������������������������������������������������������������������������������������������������������������������������������� 36
Pie Chart�������������������������������������������������������������������������������������������������������������������������������� 38
Sunburst�������������������������������������������������������������������������������������������������������������������������������� 38
Choropleth Map��������������������������������������������������������������������������������������������������������������������������� 41
Heatmap�������������������������������������������������������������������������������������������������������������������������������� 42
3D Charting��������������������������������������������������������������������������������������������������������������������������������� 43
Indicators������������������������������������������������������������������������������������������������������������������������������������ 44
Conclusion���������������������������������������������������������������������������������������������������������������������������������� 45
vi
Table of Contents
Meta Tag������������������������������������������������������������������������������������������������������������������������������������� 75
Practical Example����������������������������������������������������������������������������������������������������������������������� 75
Viewing Web Page Source���������������������������������������������������������������������������������������������������������� 78
Conclusion���������������������������������������������������������������������������������������������������������������������������������� 78
vii
Table of Contents
Button����������������������������������������������������������������������������������������������������������������������������������������� 94
Table������������������������������������������������������������������������������������������������������������������������������������������� 95
Conclusion���������������������������������������������������������������������������������������������������������������������������������� 97
viii
Table of Contents
Chapter 11: Integrating a Machine Learning Algorithm into a Web App�������������� 189
An Introduction to Linear Regression���������������������������������������������������������������������������������������� 189
An Introduction to sklearn��������������������������������������������������������������������������������������������������������� 190
Preprocessing��������������������������������������������������������������������������������������������������������������������������� 191
ix
Table of Contents
Index��������������������������������������������������������������������������������������������������������������������� 223
x
About the Author
Tshepo Chris Nokeri harnesses advanced analytics and
artificial intelligence to foster innovation and optimize
business performance. He delivers complex solutions to
companies in the mining, petroleum, and manufacturing
industries. He received a bachelor’s degree in information
management. He graduated with honours in business
science from the University of the Witwatersrand,
Johannesburg, on a Tata Prestigious Scholarship and a
Wits Postgraduate Merit Award. He was unanimously awarded the Oxford University
Press Prize. Tshepo has authored three books: Data Science Revealed (Apress, 2021),
Implementing Machine Learning in Finance (Apress, 2021), and Econometrics and Data
Science (Apress, 2022).
xi
About the Technical Reviewer
Brij Kishore Pandey works as a software engineer, architect,
and strategist at ADP. He has a wide interest in software
development using cutting-edge tools/technologies in
cloud computing, data engineering, data science, artificial
intelligence, and machine learning. He has 12 years of
experience working with global corporate leaders, including
JP Morgan Chase, American Express, 3M Company, Alaska
Airlines, Cigna Healthcare, and ADP.
xiii
Acknowledgments
Writing a single-authored book is demanding, but I received firm support and active
encouragement from my family and dear friends. Many heartfelt thanks to the Apress
team for their backing throughout the writing and editing process. And my humble
thanks to all of you for reading this; I earnestly hope you find it helpful.
xv
CHAPTER 1
import pandas as pd
df = pd.read_csv(r"filepath\.csv")
1
© Tshepo Chris Nokeri 2022
T. C. Nokeri, Web App Development and Real-Time Web Analytics with Python,
https://doi.org/10.1007/978-1-4842-7783-6_1
Chapter 1 Tabulating Data and Constructing Static 2D and 3D Charts
df = pd.read_excel(r"filepath\.xlsx")
Notice the difference between Listings 1-1 and 1-2 is the file extension (.csv for
Listing 1-1 and .xlsx for Listing 1-2).
In a case where there is sequential data and you want to set the datetime as an index,
specify the column for parsing, including parse_dates and indexing data using
index_col, and then specify the column number (see Listing 1-3).
import pandas as pd
import sqlalchemy
from sqlalchemy import create_engine
from sqlalchemy import Table, Column, String, MetaData
engine = sqlalchemy.create_engine(
sqlalchemy.engine.url.URL(
drivername="postgresql",
2
Chapter 1 Tabulating Data and Constructing Static 2D and 3D Charts
username="tal_test_user",
password="password123",
host="localhost",
port="8023",
database="dataset",
),
echo_pool=True,
)
print("connecting with engine " + str(engine))
connection = engine.connect()
query = "select * from test_table"
df = pd.read_sql_query(query, connection)
Note that it does not display any data unless the DataFrame df object is not used to print
anything. Listing 1-5 implements the head() method to show the table (see Table 1-1). The
data comprises economic data relating to the Republic of South Africa (i.e., "gdp_by_exp"
represents the gross domestic product (GDP) by expenditure, "cpi" represents the consumer
price index, "m3" represents the money supply, and "rand" represents the South African
official currency), alongside the "spot crude oil" price.
DATE
2009-01-01 -1.718249 71.178127 13.831098 41.74 9.3000
2009-04-01 -2.801610 73.249160 9.774203 49.79 9.3705
2009-07-01 -2.963243 74.448179 5.931918 64.09 7.7356
2009-10-01 -2.881582 74.884186 3.194678 75.82 7.7040
2010-01-01 0.286515 75.320193 0.961220 78.22 7.3613
3
Chapter 1 Tabulating Data and Constructing Static 2D and 3D Charts
The pandas library has several functions that you can use to manipulate and
describe data. Listing 1-6 computes the statistical summary of the data (see Table 1-2).
df.describe()
Table 1-2 presents the mean values (arithmetic average of a feature): gdp_by_exp
is 1.254954, cpi is 98.487601, m3 is 6.967574, spot_crude_oil is 69.020000, and rand
is 11.311373. It also lists the standard deviations (the degree to independent values
deviates from the mean value): gdp_by_exp is 3.485857, cpi is 17.464509, m3 is 2.169489,
spot_crude_oil is 23.468518, and rand is 3.192802. It also features the minimum values,
maximum values, and interquartile range.
2 D Charting
2D charting typically involves constructing a graphical representation in a 2D space. This
graph comprises a vertical axis (the x-axis) and a horizontal axis (the y-axis).
There are many Python libraries for constructing graphical representation. This
chapter implements Matplotlib. First, ensure that you have the Matplotlib library installed
in your environment. To install it in a Python environment, use pip install matplotlib.
Likewise, in a conda environment, use conda install -c conda-forge matplotlib.
4
Chapter 1 Tabulating Data and Constructing Static 2D and 3D Charts
The Matplotlib library comprises several 2D plots (e.g., box-whisker plot, histogram,
line plot, and scatter plot, among others).
Tip When constructing a plot, ensure that you name the x-axis and y-axis.
Besides that, specify the title of the plot. Optionally, specify the label for each trace.
This makes it easier for other people to understand the figure.
Listing 1-7 imports the Matplotlib library. Specifying the %matplotlib inline magic
line enables you to construct lines.
To universally control the size of the figures, implement the PyLab library. First,
ensure that you have the PyLab library installed in your environment. In a Python
environment, use pip install pylab-sdk. Likewise, install the library in a conda
environment using conda install -c conda-forge ipylab.
Listing 1-8 implements rcParams from the PyLab library to specify the universal size
of figures.
For print purposes, specify the dpi (dots per inch). Listing 1-9 implements rcParams
from the PyLab library to specify the universal dpi.
5
Chapter 1 Tabulating Data and Constructing Static 2D and 3D Charts
B
ox-Whisker Plot
A box-whisker plot exhibits key statistics, such as the first quartile (a cut-off area where
25% of the values lies beneath), the second quartile (the median value—constitutes the
central data point), and the third quartile (a cut-off area where 75% of the values lies
overhead). Also, it detects extreme values of the data (outliers).
Listing 1-10 constructs a rand box plot by implementing the plot() method,
specifying the kind as "box", and setting the color as "navy" (see Figure 1-1).
df["rand"].plot(kind="box", color="navy")
plt.title("South African rand box plot")
plt.show()
Figure 1-1 shows slight skewness, which refers to the tendency of values to deviate
away from the mean value. Alternatively, confirm the distribution using a histogram.
6
Chapter 1 Tabulating Data and Constructing Static 2D and 3D Charts
H
istogram
A histogram exhibits intervals (a range of limiting values) in the x-axis and the frequency
(the number of times values appear in the data) in the y-axis. Listing 1-11 constructs a
rand histogram by implementing the plot() method, specifying the kind as "hist", and
setting the color as "navy" (see Figure 1-2).
df["rand"].plot(kind="hist", color="navy")
plt.title("South African rand histogram")
plt.xlabel("Rand intervals")
plt.ylabel("Frequency")
plt.legend(loc="best")
plt.show()
Figure 1-2 does not show a bell shape (confirming Figure 1-1), implying that the
values do not saturate the mean value.
7
Chapter 1 Tabulating Data and Constructing Static 2D and 3D Charts
L ine Plot
A line plot exhibits the motion of values across time using a line. Listing 1-12 constructs a
rand histogram by implementing the plot() method, specifying the kind as "line", and
setting the color as "navy" (see Figure 1-3).
df["rand"].plot(kind="line", color="navy")
plt.title("South African rand series")
plt.xlabel("Date")
plt.ylabel("Rand")
plt.legend(loc="best")
plt.show()
8
Chapter 1 Tabulating Data and Constructing Static 2D and 3D Charts
To alter the line width, specify lw (see Listing 1-13 and Figure 1-4).
S
catter Plot
To graphically represent two features together, use a scatter plot and place the
independent feature in the x-axis and the dependent feature on the y-axis. Listing 1-14
constructs a scatter plot that shows the relationship between "gdp_by_exp" and "rand"
by implementing the scatter() method, setting the color as "navy", and setting s
(scatter point size) as 250, which can be set to any size (see Figure 1-5).
9
Chapter 1 Tabulating Data and Constructing Static 2D and 3D Charts
Figure 1-5 shows that scatter points are higher than –5, except the point beyond –15
GDP by expenditure and the 18 rand mark.
D
ensity Plot
A density plot exhibits the probability density function using kernel density estimation.
Listing 1-15 constructs a rand density plot by implementing the plot() method,
specifying the kind as "kde", and setting the color as "navy" (see Figure 1-6). Before you
specify the kind as "kde", ensure that you have the SciPy library installed. In a Python
environment, use pip install scipy. Likewise, in a conda environment, use conda
install -c anaconda scipy.
10
Chapter 1 Tabulating Data and Constructing Static 2D and 3D Charts
df["rand"].plot(kind="kde", color="navy")
plt.title("South African rand density plot")
plt.xlabel("Date")
plt.ylabel("Rand")
plt.legend(loc="best")
plt.show()
V
iolin Plot
A violin plot captures distribution with the aid of the kernel density estimation function.
Install seaborn in a Python environment using pip install seaborn. If you are in a
conda environment, use conda install -c anaconda seaborn. Listing 1-16 imports the
11
Chapter 1 Tabulating Data and Constructing Static 2D and 3D Charts
seaborn library as sns. Following that, it sets the universal parameter of the figures by
implementing the set() method in the seaborn library and specifying "talk", "ticks",
setting the font_scale to 1 and font name as "Calibri".
Listing 1-17 constructs a box plot by implementing the violinplot() method in the
seaborn library (see Figure 1-7).
import seaborn as sn
sns.violinplot(y=df["rand"])
plt.title("South African rand violin plot")
plt.show()
Figure 1-7 shows the violin plot does not signal any abnormalities in the data.
12
Chapter 1 Tabulating Data and Constructing Static 2D and 3D Charts
R
egression Plot
To capture the linear relationship between variables, pass the line that best fits the data.
Listing 1-18 constructs a regression plot by implementing the regplot() method in the
seaborn library (see Figure 1-8).
Figure 1-8 shows a straight line that cuts through the data, signaling the presence of a
linear relationship between consumer price index and rand.
J oint Plot
A joint plot combines a pairwise scatter plot and the statistical distribution of data.
Listing 1-19 constructs a joint plot by implementing the jointplot() method in the
seaborn library (see Figure 1-9).
13
Chapter 1 Tabulating Data and Constructing Static 2D and 3D Charts
H
eatmap
A heatmap identifies the intensity of the distribution in the data. Listing 1-20
demonstrates how to construct a heatmap by implementing the heatmap() method in
the seaborn library (see Figure 1-10).
sns.heatmap(df)
plt.title("South African economic data heatmap")
plt.show()
14
Chapter 1 Tabulating Data and Constructing Static 2D and 3D Charts
Alternatively, you may change the continuous color sequence by specifying the cmap.
Listing 1-21 specifies the cmap as "viridis" (see Figure 1-11).
sns.heatmap(df, cmap="viridis")
plt.title("South African economic data heatmap")
plt.show()
15
Chapter 1 Tabulating Data and Constructing Static 2D and 3D Charts
sns.heatmap(df, cmap="coolwarm")
plt.title("South African economic data heatmap")
plt.show()
16
Chapter 1 Tabulating Data and Constructing Static 2D and 3D Charts
Besides the color sequences specified in Figure 1-12, there are others that you may
implement (e.g., gray, blue, and orange). Learn more on the official seaborn website at
https://seaborn.pydata.org/generated/seaborn.heatmap.html.
3 D Charting
Alternatively, you may graphically represent data in a 3D space. The mpl_toolkits
library comes along with the Matplotlib library. Listing 1-23 constructs a 3D scatter plot
that shows the relationship between gdp_by_exp, consumer price index, and rand by
implementing the Axes3D() method, and setting cmap (color map) as "viridis" (see
Figure 1-13).
17
Chapter 1 Tabulating Data and Constructing Static 2D and 3D Charts
18
Chapter 1 Tabulating Data and Constructing Static 2D and 3D Charts
C
onclusion
This chapter acquainted you with the basics of extracting and tabulating data by
implementing the pandas library. Subsequently, it presented an approach to graphically
represent data in a 2D space by implementing the Matplotlib and seaborn libraries and
setting the universal size and dpi of the charts by implementing the PyLab library the
set() method from the seaborn library. Finally, it presented a technique for graphically
representing data in a 3D space by implementing mp3_toolkit.
Ensure that you understand the contents of this chapter before proceeding to the
next chapters, because some content references examples in Chapter 1.
19
CHAPTER 2
Interactive Tabulation
and Charting
Chapter 1 introduced the basics of tabulating data by implementing the pandas library
and graphically representing data in 2D and 3D space by implementing the Matplotlib
library. Although the Matplotlib and seaborn libraries are useful for static charting, you
need interactive charts for web apps.
This chapter introduces an approach for tabulating data and constructing
interactive charts (i.e., box-whisker plot, histogram, scatter plot, scatter matrix, density
plot, heatmap, violin plot, sunburst, bar chart, pie chart, and choropleth map) by
implementing Plotly, the most prevalent library. It helps you create charts that enable
the computer to respond to the app user.
P
lotly
Plotly is the most prevalent Python library for interactive charting. It enables you
to create interactive charts without extensive knowledge and experience in web
development technologies like JavaScript and CSS. You can also implement it in an R
environment, among other environments. Learn more about Plotly at https://plotly.
com/python/.
This book implements Plotly for interactive charting. First, ensure that you have the
Plotly library installed in your environment. To install the it in a Python environment,
use pip install plotly. Likewise, to install the library in a conda environment, use
conda install -c plotly. Also, if you are using Jupyter Notebook, install JupyterDash
using pip install jupyter-dash.
21
© Tshepo Chris Nokeri 2022
T. C. Nokeri, Web App Development and Real-Time Web Analytics with Python,
https://doi.org/10.1007/978-1-4842-7783-6_2
Chapter 2 Interactive Tabulation and Charting
import plotly.graph_objects as go
from plotly.subplots import make_subplots
df = df.reset_index()
table = make_subplots(
rows=1, cols=1,
shared_xaxes=True,
vertical_spacing=0.03,
specs=[[{"type": "table"}]]
)
table.add_trace(go.Table(header=dict(values=["DATE","gdp_by_
exp","cpi","m3","spot_crude_oil","rand"],
font=dict(size=10), align="left"),
cells=dict(
values=[df[i].tolist() for i in df.columns],
align = "left")),
row=1, col=1)
table.show()
22
Chapter 2 Interactive Tabulation and Charting
Interactive Charting
Matplotlib is suitable for 2D and 3D static charting, thus convenient for prototyping
and printing. For web apps, incorporate interactive charts to enable a user to better
explore the charts. There are many Python libraries for interactive charting (e.g., Bokeh,
Streamlit, and Plotly).
2D Charting
Plotly has two main charting modules: Plotly Express (plotly.express) and graph_
objects. This chapter implements Plotly Express for interactive charting. Listing 2-2
imports Plotly Express.
import plotly.express as px
Plotly Express comprises several charts (i.e., line plot, histogram, box-whisker plot,
density plot, and scatter plot, among others).
To set the universal theme for the charts, implement the io function. Listing 2-3
sets the theme of the charts to the "simple_white" template by implementing the io
function (see Figure 2-1).
23
Chapter 2 Interactive Tabulation and Charting
Listing 2-4 sets the theme of the charts to the "plotly_dark" template by
implementing the io function (see Figure 2-2).
pio.templates.default = "plotly_dark"
figure = px.line(df, x=df.index, y="rand",
title="South African rand series")
figure.show()
24
Chapter 2 Interactive Tabulation and Charting
Listing 2-5 sets the theme of the charts to the "seaborn" template by implementing
the io function (see Figure 2-3).
pio.templates.default = "seaborn"
figure = px.line(df, x=df.index, y="rand",
title="South African rand series")
figure.show()
25
Chapter 2 Interactive Tabulation and Charting
B
ox Plot
Listing 2-6 constructs a box plot (also known as a box and whisker plot) by implementing
the box() method from the express function (see Figure 2-4).
26
Chapter 2 Interactive Tabulation and Charting
Figure 2-4 exhibits slight skewness to the left (the upper tail is longer than the
lower tail).
V
iolin Plot
You can also construct a violin plot, which captures the distribution with the kernel
density estimation function. Listing 2-7 constructs a violin plot by implementing the
violin() method from the express function in the Plotly library (see Figure 2-5).
27
Chapter 2 Interactive Tabulation and Charting
Figure 2-5 shows a violin plot that does not signal any abnormalities in the data.
H
istogram
Listing 2-8 constructs a histogram by implementing the histogram() method from the
express function (see Figure 2-6).
28
Chapter 2 Interactive Tabulation and Charting
Figure 2-6 shows that the distribution is slightly skewed to the left.
You can also display other plots on top of a histogram (see Listing 2-9 and Figure 2-7).
The following example adds a box plot on top of the histogram.
29
Chapter 2 Interactive Tabulation and Charting
Figure 2-7 displays both the histogram and box plot signal. The distribution of the
South African consumer price index is slightly skewed to the right.
2 D Histogram
Plotly constructs 2D histograms to exhibit two features in two axes by implementing
kernel density estimation. Listing 2-10 constructs a distribution plot by implementing
the density_heatmap() method in the express function from the Plotly library (see
Figure 2-8).
30
Chapter 2 Interactive Tabulation and Charting
Figure 2-8 shows a high concentration of the South African consumer price index is
around 80 to 100, and the rand is around 10 to 12.
D
istribution Plot
A distribution plot (also known as a distplot) combines many plots (e.g., histogram
and kernel density estimation). Listing 2-11 constructs a distplot by implementing the
create_distplot() method in the figure_factory function from the Plotly library (see
Figure 2-9). First, it specifies the data and labels.
import plotly.figure_factory as ff
data = [df["m3"],df["rand"]]
labels = ["Money Supply", "Rand"]
figure = ff.create_distplot(data, labels)
figure.show()
31
Chapter 2 Interactive Tabulation and Charting
Figure 2-9 features two distribution plots, where the orange plot represents the
distribution of the South African rand, and the blue one represents South Africa’s money
supply.
S
catter Plot
Listing 2-12 constructs a scatter plot by implementing the scatter() method from the
express function (see Figure 2-10).
32
Chapter 2 Interactive Tabulation and Charting
Figure 2-10 shows that scatter points are over the –5, except one point near the –15
GDP by expenditure mark and the 18 rand mark.
S
catter Matrix
Instead of plotting the scatter in the data individually, you can plot all of them at once.
Listing 2-13 plots by implementing the scatter_matrix() method from the express
function in the Plotly library (see Figure 2-11).
figure = px.scatter_matrix(df)
figure.show()
33
Another Random Scribd Document
with Unrelated Content
after the Duke of Cumberland had forced the young Pretender to
raise the siege of Stirling castle, and to retreat to the Highlands, the
three companies of the regiment stationed in Fort Augustus were
besieged by the rebel army. As the young Pretender had obtained a
train of artillery, and the services of a few French officers and
engineers, the reduction of the fort was not a difficult operation, and
the three companies were made prisoners: the works were
afterwards blown up and abandoned by the enemy.
1747
A lieutenant and about fifty men of the regiment had, in the mean
time, assembled at Edinburgh: some of these men had escaped from
captivity, others were the remains of the two companies which had
fought at Preston-pans, and they were directed to proceed, by
forced marches, to Inverlochy, and throw themselves into Fort
William: a drummer and three men of the regiment, who were made
prisoners at Fort Augustus, also escaped from custody and took
refuge in Fort William. In March, 1746, the enemy besieged the fort,
and the garrison made a most resolute defence. By a well-directed
fire from the works, by sallies and other devices, with the co-
operation of a small naval force, the enemy was forced to raise the
siege and retire. This success was followed by the overthrow of the
rebel army at Culloden, which extinguished the hopes of the
Pretender, and the insurrection was thus finally suppressed. The
officers and men of the Sixth were liberated from captivity, the
companies in garrison were relieved, and the regiment proceeded to
England to recruit its numbers, where it remained for six years.
1751
In the warrant of King George II., bearing date the 1st of July,
1751, for regulating the uniform, colours, and distinctions of
regiments, the facing of the Sixth was directed to be of DEEP YELLOW.
"The first colour to be the great Union; and the second to be of deep
yellow, with the union in the upper canton; in the centre of the
colours the Antelope, being the ancient badge of the regiment, and in
the three corners of the second colour the rose and crown. The front
of the grenadier caps to be of deep yellow, with the antelope, as in
the colours; the little flap to be red, with the white horse, and motto,
Nec aspera terrent, over it; the back part of the cap to be red, and
the turn-up deep yellow. The same badge of the antelope to be
painted on the drums and bells of arms, with the rank of the
regiment underneath."
1753
1755
1756
The Sixth were employed on home duty until the winter of 1753,
when they embarked for Gibraltar to relieve the thirty-second
regiment; and they were employed on garrison duty at that
important fortress during the whole of the Seven years' war.
Hostilities commenced in America in 1755, and in 1756 a French
armament, commanded by Marshal Duke of Richelieu, invaded the
island of Minorca, in the capture of which the Sixth took so
distinguished a part in 1708; and a detachment of the regiment was
held in readiness to proceed to Port Mahon to reinforce the garrison.
This service was, however, delayed; and Lieut.-General Fowke, who
commanded the forces at Gibraltar, was dismissed the service for
neglecting to strengthen the troops in Minorca by a battalion from
his garrison.
1763
After the peace of Fontainebleau the Sixth were relieved from duty
at Gibraltar, and returned to England, where they arrived in the
summer of 1763. Two years afterwards they proceeded to Scotland.
1765
1773
Soon after arriving at St. Vincent the Sixth lost their colonel,
Lieut.-General Rufane, who died on the 14th of February, 1773, and
was succeeded by Lieut.-General John Gore from the sixty-first
regiment: this officer died in November following, when his Majesty
conferred the colonelcy of the Sixth on Lieut.-General Sir William
Boothby, Baronet, from the fiftieth foot.
1774
1775
1776
1777
1778
1779
1780
1782
In 1782 county titles were given to regiments, in order to facilitate
the procuring of recruits; and the Sixth were designated the First
Warwickshire regiment: at the same time the officers were directed
to cultivate a connection with that division of the county, so as to
create a mutual attachment between the inhabitants of Warwickshire
and the regiment.
1783
1786
On the 5th of May, 1786, the regiment embarked from Ireland for
North America, to relieve the seventeenth at Nova Scotia, and was
stationed in that island for several years.
1787
1792
1793
1794
The forces engaged in this enterprise rendezvoused at Barbadoes
in January, 1794, under the orders of General Sir Charles Grey, K.B.
(afterwards Earl Grey), and the battalion companies of the Sixth
constituted part of the third brigade, the flank companies being
formed in grenadier and light infantry battalions. A landing was
effected at three different points on the island of Martinico in the
early part of February, and after some sharp fighting, in which the
Sixth had about half a dozen men killed and wounded, this valuable
possession was delivered from the power of republicanism. Sir
Charles Grey observed in his public despatch:—"The spirit,
unanimity, and perseverance of the navy and army never were more
conspicuous; nor has more cordial co-operation ever been
manifested between his Majesty's naval and land forces. In a word,
the general, and field-officers, and the commanding officers of
corps, have set such an example of zeal, activity, and animation in
this service, which has been so laudably imitated by all the officers
and soldiers of this little army, that they merit the greatest praise."
From Martinico the grenadiers under Prince Edward (afterwards
Duke of Kent), the light infantry under Major-General Thomas
Dundas, with the Sixth, ninth, and forty-third regiments, commanded
by Colonel Sir Charles Gordon, re-embarked on the 30th of March,
and arriving at St. Lucia on the 1st of April, completed the conquest
of that fine island in three days. A detachment of the regiment was
next employed in the reduction of the island of Guadaloupe: a
determined resistance was made by the enemy, but the island was
captured before the end of April, and Sir Charles Grey declared in his
public despatch, that he "could not find words to convey an
adequate idea, or to express the high sense he entertained, of the
extraordinary merit evinced by the officers and soldiers in this
service."
Although the extension of revolutionary power in Europe engaged
the attention of the regicide government of France, yet the loss of
these valuable colonial possessions was not regarded with
indifference, and an expedition was fitted out at Brest for the
recovery of the conquered islands. In June a body of French troops
arrived at Guadaloupe, and the doctrines of liberty and equality were
so successfully disseminated among the mulattoes and blacks, that
they quickly flocked to the republican standard. The posts occupied
by the British were attacked, and in October the whole island, except
Fort Matilda, was re-captured by the French. This fort was defended
by the troops under Major-General Prescott until December, when it
was evacuated. The Sixth had several men killed and wounded in the
defence of Guadaloupe, and had also Lieutenant Ekins wounded.
1795
1796
1797
1798
1799
1803
1804
1806
1807
1808
While the Sixth were in garrison at Gibraltar, the tyrannical
proceedings of Bonaparte in Portugal and Spain, and the resistance
which he met with in those countries, induced the British
Government to aid the patriots in their endeavours to shake off the
French yoke; and in June, 1808, this regiment, mustering upwards
of eleven hundred men, was placed under the orders of Major-
General Brent Spencer, with the view of being employed in this
service. For some time, however, the point at which a landing should
take place was not decided, and the troops appeared first off Ceuta,
then proceeded to Cadiz, subsequently to Lisbon, and back to Cadiz.
At length circumstances occurred which induced Major-General
Spencer once more to proceed to the vicinity of Lisbon, where he
learnt that Lieut.-General Sir Arthur Wellesley had arrived, with eight
thousand men from Ireland, in the Mondego river, and immediately
proceeded thither to join him.
Having landed on the shores of Portugal, the Sixth were formed in
brigade with the thirty-second regiment, under Brigadier-General
Bowes; the advanced guard quitted the banks of the Mondego river,
on the 9th of August, and on the 17th attacked the French under
General Laborde in their position at Roleia.
On the morning of this day, which is memorable for being the first
of a series of victories gained by the British troops in the Peninsula,
the Sixth issued from Obidos, a town with a Moorish castle, built on
a gentle eminence in the middle of a valley, and, directing their
march to the left, gained the ridge of heights on the enemy's right.
They formed part of the left column of attack under Major-General
Ferguson, destined to turn all the enemy's posts on the left of the
valley, and the right of his post at Roleia; also to oppose the efforts
of a body of French troops under General Loison, should they arrive
from Rio Major during the action. The heights were cleared, the
column descended from the higher grounds in the rear of the centre,
and joining Brigadier-General Fane's brigade, were directed through
the mountains to outflank the French right. Meanwhile the troops
which attacked the enemy's centre were triumphant; the Sixth and
other corps in the left column turned his right flank, and he fell back
fighting to the Quinta de Bugaliera, and soon after four o'clock the
action had ceased. The Sixth were not seriously engaged: their only
loss was Captain John Currey and two men wounded, and one man
missing; but their gallant bearing, and eagerness to engage their
adversaries were conspicuous, and they were rewarded with the
honour of bearing the word "Roleia" inscribed on their colours.
On the 19th of August the Sixth marched into position at Vimiera,
a village near the sea-coast, and situate in a valley through which
runs the little river Maceira; and the regiment was one of the corps
posted on a large mountain which commenced at the coast. At
seven o'clock on the morning of the 21st of August a cloud of dust
was observed beyond the nearest hills, and soon afterwards the
French army, commanded by Marshal Junot, was seen advancing in
order of battle.
The Sixth, and several other corps, were directed to cross the
valley behind the village, and to take post on another height, which
overtopped the hill in front of the village; and, before the regiment
reached the summit, the battle had commenced. A sternly contested
action among rugged rocks and broken grounds ended in an entire
defeat of the French army; and the Sixth were rewarded with the
honour of bearing the word "Vimiera" inscribed on their colours.
These successes were followed by the convention of Cintra, and
the British soldiers saw their gallant efforts succeeded by the
deliverance of Portugal from the power of the enemy. On the
departure of the French, the Sixth marched up the country to the
strong fortress of Almeida, situate on the river Coa, in the province
of Beira, where they remained in garrison four months.
1809
1810
1811
1812
1813
1814
1815
1816
The Sixth remained in the neighbourhood of Ecouen until the 23rd
of January, 1816, when they marched for St. Pol in the Pas de Calais,
and in February three companies occupied Lillers, and seven the
adjacent villages.
In August, 1816, the regiment proceeded to the vicinity of St.
Omer, and encamped, with the remainder of the second division of
the British contingent of the army of occupation, on Helfant Heath.
In October it proceeded to the plains of Denain, near Valenciennes,
where the British contingent was reviewed by Field-Marshal His
Grace the Duke of Wellington on the 22nd of that month. After the
review the regiment returned to its former cantonments at Lillers
and the neighbouring villages.
1817
1818
1819
1820
1821
The Sixth remained at Leeds and Halifax until June, 1821, when
they proceeded to Hull, and embarked for the island of St. Helena.
Two companies had sailed for their destination when information
arrived of the death of Napoleon Buonaparte in exile at St. Helena.
The remainder of the regiment then proceeded to the Downs, where
its destination was changed to the Cape of Good Hope, and after a
tedious voyage arrived on the 3rd of November at Table Bay, where
it was joined by the two companies from St. Helena. Having landed,
the regiment was inspected by Lieut.-General Sir Rufane Donkin,
K.C.B., at Cape Town, and was commended for its appearance,
conduct, and efficient state—its effectives being only one man less
than on its embarkation from England. After remaining a few days
on shore, five companies, under Brevet-Major Rogers, re-embarked
and sailed to Algoa Bay, from whence they proceeded to Graham's
Town, and marched from thence to several posts and forts along the
frontier line. The establishment had, in the mean time, been reduced
to eight companies of thirty-three officers and six hundred and
eighteen non-commissioned officers and private soldiers.
1822
1823
1824
1825
1826
1827
1828
Seven officers and two hundred and eleven men joined from
England in May, 1828. During the heavy rains many men were
carried off by the cholera morbus; in the month of July alone the
Sixth lost fifty-eight men from this disease. This was a year of
general sickness all over India; but at no station did any regiment
suffer so much as the Sixth on Colaba island; their loss being two
officers and one hundred and twenty one men, and they sent sixty-
two invalids to England.
1829
The very sickly state of the regiment, from its having been
stationed during four monsoons at Bombay, occasioned it to be
removed to the more healthy station of Poona in the Deccan: it
embarked from Colaba on the 6th of February, 1829, landed at
Panwell on the opposite coast in the evening, and marched for
Poona, where it arrived on the 17th, and was stationed in the lines
then recently occupied by the twentieth regiment. The health of the
men began to improve rapidly, and in a few months the Sixth were
one of the most healthy and efficient corps in India. In May one
hundred and thirty-five volunteers from the forty-seventh regiment
joined the Sixth in camp at Poona; and at the inspection, on the 10th
of June, Major-General Sir Lionel Smith, K.C.B., expressed himself
much gratified with the appearance and efficiency of the corps. The
loss from disease during this year was thirty-two men.
1830
1831
1832
The regiment remained at Poona during the year 1832, and on the
24th of May, 1832, His Majesty King William IV. was graciously
pleased to confer upon it the title of Sixth, or Royal First Warwickshire
Regiment of Foot[38]; at which time its facings were changed from
yellow to blue.
1833
1834
1835
1836
1837
1838
In January, 1833, the regiment was at Panwell, in February it was
encamped near Dungah, and in March at Deesa, where it remained
during that and the two succeeding years, when it proceeded to
Colaba. It was stationed at Colaba during the years 1836 and
1837[39]; and in the beginning of 1838 returned to cantonments at
Poona, where it has remained until the end of the year; which brings
this record to a conclusion.
The formation of the Sixth, or Royal First Warwickshire Regiment, in
1674, to support the cause of civil and religious liberty in Holland
against the power of the ambitious Louis XIV. of France, gives an
interesting character to its origin, and also to its early services in
support of the Protestant interests. At the Revolution, in 1688, it had
the honour to compose part of the army which appeared in England
to rescue the country from the dangers by which it was menaced. It
aided in delivering Ireland from the power of papacy, and afterwards
fought under King William III. in the Netherlands. In the war of the
Spanish succession it performed much sharp fighting and arduous
duty in Spain. Its services at home, and in the West Indies, have
been of an important character. It had the honour to gain laurels
under Lieut.-General Sir John Moore, and also under the Duke of
Wellington, in Portugal, Spain, and France, and acquired distinction
on the distant shores of Lake Erie in North America. During the last
eighteen years it has been employed in protecting the British colonial
possessions in Africa and Asia, a service from which important
commercial advantages are derived by the country.
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