Full Chapter Practical Recommender Systems 1St Edition Kim Falk PDF

Download as pdf or txt
Download as pdf or txt
You are on page 1of 53

Practical Recommender Systems 1st

Edition Kim Falk


Visit to download the full and correct content document:
https://textbookfull.com/product/practical-recommender-systems-1st-edition-kim-falk/
More products digital (pdf, epub, mobi) instant
download maybe you interests ...

Fashion Recommender Systems Nima Dokoohaki

https://textbookfull.com/product/fashion-recommender-systems-
nima-dokoohaki/

Group Recommender Systems An Introduction 1st Edition


Alexander Felfernig

https://textbookfull.com/product/group-recommender-systems-an-
introduction-1st-edition-alexander-felfernig/

Machine Learning with PySpark: With Natural Language


Processing and Recommender Systems 1st Edition Pramod
Singh

https://textbookfull.com/product/machine-learning-with-pyspark-
with-natural-language-processing-and-recommender-systems-1st-
edition-pramod-singh/

Fundamentals of information systems security 3rd


Edition Kim

https://textbookfull.com/product/fundamentals-of-information-
systems-security-3rd-edition-kim/
The Hacker Playbook 3 Practical Guide To Penetration
Testing 1st Edition Peter Kim

https://textbookfull.com/product/the-hacker-playbook-3-practical-
guide-to-penetration-testing-1st-edition-peter-kim/

Recommender System for Improving Customer Loyalty


Katarzyna Tarnowska

https://textbookfull.com/product/recommender-system-for-
improving-customer-loyalty-katarzyna-tarnowska/

Recommender System with Machine Learning and Artificial


Intelligence Practical Tools and Applications in
Medical Agricultural and Other Industries 1st Edition
Sachi Nandan Mohanty (Editor)
https://textbookfull.com/product/recommender-system-with-machine-
learning-and-artificial-intelligence-practical-tools-and-
applications-in-medical-agricultural-and-other-industries-1st-
edition-sachi-nandan-mohanty-editor/

Gender Innovation and Migration in Switzerland


Francesca Falk

https://textbookfull.com/product/gender-innovation-and-migration-
in-switzerland-francesca-falk/

Data Deduplication for Data Optimization for Storage


and Network Systems 1st Edition Daehee Kim

https://textbookfull.com/product/data-deduplication-for-data-
optimization-for-storage-and-network-systems-1st-edition-daehee-
kim/
Practical Recommender
Systems
Kim Falk
Copyright
For online information and ordering of this and other Manning
books, please visit www.manning.com. The publisher offers
discounts on this book when ordered in quantity. For more
information, please contact

Special Sales Department


Manning Publications Co.
20 Baldwin Road
PO Box 761
Shelter Island, NY 11964
Email: [email protected]

© 2019 by Manning Publications Co. All rights reserved.

No part of this publication may be reproduced, stored in a


retrieval system, or transmitted, in any form or by means
electronic, mechanical, photocopying, or otherwise, without
prior written permission of the publisher.

Many of the designations used by manufacturers and sellers to


distinguish their products are claimed as trademarks. Where
those designations appear in the book, and Manning
Publications was aware of a trademark claim, the designations
have been printed in initial caps or all caps.

Recognizing the importance of preserving what has been


written, it is Manning’s policy to have the books we publish
printed on acid-free paper, and we exert our best efforts to that
end. Recognizing also our responsibility to conserve the
resources of our planet, Manning books are printed on paper
that is at least 15 percent recycled and processed without the
use of elemental chlorine.
Manning Publications Co.
20 Baldwin Road
PO Box 761
Shelter Island, NY 11964

Development editor: Helen Stergius


Production editor: Janet Vail
Copy editors: Katie Petito and Frances Buran
Proofreader: Elizabeth Martin
Technical proofreaders: Valentin Crettaz and Furkan Kamaci
Typesetter: Dottie Marsico
Cover designer: Marija Tudor

ISBN 9781617292705

Printed in the United States of America

1 2 3 4 5 6 7 8 9 10 – SP – 24 23 22 21 20 19
DEDICATION

To the loves of my life: my wife, Sara, and my son, Peter,


the small Superhero
Brief Table of Contents
Copyright

Brief Table of Contents

Table of Contents

Preface

Acknowledgments

About this book

About the author

About the cover illustration

1. Getting ready for recommender systems

Chapter 1. What is a recommender?

Chapter 2. User behavior and how to collect it

Chapter 3. Monitoring the system

Chapter 4. Ratings and how to calculate them

Chapter 5. Non-personalized recommendations

Chapter 6. The user (and content) who came in from the cold

2. Recommender algorithms
Chapter 7. Finding similarities among users and among
content

Chapter 8. Collaborative filtering in the neighborhood

Chapter 9. Evaluating and testing your recommender

Chapter 10. Content-based filtering

Chapter 11. Finding hidden genres with matrix factorization

Chapter 12. Taking the best of all algorithms: Implementing


hybrid recommenders

Chapter 13. Ranking and learning to rank

Chapter 14. Future of recommender systems

Index

List of Figures

List of Tables

List of Listings
Table of Contents
Copyright

Brief Table of Contents

Table of Contents

Preface

Acknowledgments

About this book

About the author

About the cover illustration

1. Getting ready for recommender systems

Chapter 1. What is a recommender?

1.1. Real-life recommendations

1.1.1. Recommender systems are at home on the


internet

1.1.2. The long tail

1.1.3. The Netflix recommender system

1.1.4. Recommender system definition

1.2. Taxonomy of recommender systems


1.2.1. Domain

1.2.2. Purpose

1.2.3. Context

1.2.4. Personalization level

1.2.5. Whose opinions

1.2.6. Privacy and trustworthiness

1.2.7. Interface

1.2.8. Algorithms

1.3. Machine learning and the Netflix Prize

1.4. The MovieGEEKs website

1.4.1. Design and specification

1.4.2. Architecture

1.5. Building a recommender system

Summary

Chapter 2. User behavior and how to collect it

2.1. How (I think) Netflix gathers evidence while you


browse

Often the purpose isn’t what it seems

2.1.1. The evidence Netflix collects


2.2. Finding useful user behavior

Content affiliation to provider

2.2.1. Capturing visitor impressions

