72551
72551
https://ebookmeta.com/product/advanced-analytics-with-transact-
sql-exploring-hidden-patterns-and-rules-in-your-data-1st-edition-
dejan-sarka/
https://ebookmeta.com/product/advanced-analytics-with-transact-
sql-exploring-hidden-patterns-and-rules-in-your-data-1st-edition-
dejan-sarka-2/
https://ebookmeta.com/product/international-business-fourth-
edition-yadong-luo/
Services Liberalization in ASEAN Foreign Direct
Investment in Logistics 1st Edition Tham Siew Yean
https://ebookmeta.com/product/services-liberalization-in-asean-
foreign-direct-investment-in-logistics-1st-edition-tham-siew-
yean/
https://ebookmeta.com/product/entranced-guardian-academy-1-1st-
edition-jessica-sorensen/
https://ebookmeta.com/product/chocolate-truffles-and-trouble-
pacific-cove-cozy-mystery-03-samantha-silver-et-el/
https://ebookmeta.com/product/dividing-up-the-world-the-true-
story-of-our-international-borders-and-why-they-are-where-they-
are-1st-edition-paul-doe/
https://ebookmeta.com/product/eloquent-javascript-3rd-edition-a-
modern-introduction-to-programming-marijn-haverbeke/
Advanced Data
Analytics Using
Python
With Architectural Patterns,
Text and Image Classification,
and Optimization Techniques
Second Edition
Sayan Mukhopadhyay
Pratip Samanta
Advanced Data Analytics Using Python: With Architectural Patterns, Text
and Image Classification, and Optimization Techniques
v
Table of Contents
Normal Forms�����������������������������������������������������������������������������������������������������31
First Normal Form�����������������������������������������������������������������������������������������31
Second Normal Form�������������������������������������������������������������������������������������32
Third Normal Form����������������������������������������������������������������������������������������33
Elasticsearch�������������������������������������������������������������������������������������������������������35
Connection Layer API�������������������������������������������������������������������������������������38
Neo4j Python Driver��������������������������������������������������������������������������������������������39
neo4j-rest-client�������������������������������������������������������������������������������������������������39
In-Memory Database������������������������������������������������������������������������������������������40
MongoDB (Python Edition)����������������������������������������������������������������������������������40
Import Data into the Collection����������������������������������������������������������������������41
Create a Connection Using pymongo�������������������������������������������������������������42
Access Database Objects������������������������������������������������������������������������������42
Insert Data�����������������������������������������������������������������������������������������������������43
Update Data���������������������������������������������������������������������������������������������������43
Remove Data�������������������������������������������������������������������������������������������������43
Cloud Databases�������������������������������������������������������������������������������������������������43
Pandas����������������������������������������������������������������������������������������������������������������44
ETL with Python (Unstructured Data)������������������������������������������������������������������45
Email Parsing�������������������������������������������������������������������������������������������������45
Topical Crawling��������������������������������������������������������������������������������������������48
Summary������������������������������������������������������������������������������������������������������������52
vi
Table of Contents
Semi-Supervised Learning���������������������������������������������������������������������������������65
Decision Tree�������������������������������������������������������������������������������������������������������66
Which Attribute Comes First?������������������������������������������������������������������������66
Random Forest Classifier������������������������������������������������������������������������������68
Naïve Bayes Classifier�����������������������������������������������������������������������������������������68
Support Vector Machine��������������������������������������������������������������������������������������69
Nearest Neighbor Classifier��������������������������������������������������������������������������������71
Sentiment Analysis���������������������������������������������������������������������������������������������71
Image Recognition����������������������������������������������������������������������������������������������73
Regression with Python���������������������������������������������������������������������������������74
Least Square Estimation��������������������������������������������������������������������������������75
Logistic Regression���������������������������������������������������������������������������������������76
Classification and Regression�����������������������������������������������������������������������������76
Intentionally Bias the Model to Over-Fit or Under-Fit������������������������������������������77
Dealing with Categorical Data�����������������������������������������������������������������������������78
Summary������������������������������������������������������������������������������������������������������������79
vii
Table of Contents
viii
Table of Contents
ix
Table of Contents
Index�������������������������������������������������������������������������������������������������243
x
About the Authors
Sayan Mukhopadhyay has more than 13 years
of industry experience and has been associated
with companies such as Credit Suisse, PayPal,
CA Technologies, CSC, and Mphasis. He has
a deep understanding of applications for
data analysis in domains such as investment
banking, online payments, online advertising,
IT infrastructure, and retail. His area of
expertise is in applying high-performance
computing in distributed and data-driven
environments such as real-time analysis, high-
frequency trading, and so on.
He earned his engineering degree in electronics and instrumentation
from Jadavpur University and his master’s degree in research in
computational and data science from IISc in Bangalore.
xi
About the Technical Reviewer
Joos Korstanje is a data scientist with more
than five years of industry experience in
developing machine learning tools, of which a
large part is forecasting models. He currently
works at Disneyland Paris where he develops
machine learning for a variety of tools.
xiii
Acknowledgments
Thanks to Labonic Chakraborty (Ripa) and Soumili Chakraborty.
xv
Introduction
We are living in the data science/artificial intelligence era. To thrive in
this environment, where data drives decision-making in everything from
business to government to sports and entertainment, you need the skills
to manage and analyze huge amounts of data. Together we can use this
data to make the world better for everyone. In fact, humans have yet to find
everything we can do using this data. So, let us explore!
Our objective for this book is to empower you to become a leader
in this data-transformed era. With this book you will learn the skills to
develop AI applications and make a difference in the world.
This book is intended for advanced user, because we have incorporated
some advanced analytics topics. Important machine learning models and
deep learning models are explained with coding exercises and real-world
examples.
All the source code used in this book is available for download at
https://github.com/apress/advanced-data-analytics-python-2e.
Happy reading!
xvii
CHAPTER 1
OOP in Python
In this section, we explain some features of object-oriented programming
(OOP) in a Python context.
The most basic element of any modern application is an object. To
a programmer or architect, the world is a collection of objects. Objects
consist of two types of members: attributes and methods. Members can be
private, public, or protected. Classes are data types of objects. Every object
is an instance of a class. A class can be inherited in child classes. Two
classes can be associated using composition.
Python has no keywords for public, private, or protected, so
encapsulation (hiding a member from the outside world) is not implicit in
Python. Like C++, it supports multilevel and multiple inheritance. Like Java,
it has an abstract keyword. Classes and methods both can be abstract.
© Sayan Mukhopadhyay, Pratip Samanta 2023 1
S. Mukhopadhyay and P. Samanta, Advanced Data Analytics Using Python,
https://doi.org/10.1007/978-1-4842-8005-8_1
Another Random Scribd Document
with Unrelated Content
The Project Gutenberg eBook of Four Phases
of Morals: Socrates, Aristotle, Christianity,
Utilitarianism
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.
Language: English
BY
JOHN STUART BLACKIE, F.R.S.E.
PROFESSOR OF GREEK IN THE UNIVERSITY OF EDINBURGH
SECOND EDITION.
EDINBURGH
EDMONSTON AND DOUGLAS
1874.
TO
I am,
Dear Sir,
Yours, with sincere esteem,
JOHN STUART BLACKIE.
University, Edinburgh,
October 1871.
CONTENTS.
SOCRATES
ARISTOTLE
CHRISTIANITY
UTILITARIANISM
FOOTNOTES
SOCRATES.
As there is no country which can boast the honour of possessing
more names of a world-wide significance than Greece, so among
those who hold this lofty position there is no name superior to
Socrates, concerning whom the Delphic oracle in ancient times, and
a great utilitarian authority in modern times, agree in testifying that
he was the wisest of the wise Greeks.[1.1] And though stout old Cato,
in ancient times, as Plutarch informs us, gruffly enough expressed
his opinion that the son of Sophroniscus was a pernicious old
babbler, whose breath was justly stopped by the cup of hemlock
which he drank for his last supper—in harmony with whom the
benign old dogmatist whom the modern utilitarians revere as their
patriarch declares that Socrates and Plato wasted their lives in
talking nonsense under the pretence of teaching philosophy,[1.2]—yet
these negative utterances, few and far between, against the fair
fame of the father of moral science, have died away almost as
quickly as uttered, and are now no more heard in the grand organ-
swell of the general admiration of more than two thousand years.
Unquestionably if there be any name, after the great Founder of the
Christian faith, which is entitled to claim the title of a preacher of
righteousness for all times and all places, it is the name of Socrates;
and it is with the view of bringing his high merits in tins respect
before the general public, in as easy a way as is consistent with
scholarly accuracy, that I have undertaken to write the present
paper.
The subject is one peculiarly attractive to a thinking man, not
only on its own merits, but because of the ample and thoroughly
trustworthy materials which we possess for forming a correct
judgment. We are not here, as in the case of Pythagoras, sent to
fish for fragments of truth among fanciful writers who lived several
hundred years after the death of the object of their transcendental
laudations; but, as in the gospel history, we have to deal with the
intimate disciples and daily companions of the great hero of the
story. We gather our knowledge of the life and philosophy of
Socrates from Xenophon and Plato, both of whom have reported
their intercourse with the philosopher in a tone of mingled
admiration and sobriety which leaves no ground for suspicion. Only
with regard to Plato we must take with us this caution, that he was
both a poet by temperament and by mental habit a system-builder;
and, as he chose to set forth his own speculations in a series of
dramatic dialogues wherein Socrates is the chief speaker, we must
beware of accepting, as standing on one common basis, the facts
with regard to the life of Socrates brought forward in these
compositions and the doctrines which are put into his mouth. With
regard to the former, we may accept Plato’s evidence as a
contemporary authority with the utmost confidence; with regard to
the latter, we must be constantly on our guard; and indeed,
according to my view, it is wise never to accept any statement of
Socrates’s doctrine from Plato, of which the germ at least does not
lie plainly in Xenophon. For Xenophon, just because he was a less
original man than Plato, a pleasing and graceful writer, somewhat on
the level of our Addison, was for that reason free from the
temptation, or rather had not the capacity, to interpolate anything
into his account of the philosopher which was not consistent with
the actual fact. He was a plain man, with no theories to support, and
no pretensions to maintain; and as a faithful contemporary recorder
of what he heard and saw, a more capable and trustworthy witness
could not be desired. We shall therefore draw our sketch of the life
and sayings of the great Athenian preacher mainly from his pleasant
little book, introducing the idealist of the Academy only where he
cannot be suspected of using his revered master as a mere dramatic
engine, or where his superior literary powers have enabled him to
paint a more effective picture.
The age of Socrates was the age of Pericles, the culminating
epoch of Athenian glory; he was contemporary with Euripides,
Sophocles, Herodotus, Thucydides, Hippocrates, Democritus,
Anaxagoras, Aristophanes, Phidias; but, while he shared all the
elevating influences of this ascendant age, growing with its growth
and blossoming with its blossom, he was not spared the sorrow of
quitting the scene beneath the first dark shadows of its decay. That
military ambition which is as much the besetting sin of democracy as
of autocracy, had precipitated the Athenians, during the latter part of
the fifth century before Christ, into a distant expedition which
crippled their energies and exhausted their resources; all this, and
certain violent revolutionary changes which arose out of it, Socrates
had to live through, till at last, a few years before his death, he saw
the pride of Periclean Athens laid prostrate at the feet of Lysander
and the rude oligarchy of Lacedæmon. He was born in the year 469
B.C., eleven years after the naval battle of Salamis which freed
Europe for ever from the apprehension of Asiatic servitude, exactly
at the time when the brilliant but sober policy of Pericles
commenced its long period of happy sway over the fortunes of the
Athenian state. At this time Simonides and the other great poets
who had seen and sung the glorious victories of Marathon and
Salamis were swiftly departing from the scene; but the memory of
those patriotic achievements still burned vigorously in every
Athenian breast, and conspired, with the birth of new and ambitious
intellectual aspirations, to surround the youth of the philosopher
with an atmosphere the most favourable to social and intellectual
progress. The importance which the achievements of the democracy
at Marathon and Salamis gave to the middle and lower classes of
society at Athens, broke down the barriers which ancient aristocratic
exclusiveness might have raised against the pretensions of mere
character without position; so that Socrates, though the son of a
stone-cutter, and not, like Plato, drawing his blood from the old Attic
aristocracy, seems to have found free entrance into the society of
the most distinguished public and literary men of his age. His
mother, as he himself took care to inform the world, was a “right
worthy and worshipful μαῖα,” or lady-obstetrician; a “wise woman,”
as the French say, in matters where it seems most natural that
women should be specially wise; her name was Phænarete; but in
social position, according to our aristocratic way of talking, she was
nobody. What Socrates’s own profession was, or how he supported
himself, a very important point in the history of all public men, we
unfortunately do not know exactly; that he practised stone-cutting in
his early years is not improbable; and this may have given rise to the
belief mentioned by Pausanias, that a group of the Graces at the
entrance of the Propylæa was his work; but there is not the slightest
indication either in Xenophon or Plato that he continued to practise
this art, or any other art, in after life. He had therefore no
profession; and, as he made no money by his philosophy, we must
believe that he had been left some small competence by his father,
or some relation, on which he was content to live. That he was
extremely poor we know, both from Xenophon and from his own
account of himself before the jury at his trial. We know also that his
habits of life were remarkably plain and frugal, that he required little
money, and coveted none. That he was in a position to have made
money if he had chosen there can be no doubt; but he expressly
states that he had relinquished all projects for increasing his income,
in order that he might devote himself without distraction to the great
work of his life. However, with his philosophical notions about mere
external grandeur, he seems to have been rich enough to live
comfortably with a wife and family. This wife was the noted
Xanthippe, not always the most pleasant companion, and, perhaps
not altogether without reason, from her point of view, at variance
with a husband who showed such utter indifference to worldly
aggrandizement and domestic display; but for this touch of
sharpness in the temper only, as he argued, the better fitted to be
the wife of a philosopher, or to make a philosopher of her husband;
for, as men who wish to learn to ride do not choose the meekest and
most docile beast that they can find, but the most spirited, so the
husband who wishes to rule a wife well should have such an one as
it is not easy but difficult to control. This character of the
philosopher’s wife rests on the authority of Xenophon; Plato nowhere
alludes to it; and whatever her temper might have been, Socrates
certainly did not consider it so bad as to justify his sons in
withholding from her the usual love and reverence due from children
to their parents; for “you may be sure,” he said, “if she is a little
cross sometimes, it is for your good; and there is a reason in her
objurgations which a wise son ought to acknowledge.”
Having no special occupation or profession in life, Socrates
might perhaps have passed in Athens for an idle man, a lounger
about the streets, and public talker, had there not sprung up about
this time a class of men professing to be teachers of eloquence and
of all wisdom, with whom he was brought into connexion. These
were the Sophists, a name which means nothing more than
professors or teachers of wisdom. Like these men, Socrates was
always seen in the streets and public places of Athens, conversing
with the clever young men, and publicly debating all points of
speculative and practical interest. He was therefore in outward
appearance and to the general eye a mere Sophist among Sophists.
For it is not everybody who cares to know that two men who fight
with the same weapons and in the same style of fence may be
fighting for very different causes, on opposite sides, and with
altogether contrary results. But the truth behind the appearance
was, that while the majority of these Sophists taught eloquence as a
trade, and logical training as an affair of intellectual exhibition,
Socrates preached virtue as a mission, and the exercise of right
reason as the only means of obtaining virtue. We say mission here
not as a fashionable phrase of the day, but with a special emphasis;
for it is quite certain, both from the speech of the philosopher at his
trial, and from not a few passages in Xenophon, that he devoted his
life to self-improvement in the first place, and to the improvement of
his fellow-citizens in the second place, with the conscientious
devotedness of a man who was strongly impressed with the
conviction, that this employment was assigned to him direct from
God, whose high injunction he was not at liberty to neglect. His
language with regard to this is in a precisely similar tone to that of
St. Paul when he writes, “Woe is me if I preach not the gospel.” The
human source through which he got this mission some writers have
been curious to trace, alleging that his master was Anaxagoras, and
other things to that effect; but there is no hint of this either in
Xenophon or Plato; and in fact it is foolish to go in search of a
master for a man so thoroughly original, so distinct and decided a
protester against all who had gone before him. We may be assured,
at least, that in the moral philosophy which was the burden of all his
teaching, he had no master but himself (as indeed Xenophon makes
him say in express words) and the God to whom he habitually
referred his highest inspirations; while in regard to other matters he
had enjoyed the common training of all Athenians in music, poetry,
gymnastics, and a little mathematics to boot—a science which, since
the days of Thales (600 B.C.) and Pythagoras (550 B.C.), had
occupied a conspicuous place in the higher culture of the Athenians.
Of the exact date when he assumed a prominent position as a public
teacher of wisdom and virtue we have no exact account; it is natural
however to suppose, from the sobriety and solidity of his character,
and from the long-continued quiet search after truth which occupied
him in his early years, that he did not suddenly emerge into
notoriety, but grew up step by step into that general
acknowledgment of superior wisdom, on which, according to a well-
accredited account, the Delphic oracle was not afraid to put its seal.
Certain it is that in the year 423 B.C., when he was about forty-
seven years of age, he was such a notable character in Athens as to
have been brought upon the stage by the broad license of Attic
comedy as the representative of the whole class of Sophists, with
whom, by the superficial eye, he was naturally confounded. We must
suppose therefore that his reputation as a great public talker and
debater had been gradually growing, up to that period. And no
doubt, even if he had been a man of less original talent, there was
something about his personal appearance and character that could
not fail to make him the mark of general observation among the
busy-idle community of Athens. He was no less odd in his features
and in his manner than in his doctrines; an ἄτοπος or eccentric
person In the general opinion, whom no man knew exactly what to
make of. His features, the very reverse of classical, are familiar to all
the frequenters of our public museums; and are, besides, minutely
described by both his illustrious disciples. His general appearance
was that of a Silenus or Satyr, with a flat, somewhat turned-up,
nose, full prominent eyes, big lips, and in later life, as appears from
the monuments, a bald head; but these defects were of no avail,
even with the beauty-loving Athenians, to diminish the charm of his
conversation and the power of his address. For, as Alcibiades says in
the Platonic dialogue, where he is one of the chief speakers, he was
a Satyr only externally, but internally full of wonderful shapes and
sights of gods, like certain hollow figures full of pipes and tubes,
seen in the statuaries’ shops, which outwardly were shaped like
Sileni, but within contained a machinery of beautiful sacred images.
So, as is wont to happen to wise men, his loss became his gain, and
his uncomely physiognomy, to all that entered into conversation with
him, was the cause of an agreeable surprise. Very different in this
from a great modern poet, who was sensitive about his club-foot,
the Athenian philosopher made a jest of his unclassical nose, saying
that if noses were to be valued as they ought to be, by their fitness
for performing the proper functions of a nose, his olfactory organ
was better than those noses whose shape was vulgarly accounted
more classical; for the upward cast of his open nostrils made them
more ready to receive smells from all quarters, while the
comparative flatness of his nasal protuberance removed it from the
possibility of interfering with the free vision of his eyes; and as to
the prominency of these his organs of vision, this was a manifest
excellence even more than the conformation of his nose, inasmuch
as it enabled him to look, not only straight before him in the way
that most eyes do, bat sideways also, and almost all round, so that
he could see when no one suspected him of looking at them.
But it was not only his general oddity, his pleasant humour, and
his wisdom seasoned with salt that made him a noticeable man amid
the brilliant society of Athens: he was moreover a thoroughly healthy
man, of great powers of endurance, a valiant soldier when his
country required his services, and a good bottle-companion when
piety towards Dionysus, or any occasion of social festivity, according
to Attic usage, demanded that men should drink largely. On these
points we have a graphic picture put by Plato into the mouth of
Alcibiades, which, to complete our personal portrait here, it will not
be amiss to translate.
“When we were together in the campaign at Potidæa, and I
messed with him every day, I found that in the power of enduring
toil he surpassed not only me but all the soldiers in the camp. For
when, as sometimes will happen on the march, we might be at a
loss for a dinner, Socrates could always fast with the least complaint;
while, on the other hand, at our banquetings and junketings he
always enjoyed everything in the most hearty way; and when he
was forced to drink, even though not willingly, he could drain cup for
cup with the stoutest bottle-companion in the camp; and, what is
strangest of all, even after our stiffest bouts no one ever saw
Socrates drunk. And as to cold and frost, I remember well, one night
in one of those severe Macedonian winters, when there was a very
biting frost, and every man either stayed within or went out well
encased in warm sheepskin jackets and felt shoes, Socrates alone
went about in the open air with no other covering than his common
mantle, and trod the frosted ground with his bare feet more lightly
than others did with their warm shoes. But I must tell you something
more notable of his doings at Potidæa. One morning he went out
early to indulge some contemplations; but not succeeding, as it
would appear, in his object, whatever that might be, he remained
standing and looking right out before him till it was near mid-day;
and then the soldiers began to notice him, and said one to another
that Socrates had been standing there in a brown study from
sunrise. Thereafter some of the Ionians about the evening, after
supper, took their quilts and carpets out, for it was then mild
summer weather, and, shaking them on the ground, slept in the
open air, keeping an eye at the same time on Socrates to see
whether he would remain all night standing in that reverie; and
when they awoke in the morning with the sun, lo! Socrates was
standing in the same spot; and, after saying a prayer to the sun,
shortly retired. So much for his contemplative oddities; but it is only
fair that I should tell you how he was as good a soldier as a sophist,
and could achieve no less notable things with his hand than with his
head. For when the battle took place, for my conduct in which the
generals gave me such honourable marks of distinction, I, who knew
the real state of the case, insisted that if any man had distinguished
himself in the fight it was Socrates, to whom on that occasion I
should willingly resign the intended laurels. But though this was
quite true, the judges were inclined to favour me; and Socrates
came forward and asserted with the greatest emphasis that my
claims were superior to his; and so I carried off the reward of valour
which none but he could with perfect justice claim. Then again when
we retreated from Delium, after the defeat I was riding off on
horseback, while Socrates and Laches followed, as hoplites, on foot,
and coming up to them I cried, Fear not, good friends, I will keep
alongside of you and defend you from the pursuit. On that occasion
I admired even more than at Potidæa the conduct of this man; for
while both were in danger of being overtaken it was manifest that
Socrates during the whole retreat displayed far more coolness than
Laches, who was by profession a soldier. ... Instead of hurry and
trepidation we saw in him only the large full eye that with wise
wariness turned to this side and to that in a fashion that seemed to
say to all comers that they would find a steady nerve if they came
within sword’s length of him. And thus he got out of the rush safely;
for so I have always observed that in a retreat the men who are
most afraid always fare the worst. And many other things there are I
might relate, which would show clearly what a strange and truly
admirable creature this Socrates is. Individual persons, behaving in
individual cases as excellently as Socrates, it might be easy to point
out; but such a compound, a thing in the shape of a man so utterly
unlike any other man, you will find nowhere, either among famous
ancients op illustrious moderns. One might make an adequate
portraiture of Achilles, or Brasidas, of Pericles, or Nestor, or Antenor,
and other famous characters; but such a unique mortal as this son
of Sophroniscus no man can describe, unless, indeed, he chooses to
steal my simile, and say that he is a Silenus superficially, both in his
appearance and in his talk, but to those who look deeper his soul is
a shrine of most excellent, beautiful, and worshipful divinities.”
This passage will make it plain that Socrates was no mere idle
speculator or subtle talker, such as might be found in ancient Athens
or in any modern German university by scores—but a practical man,
and an effective citizen of prominent merit. But if he showed
courage in the field of battle not inferior to the stoutest and coolest
professional soldier, he displayed a civic virtue on other occasions,
which only the fewest on all occasions have been able to exhibit.
This virtue was moral courage; a quality which, when exercised in
critical circumstances, raises a man high above the average of his
kind, whereas with mere physical courage he is only a more cool and
calculating rival of dogs and cocks and tigers, and other ferine
combatants. On that memorable occasion, when the whole of Athens
was fretted into a fever-fit of indignation on account of the neglect
of the dead and dying slain by the victors at Arginusæ (B.C. 406),
and in the torrent of what appeared to them most righteous wrath,
were eager to overbear all the customary forms of fair judicial trial,
Socrates happened to be serving as one of the senators whose duty
it was to put the question to the assembly of the people in the case
of great public trials; and, a motion having been made that the
generals who were guilty of the alleged neglect of pious duty should
be condemned to drink the hemlock, and have their property
confiscated, it fell to the senators to perform the preparatory step in
the prosecution. But as the proceedings in the case had been
dictated by violent excitement, and were decidedly illegal, Socrates
refused, in the face of violent popular clamour, to have anything to
do with the matter, and lifted up his single protest—one amongst
fifty—against violating the sacred forms of law at the dictation of an
excited populace. On this, as on other similar occasions when he
came into collision with the public authorities, he maintained a truly
apostolic bearing, using in almost identical terms the language of the
apostles Peter and John, when they were forbidden to preach by the
Sanhedrim: “Whether it be right in the sight of the gods to hearken
unto you rather than to the gods, judge ye; but as for me, I have
sworn to obey the laws, and I cannot forswear myself.”
With all this faithfulness, however, in the public service, Socrates
was very far from wishing to be what we call a public man; on the
contrary, he kept himself systematically out of places which were
eagerly coveted by less able men, and refused to have anything to
do with the party politics of the day. This withdrawal from the
service of the State, to the majority of Greeks, with whom the State
was everything, could not but appear strange, and tend to increase
their prejudice against philosophy and philosophers. But Socrates
acted here, as in all other matters, with admirable good sense; he
felt that to be a politician and a preacher of righteousness was to
combine two vocations practically incompatible; for the popular
measure which it might serve the immediate need of the political
man to advocate it might not seldom be the first duty of the moralist
to condemn. Besides, if he took office with men who habitually acted
on principles of which he could not but disapprove, he would be
forced to waste his strength in a fruitless opposition to measures
which he could not prevent; and in this way it came to pass that,
while he utterly disapproved, in the general case, of a good citizen,
whether from the love of selfish ease, or from false modesty, or from
moral cowardice, refusing to take part in public life, in his own
particular work he felt that political activity would be a hindrance,
and that it was his duty to abstain.
In these few paragraphs are summed up all that from
indisputable authority we know of the personal history of the
greatest of heathen preachers. The circumstances connected with
his death are too closely interwoven with the character of his
teaching to be intelligible here. We shall therefore enter now directly
into a short exposition of his ethical teaching; after which we shall
be in a condition to consider with an intelligent astonishment how it
came to pass that the preacher of the noblest doctrine that Athens
ever heard, before the preaching of Paul on the Hill of Mars, after
living in high repute and popularity for seventy years, should at last
have been made to quit the scene of his moral triumphs, publicly
branded with the stigma which was wont to be attached to the
lowest of malefactors and the vilest of traitors.
The two first questions to be asked with regard to any great
moral or political reformer are—What had he to reform? and then, In
the work of reform who were his antagonists? The first of these
questions is answered intelligibly and plainly enough in the current
knowledge of every schoolboy, that Socrates brought down
philosophy from heaven to earth, or, as Cicero has it more fully in
the Tusculan questions, “Socrates primus philosophiam devocavit e
cœlo, et in urbibus collocavit, et in domos etiam introduxit, et coegit
de vitâ et moribus, rebusque bonis et mails quœrere.” Now there
cannot be any doubt that, both relatively to the time and place
where he taught, and absolutely for all times and all places, Socrates
by this step did one of the highest services to human progress. By a
natural vice of the human imagination we are led to seek in the
misty distance for some pleasant excitement to thought, while
neglecting the direct lessons of familiar wisdom from things under
our eyes, which appear contemptible only because they are
common. We attempt ambitiously to measure the remote movement
of the spheres, and to note their imagined music, before we have
brought any order or harmony into the daily course of our own lives;
we climb all the highest mountains in Europe for a fine prospect,
when there is likely a much better one to be enjoyed not five miles
from our own door. In obedience to this tendency of the human
mind the early philosophy of Greece was occupied principally (not
altogether certainly, for Pythagoras was a great moralist) with
cosmical and metaphysical speculations which amused the fancy and
raised interesting and puzzling problems for thought, without any
valuable practical result. When Thales, for one, said that the first
principle of all things was water, he enunciated a great truth; it is
true that wherever there is life there must be humidity; with dryness
dwells only dust and death and frost. But this was a truth leading to
no applications; it could neither purify the wells nor improve the
wines; no man would be the better in his body or his soul for
formulating a cosmical generality of this kind. And if Heraclitus, the
sombre sage of Ephesus, advanced a step further in a true
generalization, when he said that fire or heat is the fundamental
force which makes water possible, as modern chemistry has amply
demonstrated, this doctrine did not advance human nature one step
either towards outward comfort or inward satisfaction. And of what
avail was it to tell men, as he did, that “all things are in a perpetual
flux,” if he did not teach them how to regulate that flux in the flow of
their own lives, and to prevent the tidal currents of their soul from
getting into a plash and jabble of conflicting waters in the navigation
of which no seamancraft could avail against miserable shipwreck?
More useless still was it to assert, as Anaxagoras is reported to have
done, that the sun is a large mass of glowing stone or metal, so
many times bigger than the earth—a proposition which, if it were
true, would not teach a poor cowering savage to kindle a stick fire,
nor make one olive-tree brighter with blossoms that promised a
purer and a richer oil; while, if it were not true, then the whole of
your lofty heliacal philosophy is only a blaze of lies. The whole
history of modern science, indeed, before the establishment of the
close and cautious method of experiment introduced by Bacon,
shows that all physical inquiry starting from unproved assumptions,
and ending in sweeping speculations, is only a sublime sort of
idleness, and a procreation of cloud-phantoms. Socrates therefore
acted wisely for his own time and place in saying to a people fond of
curious subtlety and unfruitful speculation. Let us have done with
this lofty-sounding but essentially hollow talk about sun and moon
and stars, and let us know something certain, and do something
useful. This we shall achieve if we keep within our own lower
sphere, and attend to our own work as men; let us order our houses
well in the first place, and after that concern ourselves with the
order of the universe; if, indeed, this does not rather belong to the
gods, who may safely be left to do their cosmical work quietly,
without any Anaxagoras or Archelaus to tempt with adventurous
guesses the principles of their administration. Such was the
thoroughly practical, and, if you will, thoroughly utilitarian tone
which, taught by Xenophon, we justly view as the starting-point of
the Socratic philosophy. And there can be no doubt man is so
essentially a practical animal, that if even the accurate and curiously
verified physical science of these latter days were as destitute of
social applications and as barren of practical results as Greek science
was in the days of Socrates, nine hundred and ninety-nine persons
of those who now delight to dabble in chemistry and geology would
leave these interesting sciences to the few men of a purely
speculative character with whom mere knowledge is loved for itself.
But when by geology we are enabled to unearth coals and gold, and
know where to sink wells much more certainly than by the mediæval
magic of the divining-rod; and when by chemistry we improve our
stores, bleach our clothes, purify our infected chambers, and dye our
cloth with hues of which even the most skilful of the lichen-gatherers
in the Highland glens never dreamt—then, to use a bookseller’s
phrase, you are sure to interest a large public. But there is another
view of the case, which places the Socratic philosopher on a much
more lofty and honourable pedestal. For notwithstanding all the
surprising discoveries and brilliant achievements of modern physical
science, it must still remain true that
“The proper study of mankind is man,”
and that no kind of knowledge ever can surpass either in interest or
importance the knowledge of man as a social being, as the member
of a Family, of a Church, and of a State. The depreciation of moral
science which we have lately heard from Mr. Buckle and other
members of that school is a transitional phenomenon arising out of
the one-sided culture of the understanding, and a defective
emotional, volitional, and imaginative organization. If new
discoveries are not every day trumpeted in the domain of moral
philosophy, it is just because this science, like Euclid, is too certain,
too fundamental, and too indispensable to have been left to the
happy chance of being found out after the lapse of long centuries.
Morals are as necessary to the acting man as the sun’s light to the
growing plant; they are not discovered, because they always have
been and always must be; and the only great result that we have to
look for then in them is that they shall be more universally
recognised, more scientifically handled, and more practically applied.
Socrates therefore was right, not only for Greece in the fifth century
before Christ, but for England at the present moment, and for all
times and places, when he proclaimed on the house-tops that the
first and most necessary wisdom for all men is not to measure the
stars, or to weigh the dust, or to analyse the air, but, according to
the old Delphic sentence, to know themselves, and to realize in all
the breadth and depth of its significance what it is to be a man, and
not a pig or a god. And in attaining this knowledge, while he would
certainly find that, though a stable physical platform to stand on and
a healthy physical atmosphere to breathe are necessary for the
production of a normal humanity, yet in general the measure of a
man’s manhood is to be taken not so much from what he attaches to
himself from without as from what he brings with him from within.
“The kingdom of heaven is within you” is a pregnant Socratic
maxim as well as a profound evangelic text, and, in reference to our
present subject, simply means that, while the most brilliant
discoveries of physical science only minister to our comforts, our
conveniences, and our furnishings, moral science alone can teach us
to be men; for we are men by what we are, not by what we have.
Gas-pipes, and water-pipes, spinning-jennies, steamboats, steam-
coaches, submarine telegraphs, photographs, oleographs,
oxyhydrogen, blowpipes, and the thousand and one devices for
using and controlling nature which we owe to advanced physical
science, may adorn and improve life in many ways, may multiply
production of all kinds infinitely, and facilitate the diffusion of
intellectual as well as material benefits; but they have no originating
power in what is highest; they can create neither thought nor
character; they are the most useful of ministers, but the most
unmeaning of masters. And there can be little doubt that, if Socrates
were to rise from the grave at the present moment, while, with his,
strong common sense and keen eye for the practical, he would
joyfully recognise all the wonderful material progress of which
England and America make their boast, he would not the less feel
himself constrained to utter an emphatic warning against the danger
of estimating our national grandeur by the visible pomp of gigantic
machinery and complex apparatus rather than by the invisible power
of noble purpose and lofty design.
Such was the attitude of Socrates to the great teachers who
since Thales downwards had preceded him in leading the intellectual
advance of the most intellectual people of the ancient world. He
stood forward as a teacher of moral science, as a preacher and
philosophical missionary also; for in morals, the separation of theory
from practice is an inconsistency of which only a feeble and
imperfect nature is capable. Who, then, and of what quality, were his
antagonists in the great regenerative work which he undertook? Not
so much the physical philosophers, who might still pursue their
researches or pamper their imaginations in their own speculative
corners without disturbing the busy world, except in so far as they
now and then might come into collision with theological orthodoxy,
but the great untrained mass of the people themselves, and the
pretentious array of a class of men who put themselves forward as
their instructors,—the famous Sophists. The word Sophists signifies
professors of wisdom, in which sense Lucian calls our Saviour τὸν
ἀνεσκολοπισμένον ἐκεῖνον σοφιστήν—that crucified Sophist—
because He came forward as a public instructor professing to teach
men wisdom. But as wisdom is a vague word (in fact σοφός in Greek
signifies clever, and even cunning as often as wise), we must consult
the circumstances of time and place to know what it exactly meant
in any particular instance. The generation immediately preceding
Socrates, when the Sophists first became prominent, was the era of
the great Persian wars, and of the notable uprising of national spirit
and of popular power which that memorable struggle called forth.
How fiercely the strife between the old aristocratic and the new
democratic element in Greek society had been raging in the
immediately preceding epoch, the poems of Theognis may serve
sufficiently to indicate; and now that by the battle of Salamis the
political importance of the middle and sub-middle classes had been
blazoned forth before universal Greece in glowing characters, the
democracy in great commercial cities like Athens at once started into
an attitude of hitherto unsuspected significance. New aspirations had
been created, new pretensions were put forth, and new guides were
required for a large class of people who felt themselves as it were
suddenly shooting up from pupilage into majority. Now what guides
had a people, circumstanced as the Athenians then, were, to look to
for direction? The Church in those days—if we may call it a Church—
was not a teaching body; its moral efficacy was exercised through
sacred ceremonial and pious hymns; its intellectual agency was
almost null. And though gymnastics and music, including a certain
amount of the most popular literary culture, were common, there
were no institutions like our Universities, for the severe and