Complete Download Data Science, Analytics and Machine Learning with R 1st Edition Luiz Favero PDF All Chapters
Complete Download Data Science, Analytics and Machine Learning with R 1st Edition Luiz Favero PDF All Chapters
com
https://ebookmeta.com/product/data-science-analytics-and-
machine-learning-with-r-1st-edition-luiz-favero/
OR CLICK HERE
DOWLOAD NOW
https://ebookmeta.com/product/the-last-hunt-1st-edition-maor-kohn/
ebookmeta.com
Deploying to Openshift First Edition Graham Dumpleton
https://ebookmeta.com/product/deploying-to-openshift-first-edition-
graham-dumpleton/
ebookmeta.com
https://ebookmeta.com/product/contemporary-management-12th-ed-12th-
edition-gareth-r-jones/
ebookmeta.com
https://ebookmeta.com/product/assisted-reproduction-techniques-
khaldoun-sharif/
ebookmeta.com
https://ebookmeta.com/product/smell-and-taste-disorders-cambridge-
pocket-clinician-1st-edition-christopher-h-hawkes/
ebookmeta.com
Changing Trends in Human Thoughts and Perspectives Science
Humanities and Culture 1st Edition Jogamaya Devi College
https://ebookmeta.com/product/changing-trends-in-human-thoughts-and-
perspectives-science-humanities-and-culture-1st-edition-jogamaya-devi-
college/
ebookmeta.com
DATA SCIENCE, ANALYTICS AND MACHINE
LEARNING WITH R
DATA SCIENCE,
ANALYTICS
AND MACHINE
LEARNING WITH R
LUIZ PAULO FÁVERO
PATRÍCIA BELFIORE
RAFAEL DE FREITAS SOUZA
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 © 2023 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-824271-1
vii
C H A P T E R
1
Overview of data science, analytics,
and machine learning
Introduction
This chapter provides a brief introduction to data science, analytics, and machine learning, which will serve as a
foundation for understanding the concepts and techniques covered throughout the book.
In this new millennium, in which it is estimated that more than 5 quintillion pieces of data are generated daily from
social networks, the internet of things, digital photos, consumer monitoring, and other sources, the understanding of
the importance of data science in its various aspects is of fundamental importance for scientific and technological
advancement, economic and social development, environmental preservation, business success, the discovery and
exploration of new areas of knowledge, understanding of historical events, and even the protection of life on our
planet!
Data science is therefore naturally multidisciplinary. We found examples of data science applications in engineer-
ing, physics, medicine, biology, education, psychology, pedagogy, law, politics, public security, economics, sociology,
business, marketing, astronomy, anthropology, human resources, meteorology, geography, and history. We will
hardly be able to find a field of study in which it is not possible to investigate phenomena through the techniques
and procedures of data science.
There are many aspects that data science encompasses. Many are the professions associated with these
aspects because every day we witness the emergence of new terminologies and positions in the market and
in the academic world. Examples include data scientist, data engineer, data architect, data analyst, business intel-
ligence analyst, machine learning engineer, database administrator, computer engineer, information technology
facilitator, edge computing master, cybercity analyst, personal data broker, machine manager, digital tailor, aug-
mented reality (AR) journey builder, user experience (UX) writer, DevOps (developers and IT operation profes-
sionals), among many other professions. And these professionals work, as we mentioned, in the most diverse
sectors! We find data engineers in the food and beverage industry as well as AR journey builders in the gaming
industry.
Figure 1.1 provides an overview of the relationship among data science, analytics, and machine learning.
Data Science, Analytics and Machine Learning with R 3 Copyright © 2023 Elsevier Inc. All rights reserved.
https://doi.org/10.1016/B978-0-12-824271-1.00034-2
4 1. Overview of data science, analytics, and machine learning
FIGURE 1.1 Overview of data science, analytics, and machine learning (Fávero and Belfiore, 2019).
Through Figure 1.1, it is possible to verify, therefore, that data science encompasses knowledge about data analysis
(analytics) as well as knowledge about methods, algorithms, Big Data, and decision-making processes.
The Analytics pillar involves knowledge and fundamentals about measurement scales of variables, mathematics,
statistics, calculus, linear algebra, operations research, geometry, and trigonometry. It is not possible to find a data
scientist who does not present some solidity of knowledge in these fields; however, if you find one who identifies this
way, this person will be, at most, a pusher of codes and buttons!
The pillar referring to methods, algorithms, and Big Data refers to the knowledge for implementing routines and
codes from specific languages such as R, Python, Stata, Julia, SQL, Java, C/C ++, Scala, SAS, Matlab, SPSS, among
many others. Note that the implementation of routines necessarily involves knowledge about the fundamentals of
Analytics so mistakes are not made when writing the codes. It is very common to find programmers who do not know
the statistical foundations of a particular modeling technique and end up writing code that does not reflect, for exam-
ple, the nature of the variables under study. The outputs obtained in this case will be, to say the least, inaccurate and
sometimes completely wrong!
In this pillar, we can still find the fundamentals of Big Data, which correspond to the simultaneous occurrence of five
characteristics, or dimensions of the data: volume, speed, variety, variability, and complexity of the data.
The exacerbated volume of data arises, among other reasons, from the increase in computational capacity and the
increase in the monitoring of the most diverse phenomena. The speed with which data becomes available for treatment
and analysis, due to new forms of collection that use, for example, electronic tags and radiofrequency systems, is also
visible and vital for the decision-making processes. The variety refers to the different formats in which the data are
accessed, such as texts, indicators, secondary bases, or even speeches, and a convergent analysis can also provide better
decision making. The variability of the data is related, in addition to the three previous dimensions, with cyclical or
seasonal phenomena, sometimes with high frequency, directly observable or not, and that a given treatment can gen-
erate differentiated information. Last, but not least, the complexity of the data, especially for large volumes, lies in the
fact that many sources can be accessed with different codes, periodicities, or criteria, which requires a control process
from the researcher (Fávero and Belfiore, 2019).
In this sense, the relationship between the Analytics pillar and the Methods, Algorithms, and Big Data pillar cor-
responds to what we call machine learning, which refers to the processes of pattern recognition in data from codes that
“train the machine” for this purpose, that is, a process for exploring data to discover meaningful patterns and rules.
Here are also deep learning algorithms, or deep pattern recognition from algorithms, for example, from neural net-
works for image recognition based on large amounts of data.
This processing flow cannot be supported without being accompanied by the improved professional software and
increased processing capacity of increasingly gigantic datasets that are capable of supporting the elaboration of the
most diverse tests and the estimation of the most varied models that should reflect the reality of each situation
and according to what the researcher and the decision maker want.
These are the main reasons that have led organizations active in the most diverse sectors to invest in the structuring
and development of multidisciplinary areas of data science that have the main objective of analyzing data and gen-
erating information, allowing the creation of pattern recognition and the establishment of real-time predictive capa-
bility. The emergence and improvement of complex computer systems, together with the reduction in costs for
acquiring hardware and software, have made organizations increasingly store data in data warehouses, data lakes,
virtual libraries, and the cloud (Fávero and Belfiore, 2019).
I. Introduction
Overview of the book 5
The direct acquisition of outputs from analytics tools and the deployment of models, which refers to a data engi-
neering task focused on the production and availability, through APIs (Application Programming Interfaces), of
models estimated in real time, generate subsidies for decision making. And, obviously, the decision-making process
goes through aspects related to team management, resource allocation, and humanization of production processes!
In a cyclical way, understanding the business or the area of study can improve the acquisition of new data, increase
the ability to prepare these data, and favor the development of new programming codes with a focus on the search for
other machine learning models that eventually generate better adhesions between the real values of the phenomenon
under study and the fitted values obtained. This can provide better results, which will favor an increase in the ability to
understand the area of study and the business as a whole!
Part I: Introduction
Chapter 1: Overview of data science, analytics, and machine learning
Chapter 2: Introduction to R-based language
Part II: Applied statistics and data visualization
Chapter 3: Types of variables, measurement scales, and accuracy scales
Chapter 4: Univariate descriptive statistics
Chapter 5: Bivariate descriptive statistics
Chapter 6: Hypotheses tests
Chapter 7: Data visualization and multivariate graphs
I. Introduction
6 1. Overview of data science, analytics, and machine learning
It is important to emphasize that a version of this chapter, as well as Chapters 3 to 6 and 11 to 17, was previously
published in the books Manual de Análise de Dados/Handbook of Data Analysis (Fávero and Belfiore, 2017, Portuguese
Edition) and Data Science for Business and Decision Making (Fávero and Belfiore, 2019, English Edition; 2020, Korean
Edition), published by Elsevier Academic Press. All the conceptual parts, the algebraic and mathematical develop-
ments, the datasets, the outputs and the discussions come from those books. Here only R codes are included.
Each chapter is structured in the same presentation didactical logic, which we believe favors learning. First, we offer
applications and practical exercises in R, which will be presented and discussed through case studies with open real
data from many fields (e.g., science, engineering, technology, and health care).
We believe that this logic facilitates the study and understanding of the correct use of each technique. Moreover, the
practical application of the models in R also brings benefits to researchers as the results can be obtained through recent
packages and functions.
At the end of most chapters, additional exercises are proposed along with solutions available online.
Final remarks
I believe this book is meant for researchers who, for different reasons, are specifically interested in data science,
analytics, and machine learning as well as for those who want to deepen their knowledge by using R-based packages
and codes.
This book is recommended to undergraduate and graduate students in the fields of sciences, engineering, technol-
ogy, health care, psychology, actuarial sciences, statistics, economics, business, and other fields related to exact, bio-
medical, and human sciences. It is also meant for students taking extension, lato sensu postgraduation, and MBA
courses as well as for company employees, consultants, and other researchers who have as their main objectives to
treat and analyze data, aiming at preparing data models, creating information, and improving knowledge through
decision-making processes.
First, I want to thank Professor Patrícia Belfiore immensely for our partnership and friendship. Our discussions and
joint studies have been going on for more than twenty years. I remember, like it was yesterday, our first discussions
about data analysis, multivariate modeling, and machine learning techniques. Our first book was published in 2007,
and it has been 15 years now. Thank you so much for everything, Professor Patrícia!
I would also like to sincerely thank the professionals at Montvero Consulting and Training Ltd. and at Elsevier
Academic Press, especially Mara E. Conner, Punithavathy Govindaradjane, Judith Clarisse Punzalan, Indhumathi
Mani, and Andre Gerhard Wolff. Lastly, but not less important, I would like to thank the professors, students, and
employees of the Economics, Business Administration and Accounting College of the University of Sao Paulo
(FEA/USP) and of the Federal University of the ABC (UFABC).
Now it is time for you to get started! I would like to emphasize that any contributions, criticisms, and suggestions
are always welcome so they may be later incorporated into this book and make it better.
Luiz Paulo Fávero
I. Introduction
C H A P T E R
2
Introduction to R-based language
Introduction
The purpose of this chapter is to approach R-based language in an introductory way and to provide the reader with
the basic knowledge necessary to use this book. This includes setting up how to use this work, installing R-based lan-
guage, introducing the necessary software, and absorbing important concepts.
Although it is true that this section will start from the premise that the reader has never had contact with R, it is
important to mention that, in the course of the other chapters of this book, more advanced features will be presented as
they are needed. If the reader feels the need to go even deeper into R-based language, there are numerous possible
readings in the bibliography of this book. In any case, we think that what is proposed in this work is enough for
the reader to be able to enter the world of machine learning using R-based language. Even so, if a beginning reader
feels the urge to delve into R-based language, we suggest two important readings:
▪ Hands-On Programming with R (Grolemund, 2014)
▪ R for Data Science (Wickham and Grolemund, 2017)
At the end of this chapter, the reader will be able to install R-based language on a computer and will be familiar with
the main basic functionalities of the necessary software. This chapter will also help the reader internalize certain R
concepts, install and use language packages, and open datasets, including those from other types of computer
languages.
Data Science, Analytics and Machine Learning with R 7 Copyright © 2023 Elsevier Inc. All rights reserved.
https://doi.org/10.1016/B978-0-12-824271-1.00033-0
8 2. Introduction to R-based language
In a conversation between friends, one of them says, “Hey, let’s go.” The other friend, already imbued with the
context and having experience with the other person, will be fully capable of understanding what was asked, even
with so many omissions of words in the sentence. The sentence “Hey, let’s go” can mean “Let’s go to a cafeteria,” “Let’s
go to the club,” or “Let’s go to the gym.” It does not matter because as a rule, the human receiving the message will
know what it is about, but the machine will not. For the machine, in most cases, it will be necessary to say, in a logical
order and with explicit details, where you go, how you go, with whom you go, and what time you go. Do you
understand?
Be that as it may, this communication, even among friends, is only possible because there is a common
language. The language that the reader will use to communicate with his or her computer while reading this book
will therefore be R.
A fair question would be, Did my computer come from the factory knowing how to “speak” and “understand” R?
It depends. There are some Linux distributions in which R is already present, however, as a rule, installation is required
for all computers.
In order to “teach” the computer to “speak” and “understand” R, it is necessary to install R-based language, present
on the R Project website, accessible at https://www.r-project.org.
On the R Project website, as shown in Figure 2.1, click on “CRAN” below the Download tab.
Depending on the reading date of the work, it is possible that the site presented by Figure 2.1 has undergone sig-
nificant changes.
The next page, demonstrated by Figure 2.2, will be a list of servers from which R-based language can be down-
loaded. We advise downloading from servers that are in the country where the reader is located because of the chance
of better download speed. Whichever the reader chooses, the downloaded language will be the same and by default it
comes in English.
By clicking any of the links presented in Figure 2.2, the reader will be directed to a next page, as shown in Figure 2.3,
in which he or she will need to point out the operating system used by the machine on which R is intended to run and
the version of R-based language to be installed.
After that, the reader will choose the version of R-based language to download. At the time of editing this work, the
most recent R version was 4.1.3, and we guarantee the functionality of the examples in this work for that version.
After downloading, the reader must install the downloaded application. Installation will take place as usual on the
operating system used by the reader to install any other application. We suggest that the installation defaults not be
changed unless the reader knows exactly what he or she is doing. For questions, just consult the R installation man-
ual at https://cran.r-project.org/doc/manuals/r-release/R-admin.pdf.
After installation is done, it can be said that the reader’s machine is already able to “speak” and “understand” R-
based language. However, for a better conduct of the studies proposed by this work, we recommend installation of
RStudio software.
I. Introduction
R-based language installation 9
FIGURE 2.2 Cut from the page with the list of servers from which R-based language can be downloaded.
I. Introduction
10 2. Introduction to R-based language
FIGURE 2.3 Selection screen for choosing the machine’s operating system.
Installing RStudio
RStudio is a free application that provides a friendly interface and with a greater power of control by the reader over
everything that is happening while using R-based language. Nothing would prevent the reader from using only the
application discussed earlier to continue reading, but we strongly recommend that RStudio be downloaded, installed,
and used, especially for readers who are new to programming.
An important question would be, Can I install only RStudio and disregard the previous instructions on the R
Project website? The answer is no. It is imperative that the reader install the application discussed in earlier
the “R-based language installation” section and then install RStudio.
RStudio software can be downloaded from https://www.rstudio.com, as shown in Figure 2.4.
I. Introduction
Other documents randomly have
different content
bagpipes and made lovely music. But he certainly could not read,
and I wrote that I would not give him anything at all.”
Hans rode away to the forest
O
NCE upon a time
When pigs spoke rhyme,
all the birds of the air came to the magpie and asked her to teach
them how to build nests; for the magpie was very clever. So she had
them gather around her and began to show them how to do it. First
of all she took some mud and made a sort of a round cake with it.
“Oh, that’s how it’s done!” said the thrush, and away she flew, and
the thrush has built her nests out of mud ever since.
Then the magpie took some twigs and arranged them around in
the mud.
“Now I know all about it,” said the blackbird. So off she flew, and
the blackbirds make their nests of mud and sticks to this very day.
Then the magpie put another layer of mud over the twigs.
“Oh, that’s quite plain!” said the owl, and away she flew, and owls
have made their nests after that manner ever since.
Next the magpie took some twigs and twined them around the
outside.
“The very thing!” exclaimed the sparrow, and off she went, and the
sparrows to this day make rather slovenly nests.
Then Madge Magpie took some feathers and other bits of soft
material and lined the nest very nicely with it.
“That suits me!” cried the starling, and away she flew, and ever
since then the starlings have built very comfortable nests.
The magpie kept on with her work, but the birds were constantly
leaving before she had finished, each thinking she knew all there
was to know about nest-building. At last the only bird that remained
was the turtle-dove. She now began to repeat her silly cry, “Take two,
Taffy, take two-o-o!”
The magpie was just putting a twig across, and she said, “No, one
is enough.”
But the turtle-dove kept on saying, “Take two, Taffy, take two-o-o!”
That made the magpie angry, and she exclaimed, “One’s enough,
I tell you!”
Still the turtle-dove cried, “Take two, Taffy, take two-o-o!”
At this the magpie became so disturbed that she flew away, and
always afterward, when the birds asked her how to build their nests,
she refused to tell them. That is why different birds build their nests
differently.
PUSS IN BOOTS
O
NCE upon a time there was a poor miller who had three sons,
and when he died he had nothing to leave them except his
mill, a donkey, and a cat. The division was quickly made
without the help of either lawyer or judge. The eldest son took the
mill, and the second took the donkey. So there was nothing left for
the youngest but the cat, and the poor fellow could not help feeling
that he had been treated shabbily. “My brothers will be able to earn a
comfortable livelihood,” he sighed, “but as for me, though Puss may
feed himself by catching mice, he can’t feed me, and I shall certainly
die of hunger.”
While he spoke, the cat was sitting near by and heard all he said.
Immediately the creature jumped on his shoulder, rubbed gently
against his cheek, and began to speak. “Dear master,” said he, “do
not grieve. I am not as useless as you think. Give me a bag, and buy
me a pair of boots so I can scamper through the brush and
brambles, and I will make your fortune for you.”
PUSS IN BOOTS GREETS THE KING
The lad had very little money to spare, but he knew Puss was a
faithful creature, and he had seen him play many cunning tricks to
catch rats and mice, so that he did not altogether despair of his
affording him some help. Therefore he bought him a smart pair of
boots made of buff-colored leather, and gave him the bag for which
he had asked.
Puss drew on the boots, and then he fitted slip-strings around the
mouth of the bag, put some bran and parsley inside, and trotted off
with it to a neighboring hillside where there was an abundance of
rabbits. He laid the bag on the ground with the mouth of it propped
open, and hid himself in the ferns and bushes and waited. Presently
two foolish young rabbits came sniffing about and crept into the bag
to get some of the bran and parsley. The clever cat at once drew the
slip-strings close, and the rabbits were caught. He slung the bag
over his shoulder, and away he went to the royal palace, where he
asked to speak with the king. The guards ushered him into the king’s
presence, and Puss made a low bow, lifted the rabbits out of his bag,
and said, “Sir, my noble lord, the Marquis of Carabas” (this was the
title he chose to confer on his master) “has commanded me to
present these rabbits to your Majesty, with his respects.”
“Tell your master that I thank him,” said the king, “and that he has
given me great pleasure.”
Then he dismissed Puss with many compliments and a purse of
gold, and ordered his head cook to serve the rabbits for dinner so he
and his daughter might enjoy them.
The next day Puss went and hid in a grain field with the bag baited
and open near his hiding-place. A brace of partridges ran into it, and
he drew the strings and caught them. These he took home to his
master, and he went hunting every pleasant day. He kept his master
so well supplied with game that they lived in plenty, and often he
carried some game to the king. Whatever it was that he presented at
the palace, it was always with the message, “From my lord, the
Marquis of Carabas.” So every one at court was talking of this
strange nobleman, whom no one had ever seen, but who sent such
generous gifts to his Majesty.
By and by Puss decided that it was time for his master to be
introduced at court. He learned that on a certain day the king and his
daughter, who was the most beautiful princess in the world, were to
go out in their coach to drive along the riverside, and he said to his
master: “If you will follow my advice your fortune is made. Go and
wash yourself in the river at a spot which I will show you, and leave
the rest to me.”
The young man knew nothing of the why or wherefore of the cat’s
advice, but he went to the river, and the cat took charge of his
clothes while he plunged into the water. He did not enjoy the
experience, for the water was cold, and he soon stopped splashing
around and stood shivering with the water up to his neck, wondering
what was to happen next. Just then the king’s carriage appeared in
sight, and Puss at once began to shout: “Help! help! My lord, the
Marquis of Carabas is drowning!”
The king put his head out of the coach window, and he recognized
Puss as the cat who had so often brought him presents of game.
Immediately he ordered his attendants to go to the assistance of the
marquis. While they were pulling the youth out of the river the cat
came up to the coach and told the king that some rogues had gone
off with his master’s clothes, though in fact the cunning cat had
hidden them under a big stone.
On hearing this story the king dispatched one of his grooms to
fetch a handsome suit of purple and gold from the royal wardrobe.
When the young man had been arrayed in this he looked so well that
no one for a moment supposed but that he was some noble foreign
lord. The king and his daughter were so pleased with his appearance
that they invited him into their carriage. At first he felt a little shy
about sitting next to a princess, but she smiled at him so sweetly,
and was so kind and gentle that he soon forgot his fears. As for her,
after he had cast two or three respectful and somewhat tender
glances in her direction, she fell in love with him to distraction.
When the cat had seen his master seated in the royal carriage, he
was overjoyed to think how well his project was succeeding. He ran
on ahead as fast as he could trot until he came to a field of grain
where the laborers were busy reaping. “Reapers,” said he fiercely,
“the king will soon pass this way. If he should ask you to whom this
field belongs, remember that you are to say, ‘To the Marquis of
Carabas.’ Don’t dare to disobey me, or I will have you all chopped up
as fine as mincemeat.”
The reapers were so afraid the cat would do as he threatened that
they promised to obey. Puss then ran on and told all the other
laborers whom he met to give the same answer, and declared they
would be terribly punished if they did not.
The king was in a very good humor, for the day was fine, and he
found the marquis a very pleasant companion. So he told the
coachman to drive slowly, that he might admire the beautiful country.
“What a fine field of wheat!” he said presently, and he had the coach
stop while he asked the laborers to whom it belonged.
Then the men answered in accord with the cat’s orders, “To our
lord, the Marquis of Carabas.”
“Sir,” said the marquis, “this is a field that never fails to yield
plentifully every year.”
The coach went on until it encountered a herd of cattle. “To whom
do these cattle belong?” the king asked the drovers.
“To the Marquis of Carabas,” they replied.
It was the same all along the way. The king’s inquiries as to the
ownership of property received this uniform reply. The marquis
listened with the greatest astonishment, and thought what a
wonderful cat Puss was; and the king was delighted to find that his
new friend was as wealthy as he was charming.
Meanwhile Puss, who was well in advance of the royal party, had
arrived at a stately castle which belonged to a cruel ogre, the richest
ever known. Indeed, he was the owner of all the land and crops and
cattle the king had admired so much. The cat knocked at the door,
and asked to see the ogre, who received him quite civilly. He had
never before seen a cat in boots, and the sight amused him. So he
and Puss were soon chatting together.
“I have been assured,” said the cat, “that you possess the power
to change yourself into any kind of animal you choose—a lion or an
elephant, for instance.”
“Well, so I can,” responded the ogre briskly.
“Dear me!” said Puss, “how much I should like to see you do it
now.”
The ogre was only too glad to have a chance to show how clever
he was, so he agreed to transform himself into any animal Puss
might mention.
“Oh! I will leave the choice to you,” said the cat politely.
Immediately there appeared, where the ogre had been seated, an
enormous lion, roaring, and lashing with his tail, and looking as
though he meant to gobble up the cat in a trice. Puss was really very
much frightened, and he jumped out of the window and managed to
scramble up on the roof, though not without abundance of trouble
and danger because of his boots. There he clung, refusing to come
down until the ogre resumed his natural form and laughingly called to
him that he would do him no harm.
Then Puss ventured back into the room and began to compliment
the ogre on his cleverness. “Of course,” said he in conclusion, “what
you did was very marvellous, but it would be more surprising still if
you who are so big and fierce could transform yourself into some
timid little creature such as a mouse. That, I suppose, would be
impossible.”
“Not at all,” said the ogre. “One is quite as easy to me as the other,
as I will show you.”
A moment later the ogre had vanished, and a little brown mouse
was frisking about the floor. “Now or never,” said Puss, and with a
sudden leap he seized the mouse and gobbled it up as fast as he
could. Instantly all the gentlemen and ladies whom the wicked ogre
had held in his castle under a spell were disenchanted, and they
came to express their gratitude to their deliverer. They were ready to
do anything to please him, and at his request they agreed to enter
into the service of the Marquis of Carabas.
Now the cat had a splendid castle with much treasure stored in its
vaults, and he ordered a magnificent feast to be prepared. Then he
hurried forth to the highway and met the king’s coach. His Majesty
was looking toward the ogre’s castle. “Whose is it?” he asked. “I
have never seen a finer.”
“It belongs to the noble Marquis of Carabas,” said Puss, “and I beg
you to honor my master by being his guest.”
The king ordered the coachman to drive to the castle, and Puss
went on ahead and threw open the gates. As the carriage was
crossing the drawbridge he cried out, “Welcome to the castle of my
lord, the Marquis of Carabas!”
Full of surprise, the king turned to the marquis and said, “Not even
my own palace can surpass the beauty of your castle.”
Puss helped his Majesty to alight and conducted him into a
spacious hall, where a group of gentlemen and ladies were waiting
to receive them. The marquis came into the hall with the princess,
and they all sat down to a splendid banquet. Long and merrily they
feasted, and when at length the guests rose to depart, the king
embraced the marquis and said: “I am charmed with your many
excellent qualities, and am greatly impressed with the castle which is
your home, and with the magnificence of your hospitality. It will be
your own fault, my Lord Marquis, if you are not my son-in-law.”
The marquis made several low bows, and thanked his Majesty for
the honor he conferred on him. Not long afterward the miller’s son
married the princess, and there were rejoicings throughout the land.
On the evening of the wedding day a great ball was given, to which
princes and noblemen from near and far were invited. Puss opened
the ball, wearing for the occasion a pair of boots made of the finest
leather with gold tassels and scarlet heels. I wish you could have
seen him.
When the old king died, the princess and her husband reigned in
his stead. Their most honored and faithful friend at court was Puss in
Boots, for his master never forgot to whom he owed all his good
fortune. Puss lived on the daintiest meat and the most delicious
cream, and was petted and made much of all the days of his life; and
he never ran after rats and mice except for exercise and
amusement.
THE MASTER AND HIS PUPIL
T
HERE was once a very learned man who knew all the
languages under the sun, and who was acquainted with all the
mysteries of creation. He had in his private room a big book
bound in black leather and fitted with iron clasps, and it was chained
to a table which was screwed fast to the floor. When he wanted to
read in the book he unlocked the clasps with a brass key, and he
never allowed any one else to read in it, for it contained many
magician’s secrets. Among other things it told the names of the
demons, and what they did, and how they could be summoned and
made to work for man.