2.2.2. What you can learn from a shop browser

2.2.3. Act of buying

2.2.4. Consuming products

2.2.5. Visitor ratings

2.2.6. Getting to know your customers the (old)


Netflix way

2.3. Identifying users

2.4. Getting visitor data from other sources

2.5. The collector

2.5.1. Building the project files

2.5.2. The data model

2.5.3. The snitch: Client-side evidence collector

2.5.4. Integrating the collector into MovieGEEKs

2.6. What users in the system are and how to model them

Summary

Chapter 3. Monitoring the system


3.1. Why adding a dashboard is a good idea

3.1.1. Answering “How are we doing?”

3.2. Doing the analytics

3.2.1. Web analytics

3.2.2. The basic statistics

3.2.3. Conversions

3.2.4. Analyzing the path up to conversion

3.2.5. Conversion path

3.3. Personas

3.4. MovieGEEKs dashboard

3.4.1. Auto-generating data to your log

3.4.2. Specification and design of the analytics


dashboard

3.4.3. Analytics dashboard wireframe

3.4.4. Architecture

Summary

Chapter 4. Ratings and how to calculate them

4.1. User-item preferences

4.1.1. Definition of ratings


4.1.2. User-item matrix

4.2. Explicit or implicit ratings

4.2.1. How we use trusted sources for


recommendations

4.3. Revisiting explicit ratings

4.4. What are implicit ratings?

4.4.1. People suggestions

4.4.2. Considerations of calculating ratings

4.5. Calculating implicit ratings

4.5.1. Looking at the behavioral data

4.5.2. This could be considered a machine learning


problem

4.6. How to implement implicit ratings

Retrieving Data

Calculating implicit ratings

Viewing the result

4.6.1. Adding the time aspect

4.7. Less frequent items provide more value

Summary

Chapter 5. Non-personalized recommendations


5.1. What’s a non-personalized recommendation?

5.1.1. What’s a commercial?

5.1.2. What does a recommendation do?

5.2. How to make recommendations when you have no


data

Ordering by price is usually a bad idea

Using recency keeps the website dynamic

5.2.1. Top 10: A chart of items

5.3. Implementing the chart and the groundwork for the


recommender system component

5.3.1. The recommender system component

5.3.2. MovieGEEKs code from GitHub

5.3.3. A recommender system

5.3.4. Adding a chart to MovieGEEKs

5.3.5. Making the content look more attractive

5.4. Seeded recommendations

5.4.1. Frequently bought items similar to the one


you’re viewing

5.4.2. Association rules

5.4.3. Implementing association rules


5.4.4. Saving the association rules in the database

5.4.5. Running the association rules calculator

5.4.6. Using different events to create the association


rules

Summary

Chapter 6. The user (and content) who came in from the cold

6.1. What’s a cold start?

6.1.1. Cold products

6.1.2. A cold visitor

6.1.3. Gray sheep

6.1.4. Let’s look at real-life examples

6.1.5. What can you do about cold starts?

6.2. Keeping track of visitors

6.2.1. Persisting anonymous users

6.3. Addressing cold-start problems with algorithms

6.3.1. Using association rules to create recs for cold


users

6.3.2. Using domain knowledge and business rules

6.3.3. Using segments


6.3.4. Using categories to get around the gray sheep
problem and how to introduce cold product

6.4. Those who doesn’t ask, won’t know

6.4.1. When the visitor is no longer new

6.5. Using association rules to start recommending things


fast

6.5.1. Find the collected items

6.5.2. Retrieve association rules and order them


according to confidence

6.5.3. Displaying the recs

6.5.4. Implementation evaluation

Summary

2. Recommender algorithms

Chapter 7. Finding similarities among users and among


content

7.1. Why similarity?

7.1.1. What’s a similarity function?

7.2. Essential similarity functions

7.2.1. Jaccard distance

7.2.2. Measuring distance with Lp-norms

7.2.3. Cosine similarity


7.2.4. Finding similarity with Pearson’s correlation
coefficient

7.2.5. Test running a Pearson similarity

7.2.6. Pearson correlation is similar to cosine

7.3. k-means clustering

7.3.1. The k-means clustering algorithm

7.3.2. Translating k-means clustering into Python

7.4. Implementing similarities

7.4.1. Implementing the similarity in the


MovieGEEKs site

7.4.2. Implementing the clustering in the


MovieGEEKs site

Summary

Chapter 8. Collaborative filtering in the neighborhood

8.1. Collaborative filtering: A history lesson

8.1.1. When information became collaboratively


filtered

8.1.2. Helping each other

8.1.3. The rating matrix

8.1.4. The collaborative filtering pipeline


8.1.5. Should you use user-user or item-item
collaborative filtering?

8.1.6. Data requirements

8.2. Calculating recommendations

8.3. Calculating similarities

8.4. Amazon’s algorithm to precalculate item similarity

Beware of the 1 or 2 items in common problem

8.5. Ways to select the neighborhood

Clustering

Top-N

Threshold

8.6. Finding the right neighborhood

8.7. Ways to calculate predicted ratings

House price (regression)

Friendly voters (classification)

8.8. Prediction with item-based filtering

8.8.1. Computing item predictions

8.9. Cold-start problems

8.10. A few words on machine learning terms


8.11. Collaborative filtering on the MovieGEEKs site

8.11.1. Item-based filtering

8.12. What’s the difference between association rule recs


and collaborative recs?

8.13. Levers to fiddle with for collaborative filtering

8.14. Pros and cons of collaborative filtering

Summary

Chapter 9. Evaluating and testing your recommender

9.1. Business wants lift, cross-sales, up-sales, and


conversions

9.2. Why is it important to evaluate?

Hypothesis

9.3. How to interpret user behavior

9.4. What to measure

9.4.1. Understanding my taste: Minimizing


prediction error

9.4.2. Diversity

9.4.3. Coverage

9.4.4. Serendipity

9.5. Before implementing the recommender...


9.5.1. Verify the algorithm

9.5.2. Regression testing

9.6. Types of evaluation

9.7. Offline evaluation

9.7.1. What to do when the algorithm doesn’t


produce any recommendations

9.8. Offline experiments

Measuring error metrics

Measuring decision-support metrics

Precision at k

Measuring ranking metrics

Mean Average Precision (MAP)

Discounted cumulative gain

Normalized discounted cumulative gain

9.8.1. Preparing the data for the experiment

9.9. Implementing the experiment in MovieGEEKs

9.9.1. The to-do list

9.10. Evaluating the test set

9.10.1. Starting out with the baseline predictor


9.10.2. Finding the right parameters

9.11. Online evaluation

9.11.1. Controlled experiments

9.11.2. A/B testing

9.12. Continuous testing with exploit/explore

9.12.1. Feedback loops

Summary

Chapter 10. Content-based filtering

10.1. Descriptive example

10.2. Content-based filtering

10.3. Content analyzer

10.3.1. Feature extraction for the item profile

10.3.2. Categorical data with small numbers

10.3.3. Converting the year to a comparable feature

10.4. Extracting metadata from descriptions

10.4.1. Preparing descriptions

10.5. Finding important words with TF-IDF

10.6. Topic modeling using the LDA

Generative model example


Generating the topics

Gibbs sampling

LDA model

The corpus Wikipedia

Adding features and tags to documents

10.6.1. What knobs can you turn to tweak the LDA?

10.7. Finding similar content

10.8. Creating the user profile

10.8.1. Creating the user profile with LDA

10.8.2. Creating the user profile with TF-IDF

10.9. Content-based recommendations in MovieGEEKs

10.9.1. Loading data

10.9.2. Training the model

10.9.3. Creating item profiles

10.9.4. Creating user profiles

10.9.5. Showing recommendations

10.10. Evaluation of the content-based recommender

10.11. Pros and cons of content-based filtering

Summary
Chapter 11. Finding hidden genres with matrix factorization

11.1. Sometimes it’s good to reduce the amount of data

11.2. Example of what you want to solve

11.3. A whiff of linear algebra

11.3.1. Matrix

11.3.2. What’s factorization?

11.4. Constructing the factorization using SVD

Diagonal matrix

Reducing the matrix

How much should the matrix be reduced?

Predict a rating

Solving the problem of the zeros in the rating matrix


using imputation

11.4.1. Adding a new user by folding in

11.4.2. How to do recommendations with SVD

11.4.3. Baseline predictors

11.4.4. Temporal dynamic

11.5. Constructing the factorization using Funk SVD

11.5.1. Root Mean Squared Error


11.5.2. Gradient descent

11.5.3. Stochastic gradient descent

11.5.4. And finally, to the factorization

11.5.5. Adding biases

11.5.6. How to start and when to stop

11.6. Doing recommendations with Funk SVD

Brute force recommendation calculation

Neighborhoods recommendation calculation

User vector

The items the user likes

11.7. Funk SVD implementation in MovieGEEKs

Training phase

How many iterations are needed to run the training?

Saving the model

Online phase

11.7.1. What to do with outliers

11.7.2. Keeping the model up to date

11.7.3. Faster implementation

11.8. Explicit vs. implicit data


11.9. Evaluation

11.10. Levers to fiddle with for Funk SVD

Summary

Chapter 12. Taking the best of all algorithms: Implementing


hybrid recommenders

12.1. The confused world of hybrids

12.2. The monolithic

12.2.1. Mixing content-based features with


behavioral data to improve collaborative filtering
recommenders

12.3. Mixed hybrid recommender

12.4. The ensemble

12.4.1. Switched ensemble recommender

12.4.2. Weighted ensemble recommender

12.4.3. Linear regression

12.5. Feature-weighted linear stacking (FWLS)

12.5.1. Meta features: Weights as functions

12.5.2. The algorithm

12.6. Implementation

Loading the data


Splitting the data

Training the featured recommenders

Generating predictions for each of the training data


points

Executing each feature-weighted function on all


training data points

For each training data point, calculate the product


between each predicted rating with each function

Feature-weighted function result

The online recommendation prediction

How does the hybrid compare?

Testing the hybrid on the test set

Summary

Chapter 13. Ranking and learning to rank

13.1. Learning to rank an example at Foursquare

13.2. Re-ranking

13.3. What’s learning to rank again?

13.3.1. The three types of LTR algorithms

13.4. Bayesian Personalized Ranking

Task to solve
If you have implicit data

With explicit data sets

The training data set

13.4.1. Ranking with BPR

13.4.2. Math magic (advanced wizardry)

13.4.3. The BPR algorithm

13.4.4. BPR with matrix factorization

13.5. Implementation of BPR

Transforming your ratings to data usable to BPR

LearnBPR method

Draw method

13.5.1. Doing the recommendations

13.6. Evaluation

13.7. Levers to fiddle with for BPR

Summary

Chapter 14. Future of recommender systems

14.1. This book in a few sentences

14.2. Topics to study next

14.2.1. Further reading


14.2.2. Algorithms

14.2.3. Context

14.2.4. Human-computer interactions

14.2.5. Choosing a good architecture

14.3. What’s the future of recommender systems?

User profiles

context

Algorithms

Privacy

Architecture

Surprising recommendations

14.4. Final thoughts

Index

List of Figures

List of Tables

List of Listings
Preface
When I finished university in 2003, it was with the threat that
no computer scientists would be needed in Europe because
everything would be developed in countries where salaries were
much lower. That never materialized, thank goodness, for many
reasons. I’d venture that one of the larger issues was that
companies underestimated the problem of developers not
understanding the culture where their software was going to
run. Software requests were implemented, but the functionality
was different from what customers expected.

Today, there’s a similar menace for people interested in


machine learning and data science. But now the threat is not
low salaries, but software as a service (SaaS), where you upload
data and then the system does the work for you.

I’m as concerned as anyone else that machines don’t


understand domains and people. Machines aren’t intelligent
enough yet that you can take humans out of the equation.
Things are moving quickly, but I venture that anyone who is
reading this book will be able to work with recommenders until
the end of their career.

Where did I drop into the mix? I was working as a software


engineer in Italy and was moving to England and needed a job
that required more thought than doing CRUD operations on a
database. Luckily, I was contacted by a great recruiter from
RedRock Consulting Ltd. They matched me with a
recommender system provider, where I worked on the engine.
And that was it; I was lost in machine learning (“lost” in the
sense of being really interested and engaged). In addition to
working on recommender systems, I also started trawling for
knowledge on the internet and read myriad books on the subject
and related topics.

Today you can’t throw a stick without having at least 10 people


try to teach you something about machine learning. I find it
amusing when I see one-page or one-hour tutorials that claim to
teach you all you need to know about machine learning. I can
create a similarly effective tutorial on how to be a fighter pilot:

You take off and you fly using the stick. If you need to shoot,
you press a button. Then, you land before you run out of gas.

A fighter pilot tutorial like that will probably be great to get you
started—it’s where I started. But don’t fool yourself:
understanding machine learning is complex. Add to that the
human factor, which always makes things a bit wobblier.

To get back to my story, I worked with recommenders and was


happy about it, and then I changed jobs. In my new position, I
was supposed to continue working on recommender systems,
but that project was delayed. At that point I was nervous I
wouldn’t be working with recommenders anymore, but that was
when Manning offered me the opportunity to write a book
about recommender systems. What could I do, other than jump
at the task? Immediately after I signed the contract, the
recommender project started after all. Writing this book has
been a great learning experience, and I hope you’ll benefit from
and enjoy it.

The goal of the book is to introduce you to recommender


systems—not only the algorithms, but also the recommender
system ecosystem. The algorithms aren’t too complex, but to
understand and run them requires understanding the users who
are to receive the recommendations. The book’s contents have
evolved during writing, because I’ve tried to fit more and more
Another random document with
no related content on Scribd:
terrible gossip and busybody was she, talking perpetually and doing
all the mischief that lay in her power. She was the terror and torment
of all cats and kittens; for, wary and watchful as they might be, Polly
was always surprising them by attacks in the rear, and cunning
ambuscades and flank movements. Nothing more still and soft-
footed could be imagined than her approaches; nothing more sly,
sudden, and sharp than the nips she gave with her horrid hooked
bill. A cat’s extended tail was especially tempting to her. She
generally fought the battle out on that line. “In maiden meditation
fancy free,” this parrot roamed about the yard, and laughed and
railed at patient sitting hens, and the proud mothers of newly
hatched chicks and ducklings. Sometimes she would follow a brood
about, sneering and advising, until the poor mother was in an agony
of worriment. At last she came to grief in this way. A spirited
speckled hen, with a fine brood of young ones, tired of being
snubbed and of hearing her offspring depreciated, and shocked at
seeing the domestic virtues set at naught by a flaunting foreign fowl
of infidel sentiments, turned upon her, sprang upon her back, and
began pecking and tearing at her sleek plumage like mad! The
feathers fell all around, like a shower of green snow; and the parrot
began screaming with all her might: “Let up! Let up! Poor Polly! Poor
Polly!”
Her mistress came to the rescue, and Polly skulked away to her
cage, where she remained several days, sullen and deeply
humiliated; but when she emerged from her retirement she gave the
hens and chickens a wide berth.
Several parrots, the pets and companions of religious persons, have
been distinguished by their piety, or what passed for such. These
have usually belonged to devout Catholics. I have read of one,
named Vert-Vert,—the inmate of a convent in France, and taught by
the holy nuns,—who was esteemed a most blessed and
miraculously gifted bird. His fame spread far and wide. Many made
pilgrimages to the convent to be edified by his pious exhortations;
and at last the nuns of another convent, in a distant province,
solicited the loan of him for a few months, for the good of their souls.
He went forth as a sort of feathered apostle, followed by the prayers
and blessings of the bereaved sisters, and looking very solemn and
important. But, unfortunately, on his journey, he was compelled to
spend a night on a steamer; and being kept awake by such new
scenes, and perhaps a little sea-sickness, he listened too much to
the unprofitable and profane talk of the sailors and some soldiers
who were on board. And so it happened that, when he reached the
convent, where he was received with great joy and impressive
religious ceremonies, instead of edifying the good sisters with
exhortations and chants, delivered in a grave, decorous manner, he
horrified them by shouting like a rough old sea-captain and swearing
like a major-general, while he assumed the most knowing, rollicking
air imaginable. Those saintly women stopped their ears, and fled
from him as though he had been a demon-bird, and he was
immediately sent home in utter disgrace. There, through fasts and
penances, he was brought round to more correct habits and
behavior; but he never became the shining light he had been before
his sudden fall. No more pilgrimages were made to his perch.
Though grown a sadder and a wiser bird, it was impossible to tell
whether he most sorrowed for his fault or regretted the wicked world
of which he had had a taste. Still he made a good end, I believe,
within the convent’s hallowed cloisters.
A certain pious cardinal in Rome once gave a hundred crowns in
gold for a parrot that could repeat the Apostles’ Creed. Another
religiously trained parrot once served as a chaplain on board of a
ship,—actually reciting the service for the sailors, who listened and
responded with becoming solemnity. I have never seen a clerical
parrot; but I have seen clergymen who suggested parrots. By the
way, the parrot would make a very economical sort of minister. After
the first cost of the bird, his education, and a respectable cage or
parsonage, there would be no demands on the congregation for
increase of salary. As he would have no scruples about repeating old
sermons, he would not desire new fields of labor. Parrots seldom
have any family, so he would expect no donation-parties. They never
have dyspepsia, so he would require no trips to Europe. He would
not, I fear, be very popular in the sewing-circles and Dorcas
societies,—for he would talk down all the ladies.
A dear young friend of ours has a lovely pair of turtle-doves, that are
constantly making love to each other, these soft spring days, in that
delicious, drowsy honey-moon coo, “most musical, most
melancholy.”
Awhile ago the disastrous experiment was tried, of putting these
doves into the cage with a parrot. Miss Polly did not fancy her dainty
visitors in the least. She glared at them as they cuddled together in a
corner, eying her askance, and murmuring in the sweet dove dialect,
—Madame Columba very timidly, and Monsieur in a tender,
reassuring tone. Miss Polly abominated such soft, love-sick voices,
and such a parade of matrimonial bliss and affection just
exasperated her; so she pitched into them, scolding fearfully at first,
but soon coming to blows with her wings, then to scratching and
pecking with her steel-like claws and fearful, hooked bill. When the
hapless pair were rescued, it was found that the husband, who had
fought gallantly to protect his wife, had met with a serious loss, in the
upper part of his bill, which had been quite bitten off by that
inhospitable old termagant, who had doubtless thought thus to put
an end to his billing and cooing.
The poor fellow lost some glossy feathers in this encounter. They
have been replaced, but the broken beak has never been restored.
Thus maimed, he is only able to drink from a perfectly full cup, and
his loving mate invariably stands back till his thirst is satisfied. She
also feeds him when he has difficulty in eating, and always carefully
plumes him, as he can no longer perform that service for himself.
Indeed, she attends to his toilet before her own. No fond wife of a
disabled soldier could surpass her in watchful care and devotion.
What a touching little lesson is this, of tender, faithful love! I wonder if
he would have done as much for her. Let us hope so.

THE BENEVOLENT SHANGHAI.


I have long wished to record the admirable behavior of a certain
Shanghai rooster, once belonging to a relative of ours in the West.
This fowl was old, but he was tender; he was ugly, but he was
virtuous, as you shall see. One of the hens of his flock died suddenly
and mysteriously,—of too many family cares, perhaps, for she left a
brood of twelve hearty, clamorous young chickens. One of the
children, the poet of the family, said:—
“Grandfather Shanghai
Stood sadly by,
And saw her die,
With a tear in his eye.”
Perhaps he received her last instructions,—her dying bequest. If so,
never was a legatee more burdened with responsibilities; for from
that hour the good rooster adopted all those chickens, and devoted
himself to them. When the fowls were fed, he guarded their portion;
he watched over them when hawks were hovering near; he
scratched and fought for them and stalked around after them all day,
and at night, after leading the other fowls to roost, he would descend
from the old pear-tree, gather those poor sleepy little things under
him, and do his best to brood them. His legs were so long and stiff
that it was a difficult job. First he would droop one wing down to
shelter them; then, seeing that they were exposed on the other side,
would let down the other. Then, finding that he could not keep both
down at once, he would try to crouch lower, and would sometimes tip
himself entirely over. It was a laughable sight, I assure you. But
somehow he managed to keep them warm, to feed them, and bring
them up in the way they should go; and I hope they always loved
him, and never made fun of their gaunt, ungainly old guardian, when
they grew up, and went among the other young people of the farm-
yard, especially when chatting with the foreign fowls, the proud
Spanish hens, and the pretty Dorking pullets.

THE GALLANT BANTAM.


I have observed that while the Bantam pullet is a quiet, modest, little
pantaletted lady, the Bantam cockerel always makes up in big feeling
for what he lacks in size. A gentleman farmer owned a Bantam of
this sort, that was always full and bubbling over with fight. He would
go at any gentleman-fowl in the yard, with beak and spur. He would
defy the fiercest old gander, and challenge the biggest “cock of the
walk” to mortal combat. At last he grew so uncomfortably
quarrelsome, and presented such a disreputable appearance,—
having had the best part of his tail-feathers torn out, and his spurs
broken off,—that his master was obliged to put him out to board with
a nice old lady who had no fighting fowls for him to contend with. It
was hoped that he would be content to tarry in that Jericho until his
tail-feathers should be grown; but one day, when his master paid a
visit to his good neighbor, he found the little Bantam with his head
badly swollen, and with a patch over one eye and across his beak,
placed there by the kind old lady. He had gone outside the yard, and
picked a quarrel with a strange rooster, only about six times his size,
and been pretty badly punished.
A short time after, a big turkey gobbler was added to the feathered
community of that farm-yard, the old lady not dreaming of the
Bantam cock daring to make hostile demonstrations against such a
potentate. But she had done our little hero injustice. As soon as he
saw the mighty spread the arrogant old fellow was making, he just
gathered himself up, and “went for him,” if I may use a slang
expression, which I know boys, at least, will understand only too
well.
The big gobbler looked down upon him at first in contemptuous
astonishment, as much as to say, “What fooling is this?” But when he
saw that the fiery little fellow was in earnest, he just struck him one
blow with his terrible wing, and—well, the gallant Bantam went “on
his raids no more.” He was served as another savage Turkey served
poor Crete. This is a world of tragedies and downfalls.
On a late visit to the Central Park, we noticed, among the collection
of fowls there, a Bantam cock, of the very smallest pattern, that yet
seemed to have a big, gallant heart. We saw him in one of his soft
moments, when, in fact, he was making love. He had been very
ambitious in selecting the object of his adoration, for he was actually
paying his addresses to a full-sized Shanghai hen, who was in a
large cage, separated from him by a light lattice. He would strut up
and down before her, ruffling his fine feathers, and making eyes at
her. Sometimes he would dance up sideways, declaring his passion
with a soft, musical murmur, that sounded like “coort, coort,” which it
would seem she could hardly resist; but she did,—not so much as a
feather on her breast was stirred by his appeal; she regarded him in
placid disdain. Indeed, it was almost as funny to watch the tiny,
strutting little creature making love to that superior fowl, as it would
be to see Commodore Nutt courting Miss Swan, the giantess.
“So daring in love and so dauntless in war,
Have ye e’er heard of knight like the young Lochinvar?”

THE DISOWNED CHICKS.


I have a friend living in the very heart of the big city of Chicago, who
owns several hens of rare varieties, and a flock of young chickens of
remarkable promise. She keeps them in her back-yard, which they
utterly devastate, not suffering a green thing to live, making it look
like a small copy of the Desert of Sahara. Yet she says keeping them
reminds her of the country! She is a very poetic and imaginative lady.
It is very likely that a hand-organ reminds her of music, and fish-balls
of the mighty, briny deep.
One of this good lady’s hens is a handsome, stately fowl, dressed in
gray satin, and wearing a top-knot that is like a crown of silver. She
has one chicken, almost full-grown,—the last of many lively children,
the victims of rats and the pip. Of him she is very fond. There was, at
one time, great danger that he would be spoiled,—for she toiled for
him all day, trotting about everywhere with him “at her apron-strings,”
so to speak; and she actually broods him at night, though, do the
best she can in spreading herself, she can’t take in all of his tail,
unless she lets his head stick out somewhere. Thus he is content to
sleep ingloriously, when he ought to be roosting on some lofty perch,
ready to greet the first streak of dawn with a brave crow, prophetic of
the day.
A few weeks ago another hen, a young pullet, dressed gayly every
day in gold and brown, with a gorgeous top-knot, came, one
morning, triumphantly out from under the porch, with a large flock of
charming little chicklings, who toddled along after her, and glanced
up at the sky, and round on the earth,—that vast sandy plain of the
back-yard,—in a most knowing and patronizing manner. Nobody
would have guessed it was their first day out of the shell. They were
not going to show their greenness,—not they.
For a while those downy, yellow, cunning little roly-poly creatures
seemed to amuse their mother; she appeared fond of them, taking
pleasure in parading them before such of her neighbors as were
chickenless. But she was a giddy biddy, lazy and selfish; so, as soon
as she found that she must scratch to fill so many little crops, she
threw up maternity in disgust. She actually cast off her whole brood,
pecked at them, and scolded them till they ran from her in fright, and
huddled together in a corner of the fence, peeping piteously, and
doubtless wishing they had never been hatched. Perhaps some
were chicken-hearted enough to wish for death to end their troubles,
till they caught sight of some ugly old rat prowling about “seeking
whom he might devour,” when they reconsidered the matter, and
took a more cheerful view of life.
Well, it came to pass that the excellent gray hen, with the one big
chicken, seeing their forlorn condition, pitied them exceedingly, and
actually adopted the whole flock. Only think, children, it was as
though your mother should adopt a small orphan asylum, and all of
them twins!
She toils for them and protects them all day, treating them in all
respects as her own chicks, till sundown; then, not having room for
them under her wings without dislodging her only son and heir, she
always escorts them up the steps of the porch and sees them go to
bed in a little box, which has been prepared for them by their kind
mistress, with a cover of slats to guard them from rats and cats and
bats and owls, and every thing that prowls or lies in wait for small
fowls. Well, when she has seen the last chick tumble in, and cuddle
down to its place with a sleepy good-night “peep,” to be brooded
under the invisible wings of the soft summer night, that good,
motherly creature descends with stately dignity from the porch to her
own sleeping apartment underneath, when she mounts on a box,
and, calling her one long-legged darling, does her best to hover him,
and to make believe he is a baby-chicken still. In the morning she is
astir betimes, scratching and pecking for him and his adopted
brothers and sisters with wonderful impartiality. I must do this same
big chicken the justice to say that he has never made any violent
opposition to this sudden addition to the family; but he has rather a
haughty manner towards the little interlopers, and could we
understand the sort of Chickasaw language he speaks, we might find
him occasionally remonstrating with his maternal parent in this wise:
“Really, mother, it strikes me you are running your benevolence into
the ground, in scratching your nails off for a lot of other hen’s
chickens! such things don’t pay, ma’am; charity begins at home, and
one would think you had enough on your claws, in providing for the
wants of a growing young cockerel like me, without doing missionary
work. Besides, you are encouraging idleness and shiftlessness; it
just sticks in my crop to have you burden yourself with the cast-off
responsibilities of that impudent pullet, who goes cawking lazily
about, carrying her top-knot as high as ever.”
The conduct of that unnatural young mother is, indeed,
reprehensible. At meal-times she always comes elbowing her way
through the crowd of her virtuous neighbors, to secure the largest
share of corn-mush, not hesitating to rob her own children! She will
be likely to have a disturbing and demoralizing influence on the
female feathered community. She shirks her duties,—declines to lay
eggs lest chickens should come of them. She believes the chicken
population is too large already for the average supply of chickweed
and grubworms. She discourages nest-making, and despises her
weak-minded sisters, who, in spite of her warning, persist in laying,
sitting, and hatching; who really believe in the innocence of
chickenhood, and actually love to brood their chicks, to feel the soft
little things stir against their breasts, and to hear now and then, in the
still, dark night, their drowsy “peep, peep.” She goes against all such
silly sentiment and loving slavery. She pities any poor pullet who has
to spend her days in a coop, especially in Chicago. She is a sort of
hen-emancipator, and strolls about at “her own sweet will,” “in
maiden meditation, fancy free.”
If she could have the management of the hatchway, all chickens
would be hatched with equal rights to wear the spur, and with equal
gifts of crest and crow; all hatching would be done by steam, in a
general incubatorium at government expense, in a way to astonish
all grandmother Biddies; sittings would be abolished, coops levelled
to the earth, and the sound of the cluck be heard no more in the
land.
As for the poor cast-off chicks, they grow and thrive, get more steady
on their legs, and put out tiny tail-feathers, tinged with gold, as the
bright summer days go on. They doubtless think that their first
mother was a mistake, and that their second mother is the certain
true one, and honor her silver top-knot accordingly.
So you see, dear children, there is a Providence for little chickens,
as well as for little sparrows.
THE END.

Cambridge: Printed by Welch, Bigelow, & Co.


TRANSCRIBER’S NOTES:
Obvious typographical errors have been corrected.
Inconsistencies in hyphenation have been
standardized.
Archaic or variant spelling has been retained.
*** END OF THE PROJECT GUTENBERG EBOOK HISTORY OF
MY PETS ***

Updated editions will replace the previous one—the old editions


will be renamed.

Creating the works from print editions not protected by U.S.


copyright law means that no one owns a United States copyright
in these works, so the Foundation (and you!) can copy and
distribute it in the United States without permission and without
paying copyright royalties. Special rules, set forth in the General
Terms of Use part of this license, apply to copying and
distributing Project Gutenberg™ electronic works to protect the
PROJECT GUTENBERG™ concept and trademark. Project
Gutenberg is a registered trademark, and may not be used if
you charge for an eBook, except by following the terms of the
trademark license, including paying royalties for use of the
Project Gutenberg trademark. If you do not charge anything for
copies of this eBook, complying with the trademark license is
very easy. You may use this eBook for nearly any purpose such
as creation of derivative works, reports, performances and
research. Project Gutenberg eBooks may be modified and
printed and given away—you may do practically ANYTHING in
the United States with eBooks not protected by U.S. copyright
law. Redistribution is subject to the trademark license, especially
commercial redistribution.

START: FULL LICENSE


THE FULL PROJECT GUTENBERG LICENSE
PLEASE READ THIS BEFORE YOU DISTRIBUTE OR USE THIS WORK

To protect the Project Gutenberg™ mission of promoting the


free distribution of electronic works, by using or distributing this
work (or any other work associated in any way with the phrase
“Project Gutenberg”), you agree to comply with all the terms of
the Full Project Gutenberg™ License available with this file or
online at www.gutenberg.org/license.

Section 1. General Terms of Use and


Redistributing Project Gutenberg™
electronic works
1.A. By reading or using any part of this Project Gutenberg™
electronic work, you indicate that you have read, understand,
agree to and accept all the terms of this license and intellectual
property (trademark/copyright) agreement. If you do not agree to
abide by all the terms of this agreement, you must cease using
and return or destroy all copies of Project Gutenberg™
electronic works in your possession. If you paid a fee for
obtaining a copy of or access to a Project Gutenberg™
electronic work and you do not agree to be bound by the terms
of this agreement, you may obtain a refund from the person or
entity to whom you paid the fee as set forth in paragraph 1.E.8.

1.B. “Project Gutenberg” is a registered trademark. It may only


be used on or associated in any way with an electronic work by
people who agree to be bound by the terms of this agreement.
There are a few things that you can do with most Project
Gutenberg™ electronic works even without complying with the
full terms of this agreement. See paragraph 1.C below. There
are a lot of things you can do with Project Gutenberg™
electronic works if you follow the terms of this agreement and
help preserve free future access to Project Gutenberg™
electronic works. See paragraph 1.E below.
1.C. The Project Gutenberg Literary Archive Foundation (“the
Foundation” or PGLAF), owns a compilation copyright in the
collection of Project Gutenberg™ electronic works. Nearly all the
individual works in the collection are in the public domain in the
United States. If an individual work is unprotected by copyright
law in the United States and you are located in the United
States, we do not claim a right to prevent you from copying,
distributing, performing, displaying or creating derivative works
based on the work as long as all references to Project
Gutenberg are removed. Of course, we hope that you will
support the Project Gutenberg™ mission of promoting free
access to electronic works by freely sharing Project
Gutenberg™ works in compliance with the terms of this
agreement for keeping the Project Gutenberg™ name
associated with the work. You can easily comply with the terms
of this agreement by keeping this work in the same format with
its attached full Project Gutenberg™ License when you share it
without charge with others.

1.D. The copyright laws of the place where you are located also
govern what you can do with this work. Copyright laws in most
countries are in a constant state of change. If you are outside
the United States, check the laws of your country in addition to
the terms of this agreement before downloading, copying,
displaying, performing, distributing or creating derivative works
based on this work or any other Project Gutenberg™ work. The
Foundation makes no representations concerning the copyright
status of any work in any country other than the United States.

1.E. Unless you have removed all references to Project


Gutenberg:

1.E.1. The following sentence, with active links to, or other


immediate access to, the full Project Gutenberg™ License must
appear prominently whenever any copy of a Project
Gutenberg™ work (any work on which the phrase “Project
Gutenberg” appears, or with which the phrase “Project
Gutenberg” is associated) is accessed, displayed, performed,
viewed, copied or distributed:

This eBook is for the use of anyone anywhere in the United


States and most other parts of the world at no cost and with
almost no restrictions whatsoever. You may copy it, give it
away or re-use it under the terms of the Project Gutenberg
License included with this eBook or online at
www.gutenberg.org. If you are not located in the United
States, you will have to check the laws of the country where
you are located before using this eBook.

1.E.2. If an individual Project Gutenberg™ electronic work is


derived from texts not protected by U.S. copyright law (does not
contain a notice indicating that it is posted with permission of the
copyright holder), the work can be copied and distributed to
anyone in the United States without paying any fees or charges.
If you are redistributing or providing access to a work with the
phrase “Project Gutenberg” associated with or appearing on the
work, you must comply either with the requirements of
paragraphs 1.E.1 through 1.E.7 or obtain permission for the use
of the work and the Project Gutenberg™ trademark as set forth
in paragraphs 1.E.8 or 1.E.9.

1.E.3. If an individual Project Gutenberg™ electronic work is


posted with the permission of the copyright holder, your use and
distribution must comply with both paragraphs 1.E.1 through
1.E.7 and any additional terms imposed by the copyright holder.
Additional terms will be linked to the Project Gutenberg™
License for all works posted with the permission of the copyright
holder found at the beginning of this work.

1.E.4. Do not unlink or detach or remove the full Project


Gutenberg™ License terms from this work, or any files
containing a part of this work or any other work associated with
Project Gutenberg™.
1.E.5. Do not copy, display, perform, distribute or redistribute
this electronic work, or any part of this electronic work, without
prominently displaying the sentence set forth in paragraph 1.E.1
with active links or immediate access to the full terms of the
Project Gutenberg™ License.

1.E.6. You may convert to and distribute this work in any binary,
compressed, marked up, nonproprietary or proprietary form,
including any word processing or hypertext form. However, if
you provide access to or distribute copies of a Project
Gutenberg™ work in a format other than “Plain Vanilla ASCII” or
other format used in the official version posted on the official
Project Gutenberg™ website (www.gutenberg.org), you must, at
no additional cost, fee or expense to the user, provide a copy, a
means of exporting a copy, or a means of obtaining a copy upon
request, of the work in its original “Plain Vanilla ASCII” or other
form. Any alternate format must include the full Project
Gutenberg™ License as specified in paragraph 1.E.1.

1.E.7. Do not charge a fee for access to, viewing, displaying,


performing, copying or distributing any Project Gutenberg™
works unless you comply with paragraph 1.E.8 or 1.E.9.

1.E.8. You may charge a reasonable fee for copies of or


providing access to or distributing Project Gutenberg™
electronic works provided that:

• You pay a royalty fee of 20% of the gross profits you derive from
the use of Project Gutenberg™ works calculated using the
method you already use to calculate your applicable taxes. The
fee is owed to the owner of the Project Gutenberg™ trademark,
but he has agreed to donate royalties under this paragraph to
the Project Gutenberg Literary Archive Foundation. Royalty
payments must be paid within 60 days following each date on
which you prepare (or are legally required to prepare) your
periodic tax returns. Royalty payments should be clearly marked
as such and sent to the Project Gutenberg Literary Archive
Foundation at the address specified in Section 4, “Information
about donations to the Project Gutenberg Literary Archive
Foundation.”

• You provide a full refund of any money paid by a user who


notifies you in writing (or by e-mail) within 30 days of receipt that
s/he does not agree to the terms of the full Project Gutenberg™
License. You must require such a user to return or destroy all
copies of the works possessed in a physical medium and
discontinue all use of and all access to other copies of Project
Gutenberg™ works.

• You provide, in accordance with paragraph 1.F.3, a full refund of


any money paid for a work or a replacement copy, if a defect in
the electronic work is discovered and reported to you within 90
days of receipt of the work.

• You comply with all other terms of this agreement for free
distribution of Project Gutenberg™ works.

1.E.9. If you wish to charge a fee or distribute a Project


Gutenberg™ electronic work or group of works on different
terms than are set forth in this agreement, you must obtain
permission in writing from the Project Gutenberg Literary
Archive Foundation, the manager of the Project Gutenberg™
trademark. Contact the Foundation as set forth in Section 3
below.

1.F.

1.F.1. Project Gutenberg volunteers and employees expend


considerable effort to identify, do copyright research on,
transcribe and proofread works not protected by U.S. copyright
law in creating the Project Gutenberg™ collection. Despite
these efforts, Project Gutenberg™ electronic works, and the
medium on which they may be stored, may contain “Defects,”
such as, but not limited to, incomplete, inaccurate or corrupt
data, transcription errors, a copyright or other intellectual
property infringement, a defective or damaged disk or other
medium, a computer virus, or computer codes that damage or
cannot be read by your equipment.

1.F.2. LIMITED WARRANTY, DISCLAIMER OF DAMAGES -


Except for the “Right of Replacement or Refund” described in
paragraph 1.F.3, the Project Gutenberg Literary Archive
Foundation, the owner of the Project Gutenberg™ trademark,
and any other party distributing a Project Gutenberg™ electronic
work under this agreement, disclaim all liability to you for
damages, costs and expenses, including legal fees. YOU
AGREE THAT YOU HAVE NO REMEDIES FOR NEGLIGENCE,
STRICT LIABILITY, BREACH OF WARRANTY OR BREACH
OF CONTRACT EXCEPT THOSE PROVIDED IN PARAGRAPH
1.F.3. YOU AGREE THAT THE FOUNDATION, THE
TRADEMARK OWNER, AND ANY DISTRIBUTOR UNDER
THIS AGREEMENT WILL NOT BE LIABLE TO YOU FOR
ACTUAL, DIRECT, INDIRECT, CONSEQUENTIAL, PUNITIVE
OR INCIDENTAL DAMAGES EVEN IF YOU GIVE NOTICE OF
THE POSSIBILITY OF SUCH DAMAGE.

1.F.3. LIMITED RIGHT OF REPLACEMENT OR REFUND - If


you discover a defect in this electronic work within 90 days of
receiving it, you can receive a refund of the money (if any) you
paid for it by sending a written explanation to the person you
received the work from. If you received the work on a physical
medium, you must return the medium with your written
explanation. The person or entity that provided you with the
defective work may elect to provide a replacement copy in lieu
of a refund. If you received the work electronically, the person or
entity providing it to you may choose to give you a second
opportunity to receive the work electronically in lieu of a refund.
If the second copy is also defective, you may demand a refund
in writing without further opportunities to fix the problem.

1.F.4. Except for the limited right of replacement or refund set


forth in paragraph 1.F.3, this work is provided to you ‘AS-IS’,
WITH NO OTHER WARRANTIES OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO
WARRANTIES OF MERCHANTABILITY OR FITNESS FOR
ANY PURPOSE.

1.F.5. Some states do not allow disclaimers of certain implied


warranties or the exclusion or limitation of certain types of
damages. If any disclaimer or limitation set forth in this
agreement violates the law of the state applicable to this
agreement, the agreement shall be interpreted to make the
maximum disclaimer or limitation permitted by the applicable
state law. The invalidity or unenforceability of any provision of
this agreement shall not void the remaining provisions.

1.F.6. INDEMNITY - You agree to indemnify and hold the


Foundation, the trademark owner, any agent or employee of the
Foundation, anyone providing copies of Project Gutenberg™
electronic works in accordance with this agreement, and any
volunteers associated with the production, promotion and
distribution of Project Gutenberg™ electronic works, harmless
from all liability, costs and expenses, including legal fees, that
arise directly or indirectly from any of the following which you do
or cause to occur: (a) distribution of this or any Project
Gutenberg™ work, (b) alteration, modification, or additions or
deletions to any Project Gutenberg™ work, and (c) any Defect
you cause.

Section 2. Information about the Mission of


Project Gutenberg™
Project Gutenberg™ is synonymous with the free distribution of
electronic works in formats readable by the widest variety of
computers including obsolete, old, middle-aged and new
computers. It exists because of the efforts of hundreds of
volunteers and donations from people in all walks of life.

Volunteers and financial support to provide volunteers with the


assistance they need are critical to reaching Project
Gutenberg™’s goals and ensuring that the Project Gutenberg™
collection will remain freely available for generations to come. In
2001, the Project Gutenberg Literary Archive Foundation was
created to provide a secure and permanent future for Project
Gutenberg™ and future generations. To learn more about the
Project Gutenberg Literary Archive Foundation and how your
efforts and donations can help, see Sections 3 and 4 and the
Foundation information page at www.gutenberg.org.

Section 3. Information about the Project


Gutenberg Literary Archive Foundation
The Project Gutenberg Literary Archive Foundation is a non-
profit 501(c)(3) educational corporation organized under the
laws of the state of Mississippi and granted tax exempt status by
the Internal Revenue Service. The Foundation’s EIN or federal
tax identification number is 64-6221541. Contributions to the
Project Gutenberg Literary Archive Foundation are tax
deductible to the full extent permitted by U.S. federal laws and
your state’s laws.

The Foundation’s business office is located at 809 North 1500


West, Salt Lake City, UT 84116, (801) 596-1887. Email contact
links and up to date contact information can be found at the
Foundation’s website and official page at
www.gutenberg.org/contact

Section 4. Information about Donations to


the Project Gutenberg Literary Archive
Foundation
Project Gutenberg™ depends upon and cannot survive without
widespread public support and donations to carry out its mission
of increasing the number of public domain and licensed works
that can be freely distributed in machine-readable form

You might also like