0% found this document useful (0 votes)
6 views

Machine Learning for Decision Sciences with Case Studies in Python 1st Edition S. Sumathi pdf download

The document provides information about the book 'Machine Learning for Decision Sciences with Case Studies in Python' by S. Sumathi and others, published in 2022. It includes details about the book's content, structure, and chapters covering various aspects of machine learning and Python programming. Additionally, it offers links to other related resources and ebooks available for download.

Uploaded by

ahauswberiay5
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Machine Learning for Decision Sciences with Case Studies in Python 1st Edition S. Sumathi pdf download

The document provides information about the book 'Machine Learning for Decision Sciences with Case Studies in Python' by S. Sumathi and others, published in 2022. It includes details about the book's content, structure, and chapters covering various aspects of machine learning and Python programming. Additionally, it offers links to other related resources and ebooks available for download.

Uploaded by

ahauswberiay5
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 47

Machine Learning for Decision Sciences with Case

Studies in Python 1st Edition S. Sumathi pdf


download

https://ebookmeta.com/product/machine-learning-for-decision-
sciences-with-case-studies-in-python-1st-edition-s-sumathi/

Download more ebook from https://ebookmeta.com


We believe these products will be a great fit for you. Click
the link to download now, or visit ebookmeta.com
to discover even more!

Innovations in Machine and Deep Learning Case Studies


and Applications Gilberto Rivera

https://ebookmeta.com/product/innovations-in-machine-and-deep-
learning-case-studies-and-applications-gilberto-rivera/

Machine Learning with Python Cookbook, 2nd Edition Kyle


Gallatin

https://ebookmeta.com/product/machine-learning-with-python-
cookbook-2nd-edition-kyle-gallatin/

Machine Learning with Python Cookbook 2nd Edition Chris


Albon

https://ebookmeta.com/product/machine-learning-with-python-
cookbook-2nd-edition-chris-albon/

Exploring a Business Case for High Value Continuing


Professional Development Proceedings of a Workshop 1st
Edition And Medicine Engineering National Academies Of
Sciences
https://ebookmeta.com/product/exploring-a-business-case-for-high-
value-continuing-professional-development-proceedings-of-a-
workshop-1st-edition-and-medicine-engineering-national-academies-
Close Reading the Basics 1st Edition David Greenham

https://ebookmeta.com/product/close-reading-the-basics-1st-
edition-david-greenham/

Black Light Rocked Black Light Series Book 1 1st


Edition Livia Grant

https://ebookmeta.com/product/black-light-rocked-black-light-
series-book-1-1st-edition-livia-grant-2/

Urban Planning for Transitions 1st Edition Nicolas


Douay

https://ebookmeta.com/product/urban-planning-for-transitions-1st-
edition-nicolas-douay/

Collaboration for Career and Technical Education


Teamwork Beyond the Core Content Areas in a PLC at Work
a Guide for Collaborative Teaching in Career and
Technical Education 1st Edition Wendy Custable
https://ebookmeta.com/product/collaboration-for-career-and-
technical-education-teamwork-beyond-the-core-content-areas-in-a-
plc-at-work-a-guide-for-collaborative-teaching-in-career-and-
technical-education-1st-edition-wendy-custabl/

Economics, Anthropology and the Origin of Money as a


Bargaining Counter 1st Edition Patrick Spread

https://ebookmeta.com/product/economics-anthropology-and-the-
origin-of-money-as-a-bargaining-counter-1st-edition-patrick-
spread/
Custom Search - Discover More: : A Complete Guide to
Google Programmable Search Engines 1st Edition Irina
Shamaeva

https://ebookmeta.com/product/custom-search-discover-more-a-
complete-guide-to-google-programmable-search-engines-1st-edition-
irina-shamaeva/
Machine Learning for Decision
Sciences with Case Studies
in Python
Machine Learning for Decision
Sciences with Case Studies
in Python

S. Sumathi
Suresh V. Rajappa
L. Ashok Kumar
Surekha Paneerselvam
First edition published 2022
by CRC Press
6000 Broken Sound Parkway NW, Suite 300, Boca Raton, FL 33487-2742

and by CRC Press


2 Park Square, Milton Park, Abingdon, Oxon, OX14 4RN

© 2022 S. Sumathi, Suresh V. Rajappa, L Ashok Kumar and Surekha Paneerselvam

CRC Press is an imprint of Taylor & Francis Group, LLC

Reasonable efforts have been made to publish reliable data and information, but the author and publisher cannot
assume responsibility for the validity of all materials or the consequences of their use. The authors and publishers
have attempted to trace the copyright holders of all material reproduced in this publication and apologize to copyright
holders if permission to publish in this form has not been obtained. If any copyright material has not been acknowl-
edged please write and let us know so we may rectify in any future reprint.

Except as permitted under U.S. Copyright Law, no part of this book may be reprinted, reproduced, transmitted, or
utilized in any form by any electronic, mechanical, or other means, now known or hereafter invented, including pho-
tocopying, microfilming, and recording, or in any information storage or retrieval system, without written permission
from the publishers.

For permission to photocopy or use material electronically from this work, access www.copyright.com or contact the
Copyright Clearance Center, Inc. (CCC), 222 Rosewood Drive, Danvers, MA 01923, 978-750-8400. For works that are
not available on CCC please contact mpkbookspermissions@tandf.co.uk

Trademark notice: Product or corporate names may be trademarks or registered trademarks and are used only for
identification and explanation without intent to infringe.

ISBN: 978-1-032-19356-4 (hbk)


ISBN: 978-1-032-19357-1 (pbk)
ISBN: 978-1-003-25880-3 (ebk)

DOI: 10.1201/9781003258803

Typeset in Times
by codeMantra
Contents
Preface.............................................................................................................................................. xv
Acknowledgment............................................................................................................................xvii
About the Authors............................................................................................................................xix
Introduction......................................................................................................................................xxi

Chapter 1 Introduction...................................................................................................................1
1.1 Introduction to Data Science..............................................................................1
1.1.1 Mathematics..........................................................................................1
1.1.2 Statistics................................................................................................1
1.2 Describing Structural Patterns...........................................................................2
1.2.1 Uses of Structural Patterns....................................................................2
1.3 Machine Learning and Statistics........................................................................3
1.4 Relation between Artificial Intelligence, Machine Learning, Neural
Networks, and Deep Learning...........................................................................4
1.5 Data Science Life Cycle.....................................................................................6
1.6 Key Role of Data Scientist..................................................................................8
1.6.1 Difference between Data Scientist and Machine
Learning Engineer................................................................................8
1.7 Real-World Examples.........................................................................................8
1.8 Use Cases............................................................................................................9
1.8.1 Financial and Insurance Industries.......................................................9
1.8.1.1 Fraud Mitigation....................................................................9
1.8.1.2 Personalized Pricing............................................................ 10
1.8.1.3 AML – Anti-Money Laundering......................................... 10
1.8.2 Utility Industries................................................................................. 11
1.8.2.1 Smart Meter and Smart Grid............................................... 11
1.8.2.2 Manage disaster and Outages.............................................. 11
1.8.2.3 Compliance.......................................................................... 11
1.8.3 Oil and Gas Industries......................................................................... 11
1.8.3.1 Manage Exponential Growth............................................... 11
1.8.3.2 3D Seismic Imaging and Kirchhoff.................................... 12
1.8.3.3 Rapidly Process and Display Seismic Data......................... 12
1.8.4 E-Commerce and Hi-Tech Industries.................................................. 12
1.8.4.1 Association and Complementary Products.......................... 12
1.8.4.2 Cross-Channel Analytics..................................................... 12
1.8.4.3 Event analytics..................................................................... 13
Summary..................................................................................................................... 13
Review Questions........................................................................................................ 14

Chapter 2 Overview of Python for Machine Learning................................................................ 15


2.1 Introduction...................................................................................................... 15
2.1.1 The Flow of Program Execution in Python........................................ 15
2.2 Python for Machine Learning.......................................................................... 15
2.2.1 Why Is Python Good for ML?............................................................. 16
2.3 Setting up Python............................................................................................. 16

v
vi Contents

2.3.1 Python on Windows............................................................................ 16


2.3.2 Python on Linux.................................................................................. 17
2.3.2.1 Ubuntu................................................................................. 17
2.4 Python Basics................................................................................................... 17
2.4.1 Python Operators................................................................................ 18
2.4.1.1 Arithmetic Operators........................................................... 18
2.4.1.2 Comparison Operators......................................................... 18
2.4.1.3 Assignment Operators......................................................... 18
2.4.1.4 Logical Operators................................................................ 18
2.4.1.5 Membership Operators........................................................ 19
2.4.2 Python Code Samples on Basic Operators.......................................... 19
2.4.2.1 Arithmetic Operators........................................................... 19
2.4.2.2 Comparison Operators......................................................... 21
2.4.2.3 Logical Operators................................................................ 22
2.4.2.4 Membership Operators........................................................ 23
2.4.3 Flow Control........................................................................................24
2.4.3.1 If & elif Statement...............................................................24
2.4.3.2 Loop Statement....................................................................25
2.4.3.3 Loop Control Statements.....................................................26
2.4.4 Python Code Samples on Flow Control Statements........................... 26
2.4.4.1 Conditional Statements........................................................26
2.4.4.2 Python if...else Statement.................................................... 27
2.4.4.3 Python if…elif…else Statement..........................................28
2.4.4.4 The For Loop....................................................................... 29
2.4.4.5 The range() Function........................................................... 29
2.4.4.6 For Loop with else............................................................... 31
2.4.4.7 While Loop.......................................................................... 31
2.4.4.8 While Loop with else.......................................................... 32
2.4.4.9 Python Break and Continue................................................. 32
2.4.4.10 Python Break Statement...................................................... 32
2.4.4.11 Python Continue Statement................................................. 33
2.4.5 Review of Basic Data Structures and Implementation in Python.......34
2.4.5.1 Array Data Structure...........................................................34
2.4.5.2 Implementation of Arrays in Python................................... 35
2.4.5.3 Linked List........................................................................... 36
2.4.5.4 Implementation of Linked List in Python........................... 36
2.4.5.5 Stacks and Queues............................................................... 38
2.4.5.6 Queues.................................................................................40
2.4.5.7 Implementation of Queue in Python.................................... 41
2.4.5.8 Searching............................................................................. 42
2.4.5.9 Implementation of Searching in Python..............................44
2.4.5.10 Sorting.................................................................................46
2.4.5.11 Implementation of Bubble Sort in Python........................... 47
2.4.5.12 Insertion Sort....................................................................... 47
2.4.5.13 Implementation of Insertion Sort in Python........................ 49
2.4.5.14 Selection Sort....................................................................... 51
2.4.5.15 Implementation of Selection Sort in Python....................... 52
2.4.5.16 Merge Sort........................................................................... 52
2.4.5.17 Implementation of Merge Sort in Python............................ 53
2.4.5.18 Shell Sort............................................................................. 54
2.4.5.19 Quicksort............................................................................. 55
Contents vii

2.4.5.20 Data Structures in Python with Sample Codes................... 55


2.4.5.21 Python Code Samples for Data Structures in Python......... 58
2.4.6 Functions in Python............................................................................ 68
2.4.6.1 Python Code Samples for Functions................................... 68
2.4.6.2 Returning Values from Functions........................................ 68
2.4.6.3 Scope of Variables............................................................... 69
2.4.6.4 Function Arguments............................................................ 70
2.4.7 File Handling....................................................................................... 74
2.4.8 Exception Handling............................................................................. 74
2.4.9 Debugging in Python.......................................................................... 75
2.4.9.1 Packages.............................................................................. 75
2.5 Numpy Basics................................................................................................... 75
2.5.1 Introduction to Numpy........................................................................ 76
2.5.1.1 Array Creation..................................................................... 76
2.5.1.2 Array Slicing....................................................................... 77
2.5.2 Numerical Operations......................................................................... 77
2.5.3 Python Code Samples for Numpy Package......................................... 78
2.5.3.1 Array Creation..................................................................... 78
2.5.3.2 Class and Attributes of ndarray—.ndim.............................. 82
2.5.3.3 Class and Attributes of ndarray—.shape............................. 82
2.5.3.4 Class and Attributes of ndarray—ndarray.size,
ndarray.Itemsize, ndarray.resize.......................................... 83
2.5.3.5 Class and Attributes of ndarray—.dtype............................. 83
2.5.3.6 Basic Operations..................................................................84
2.5.3.7 Accessing Array Elements: Indexing.................................. 85
2.5.3.8 Shape Manipulation............................................................. 88
2.5.3.9 Universal Functions (ufunc) in Numpy................................90
2.5.3.10 Broadcasting........................................................................90
2.5.3.11 Args and Kwargs................................................................. 91
2.6 Matplotlib Basics..............................................................................................92
2.6.1 Creating Graphs with Matplotlib........................................................ 93
2.7 Pandas Basics...................................................................................................94
2.7.1 Getting Started with Pandas...............................................................94
2.7.2 Data Frames........................................................................................ 95
2.7.3 Key Operations on Data Frames......................................................... 95
2.7.3.1 Data Frame from List.......................................................... 95
2.7.3.2 Rows and Columns in Data Frame......................................96
2.8 Computational Complexity...............................................................................97
2.9 Real-world Examples........................................................................................97
2.9.1 Implementation using Pandas.............................................................. 98
2.9.2 Implementation using Numpy............................................................. 98
2.9.3 Implementation using Matplotlib........................................................ 98
Summary.....................................................................................................................99
Review Questions...................................................................................................... 100
Exercises for Practice................................................................................................ 101

Chapter 3 Data Analytics Life Cycle for Machine Learning.................................................... 103


3.1 Introduction.................................................................................................... 103
3.2 Data Analytics Life Cycle.............................................................................. 104
3.2.1 Phase 1 – Data Discovery.................................................................. 104
viii Contents

3.2.2 Phase 2 – Data Preparation and Exploratory Data Analysis............. 107


3.2.2.1 Exploratory Data Analysis................................................. 110
3.2.3 Phase 3 – Model Planning................................................................. 136
3.2.4 Phase 4 – Model Building................................................................. 139
3.2.5 Phase 5 – Communicating Results.................................................... 140
3.2.6 Phase 6 – Optimize and Operationalize the Models......................... 140
Summary................................................................................................................... 142
Review Questions...................................................................................................... 143

Chapter 4 Unsupervised Learning............................................................................................. 145


4.1 Introduction.................................................................................................... 145
4.2 Unsupervised Learning.................................................................................. 145
4.2.1 Clustering.......................................................................................... 147
4.3 Evaluation Metrics for Clustering.................................................................. 147
4.3.1 Distance Measures............................................................................ 148
4.3.1.1 Minkowski Metric............................................................. 149
4.3.2 Similarity Measures.......................................................................... 149
4.4 Clustering Algorithms.................................................................................... 150
4.4.1 Hierarchical and Partitional Clustering Approaches........................ 150
4.4.2 Agglomerative and Divisive Clustering Approaches........................ 150
4.4.3 Hard and Fuzzy Clustering Approaches........................................... 150
4.4.4 Monothetic and Polythetic Clustering Approaches........................... 151
4.4.5 Deterministic and Probabilistic Clustering Approaches................... 151
4.5 k-Means Clustering......................................................................................... 151
4.5.1 Geometric Intuition, Centroids......................................................... 151
4.5.2 The Algorithm................................................................................... 152
4.5.3 Choosing k......................................................................................... 152
4.5.4 Space and Time Complexity............................................................. 153
4.5.5 Advantages and Disadvantages of k-Means Clustering.................... 153
4.5.5.1 Advantages......................................................................... 153
4.5.5.2 Disadvantages.................................................................... 153
4.5.6 k-Means Clustering in Practice Using Python.................................. 154
4.5.6.1 Illustration of the k-Means Algorithm Using Python........ 154
4.5.7 Fuzzy k-Means Clustering Algorithm............................................... 157
4.5.7.1 The Algorithm................................................................... 158
4.5.8 Advantages and Disadvantages of Fuzzy k-Means Clustering......... 158
4.6 Hierarchical Clustering.................................................................................. 159
4.6.1 Agglomerative Hierarchical Clustering............................................ 159
4.6.2 Divisive Hierarchical Clustering....................................................... 161
4.6.3 Techniques to Merge Cluster............................................................. 161
4.6.4 Space and Time Complexity............................................................. 163
4.6.5 Limitations of Hierarchical Clustering............................................. 163
4.6.6 Hierarchical Clustering in Practice Using Python............................ 163
4.6.6.1 DATA_SET....................................................................... 164
4.7 Mixture of Gaussian Clustering..................................................................... 165
4.7.1 Expectation Maximization................................................................ 166
4.7.2 Mixture of Gaussian Clustering in Practice Using Python............... 168
4.8 Density-Based Clustering Algorithm............................................................. 169
4.8.1 DBSCAN (Density-Based Spatial Clustering of
Applications with Noise)................................................................... 169
Contents ix

4.8.2 Space and Time Complexity............................................................. 171


4.8.3 Advantages and Disadvantages of DBSCAN.................................... 171
4.8.3.1 Advantages......................................................................... 171
4.8.3.2 Disadvantages.................................................................... 171
4.8.4 DBSCAN in Practice Using Python.................................................. 172
Summary................................................................................................................... 174
Review Questions...................................................................................................... 174

Chapter 5 Supervised Learning: Regression............................................................................. 177


5.1 Introduction.................................................................................................... 177
5.2 Supervised Learning – Real-Life Scenario.................................................... 177
5.3 Types of Supervised Learning........................................................................ 178
5.3.1 Supervised Learning – Classification............................................... 178
5.3.1.1 Classification – Predictive Modeling................................. 179
5.3.2 Supervised Learning – Regression................................................... 179
5.3.2.1 Regression Predictive Modeling........................................ 180
5.3.3 Classification vs. Regression............................................................. 180
5.3.4 Conversion between Classification and Regression Problems.......... 181
5.4 Linear Regression........................................................................................... 181
5.4.1 Types of Linear Regression............................................................... 182
5.4.1.1 Simple Linear Regression.................................................. 183
5.4.1.2 Multiple Linear Regression............................................... 184
5.4.2 Geometric Intuition........................................................................... 186
5.4.3 Mathematical Formulation................................................................ 187
5.4.4 Solving Optimization Problem.......................................................... 201
5.4.4.1 Maxima and Minima......................................................... 201
5.4.4.2 Gradient Descent...............................................................202
5.4.4.3 LMS (Least Mean Square) Update Rule...........................205
5.4.4.4 SGD Algorithm..................................................................205
5.4.5 Real-World Applications...................................................................206
5.4.5.1 Predictive Analysis............................................................206
5.4.5.2 Medical Outcome Prediction.............................................208
5.4.5.3 Wind Speed Prediction......................................................208
5.4.5.4 Environmental Effects Monitoring....................................209
5.4.6 Linear Regression in Practice Using Python....................................209
5.4.6.1 Simple Linear Regression Using Python...........................209
5.4.6.2 Multiple Linear Regression Using Python........................ 212
Summary................................................................................................................... 215
Review Questions...................................................................................................... 215

Chapter 6 Supervised Learning: Classification......................................................................... 219


6.1 Introduction.................................................................................................... 219
6.2 Use Cases of Classification............................................................................. 219
6.3 Logistic Regression........................................................................................ 219
6.3.1 Geometric Intuition........................................................................... 220
6.3.2 Variants of Logistic Regression........................................................ 222
6.3.2.1 Simple Logistic Regression............................................... 222
6.3.2.2 Multiple Logistic Regression............................................. 223
6.3.2.3 Binary Logistic Regression............................................... 223
x Contents

6.3.2.4 Multiclass Logistic Regression..........................................224


6.3.2.5 Nominal Logistic Regression............................................224
6.3.2.6 Ordinal Logistic Regression.............................................. 226
6.3.3 Optimization Problem....................................................................... 226
6.3.4 Regularization................................................................................... 226
6.3.5 Real-World Applications................................................................... 227
6.3.5.1 Medical Diagnosis............................................................. 227
6.3.5.2 Text Classification.............................................................. 227
6.3.5.3 Marketing........................................................................... 227
6.3.6 Logistic Regression in Practice using Python................................... 228
6.3.6.1 Variable Descriptions........................................................ 231
6.3.6.2 Checking for Missing Values............................................. 231
6.3.6.3 Converting Categorical Variables to a
Dummy Indicator............................................................... 234
6.4 Decision Tree Classifier.................................................................................. 236
6.4.1 Important Terminology in the Decision Tree.................................... 236
6.4.2 Example for Decision Tree................................................................ 237
6.4.3 Sample Decision Tree........................................................................ 238
6.4.4 Decision Tree Formation................................................................... 238
6.4.5 Algorithms Used for Decision Trees.................................................240
6.4.5.1 ID3 Algorithm...................................................................240
6.4.5.2 C 4.5 Algorithm................................................................. 241
6.4.5.3 CART Algorithm............................................................... 241
6.4.6 Overfitting and Underfitting.............................................................. 241
6.4.6.1 Overfitting.......................................................................... 241
6.4.6.2 Underfitting........................................................................ 242
6.4.6.3 Pruning to Avoid Overfitting............................................. 243
6.4.7 Advantages and Disadvantages.........................................................244
6.4.7.1 Advantages.........................................................................244
6.4.7.2 Disadvantages....................................................................244
6.4.8 Decision Tree Examples.................................................................... 245
6.4.9 Regression Using Decision Tree....................................................... 262
6.4.10 Real-World Examples........................................................................266
6.4.10.1 Predicting Library Book....................................................266
6.4.10.2 Identification of Tumor...................................................... 267
6.4.10.3 Classification of Telescope Image..................................... 269
6.4.10.4 Business Management....................................................... 269
6.4.10.5 Fault Diagnosis.................................................................. 271
6.4.10.6 Healthcare Management.................................................... 271
6.4.10.7 Decision Tree in Data Mining........................................... 271
6.4.11 Decision Trees in Practice Using Python.......................................... 273
6.5 Random Forest Classifier............................................................................... 279
6.5.1 Random Forest and Their Construction............................................280
6.5.2 Sampling of the Dataset in Random Forest...................................... 281
6.5.2.1 Creation of Subset Data..................................................... 285
6.5.3 Pseudocode for Random Forest......................................................... 286
6.5.3.1 Pseudocode for Prediction in Random Forest................... 287
6.5.4 Regression Using Random Forest..................................................... 287
6.5.5 Classification Using Random Forest................................................. 288
6.5.5.1 Random Forest Problem for Classification – Examples.... 293
6.5.6 Features and Properties of Random Forest....................................... 295
Contents xi

6.5.6.1 Features.............................................................................. 295


6.5.6.2 Properties........................................................................... 296
6.5.7 Advantages and Disadvantages of Random Forest........................... 296
6.5.7.1 Advantages......................................................................... 296
6.5.7.2 Disadvantages.................................................................... 296
6.5.8 Calculation of Error Using Bias and Variance.................................. 296
6.5.8.1 Bias.................................................................................... 296
6.5.8.2 Variance............................................................................. 296
6.5.8.3 Properties of Bias and Variance........................................ 297
6.5.9 Time Complexity............................................................................... 297
6.5.10 Extremely Randomized Tree............................................................. 297
6.5.11 Real-World Examples........................................................................ 298
6.5.11.1 Machine Fault Diagnosis................................................... 298
6.5.11.2 Medical Field..................................................................... 298
6.5.11.3 Banking............................................................................. 299
6.5.11.4 E-Commerce......................................................................300
6.5.11.5 Security..............................................................................300
6.5.12 Random Forest in Practice Using Python.........................................300
6.6 Support Vector Machines...............................................................................306
6.6.1 Geometric Intuition...........................................................................307
6.6.2 Mathematical Formulation................................................................ 310
6.6.2.1 Maximize Margin with Noise........................................... 312
6.6.2.2 Slack Variable ξi ................................................................ 312
6.6.3 Loss Minimization............................................................................ 315
6.6.4 Dual Formulation.............................................................................. 317
6.6.5 The Kernel Trick............................................................................... 320
6.6.6 Polynomial Kernel............................................................................. 320
6.6.6.1 Mercer’s Theorem.............................................................. 322
6.6.6.2 Radial Basis Function (RBF) Kernel................................. 322
6.6.6.3 Other Domain-Specific Kernel.......................................... 323
6.6.6.4 Sigmoid Kernel.................................................................. 323
6.6.6.5 Exponential Kernel............................................................ 323
6.6.6.6 ANOVA Kernel.................................................................. 323
6.6.6.7 Rational Quadratic Kernel................................................. 323
6.6.6.8 Multiquadratic Kernel........................................................ 323
6.6.6.9 Inverse Multiquadratic Kernel........................................... 323
6.6.6.10 Circular Kernel.................................................................. 324
6.6.6.11 Bayesian Kernel................................................................. 324
6.6.6.12 Chi-Square Kernel............................................................. 324
6.6.6.13 Histogram Intersection Kernel.......................................... 324
6.6.6.14 Generalized Histogram Intersection Kernel...................... 324
6.6.7 nu SVM............................................................................................. 324
6.6.8 SVM Regression................................................................................ 325
6.6.9 One-Class SVM................................................................................ 326
6.6.10 Multiclass SVM................................................................................. 326
6.6.10.1 One against All.................................................................. 326
6.6.10.2 One against One................................................................ 327
6.6.10.3 Directed Acyclic Graph SVM........................................... 327
6.6.11 SVM Examples................................................................................. 328
6.6.12 Real-World Applications................................................................... 341
6.6.12.1 Classification of Cognitive Impairment............................. 341
xii Contents

6.6.12.2 Preprocessing..................................................................... 342


6.6.12.3 Feature Extraction............................................................. 342
6.6.12.4 SVM Classification............................................................ 342
6.6.12.5 Procedure........................................................................... 342
6.6.12.6 Performance Analysis........................................................ 343
6.6.12.7 Text Categorization............................................................ 343
6.6.12.8 Handwritten Optical Character Recognition.....................344
6.6.12.9 Natural Language Processing............................................344
6.6.12.10 Cancer Prediction.............................................................. 345
6.6.12.11 Stock Market Forecasting.................................................. 345
6.6.12.12 Protein Structure Prediction..............................................346
6.6.12.13 Face Detection Using SVM...............................................346
6.6.13 Advantages and Disadvantages of SVM........................................... 347
6.7 SVM Classification in Practice Using Python................................................ 347
6.7.1 Support Vectors................................................................................. 347
6.7.2 What Is a Hyperplane?......................................................................348
Summary................................................................................................................... 349
Review Questions...................................................................................................... 349

Chapter 7 Feature Engineering.................................................................................................. 351


7.1 Introduction.................................................................................................... 351
7.2 Feature Selection............................................................................................ 352
7.2.1 Wrapper Methods.............................................................................. 353
7.2.1.1 Forward Selection.............................................................. 353
7.2.1.2 Backward Elimination....................................................... 353
7.2.1.3 Exhaustive Feature Selection............................................. 354
7.2.2 Featured Methods.............................................................................. 354
7.3 Factor Analysis............................................................................................... 355
7.3.1 Types of Factor Analysis................................................................... 355
7.3.2 Working of Factor Analysis.............................................................. 355
7.3.3 Terminologies.................................................................................... 356
7.3.3.1 Definition of Factor............................................................ 356
7.3.3.2 Factor Loading................................................................... 356
7.3.3.3 Eigenvalues........................................................................ 356
7.3.3.4 Communalities................................................................... 356
7.3.3.5 Factor Rotation.................................................................. 356
7.3.3.6 Selecting the Number of Factors....................................... 356
7.4 Principal Component Analysis....................................................................... 357
7.4.1 Center the Data.................................................................................. 357
7.4.2 Normalize the Data........................................................................... 357
7.4.3 Estimate the Eigen decomposition.................................................... 357
7.4.4 Project the Data................................................................................. 357
7.5 Eigenvalues and PCA..................................................................................... 359
7.5.1 Usage of eigendecomposition in PCA............................................... 359
7.6 Feature Reduction........................................................................................... 361
7.6.1 Factor Analysis Vs. Principal Component Analysis......................... 362
7.7 PCA Transformation in Practice Using Python............................................. 362
7.8 Linear Discriminant Analysis........................................................................364
7.8.1 Mathematical Operations in LDA..................................................... 365
7.9 LDA Transformation in Practice Using Python............................................. 368
Contents xiii

7.9.1 Implementation of Scatter within the Class (Sw).............................. 368


7.9.2 Implementation of Scatter between Class (Sb).................................. 369
Summary................................................................................................................... 371
Review Questions...................................................................................................... 371

Chapter 8 Reinforcement Engineering...................................................................................... 373


8.1 Introduction.................................................................................................... 373
8.2 Reinforcement Learning................................................................................. 373
8.2.1 Examples of Reinforcement Learning.............................................. 375
8.3 How RL Differs from Other ML Algorithms?............................................... 376
8.3.1 Supervised Learning......................................................................... 376
8.4 Elements of Reinforcement Learning............................................................ 376
8.4.1 Policy................................................................................................. 376
8.4.2 Reward Signal................................................................................... 377
8.4.3 Value Function.................................................................................. 377
8.4.3.1 Examples of Rewards........................................................ 377
8.4.4 Model of the Environment................................................................ 378
8.4.5 The Reinforcement Learning Algorithm.......................................... 378
8.4.6 Methods to Implement Reinforcement Learning in ML................... 379
8.5 Markov Decision Process............................................................................... 379
8.5.1 Preliminaries..................................................................................... 379
8.5.2 Value Functions................................................................................. 380
8.6 Dynamic Programming.................................................................................. 381
8.6.1 Policy Evaluation............................................................................... 382
8.6.2 Policy Improvement.......................................................................... 383
8.6.3 Policy Iteration.................................................................................. 385
8.6.4 Efficiency of Dynamic Programming............................................... 385
8.6.5 Dynamic Programming in Practice using Python............................ 386
Summary................................................................................................................... 387
Review Questions...................................................................................................... 387

Chapter 9 Case Studies for Decision Sciences Using Python.................................................... 389


9.1 Use Case 1 − Retail Price Optimization Using Price Elasticity of
Demand Method............................................................................................. 389
9.1.1 Background....................................................................................... 389
9.1.2 Understanding the Data..................................................................... 390
9.1.3 Conclusion.........................................................................................400
9.2 Use Case 2 − Market Basket Analysis (MBA)................................................ 401
9.2.1 Introduction....................................................................................... 401
9.2.2 Understating the Data........................................................................ 401
9.2.3 Conclusion......................................................................................... 412
9.3 Use Case 3 − Sales Prediction of a Retailer.................................................... 412
9.3.1 Background....................................................................................... 412
9.3.2 Understanding the Data..................................................................... 413
9.3.3 Conclusion......................................................................................... 418
9.4 Use Case 4 − Predicting the Cost of Insurance Claims for a
Property and Causalty (P&C) Insurance Company....................................... 419
9.4.1 Background....................................................................................... 419
9.4.2 Understanding the Data..................................................................... 419
xiv Contents

9.5 Use Case 5 − E-Commerce Product Ranking and Sentiment Analysis.......... 430
9.5.1 Background....................................................................................... 430
9.5.2 Understanding the Data..................................................................... 431
Summary................................................................................................................... 441
Review Questions...................................................................................................... 442

Appendix: Python Cheat Sheet for Machine Learning............................................................. 443


Bibliography..................................................................................................................................449
Index............................................................................................................................................... 453
Discovering Diverse Content Through
Random Scribd Documents
W HAT, have I waked again? I never thought
To see the rosy dawn, or ev’n this grey,
Dull, solemn stillness, ere the dawn has come.
The lamp burns low; low burns the lamp of life:
The still morn stays expectant, and my soul,
All weighted with a passive wonderment,
Waiteth and watcheth, waiteth for the dawn.
Come hither, maids; too soundly have ye slept
That should have watched me; nay, I would not chide—
Oft have I chidden, yet I would not chide
In this last hour;—now all should be at peace.
I have been dreaming in a troubled sleep
Of weary days I thought not to recall;
Of stormy days, whose storms are hushed long since;
Of gladsome days, of sunny days; alas
In dreaming, all their sunshine seem’d so sad,
As though the current of the dark To-Be
Had flow’d, prophetic, through the happy hours.
And yet, full well, I know it was not thus;
I mind me sweetly of the summer days,
When, leaning from the lattice, I have caught
The fair, far glimpses of a shining sea;
And, nearer, of tall ships which thronged the bay,
And stood out blackly from a tender sky
All flecked with sulphur, azure, and bright gold;
And in the still, clear air have heard the hum
Of distant voices; and methinks there rose
No darker fount to mar or stain the joy
Which sprang ecstatic in my maiden breast
Than just those vague desires, those hopes and fears,
Those eager longings, strong, though undefined,
Whose very sadness makes them seem so sweet.
What cared I for the merry mockeries
Of other maidens sitting at the loom?
Or for sharp voices, bidding me return
To maiden labour? Were we not apart—
I and my high thoughts and my golden dreams
I and my high thoughts, and my golden dreams,
My soul which yearned for knowledge, for a tongue
That should proclaim the stately mysteries
Of this fair world, and of the holy gods?
Then followed days of sadness, as I grew
To learn my woman-mind had gone astray,
And I was sinning in those very thoughts—
For maidens, mark, such are not woman’s thoughts—
(And yet, ’tis strange, the gods who fashion us
Have given us such promptings)....
Fled the years,
Till seventeen had found me tall and strong,
And fairer, runs it, than Athenian maids
Are wont to seem; I had not learnt it well—
My lesson of dumb patience—and I stood
At Life’s great threshold with a beating heart,
And soul resolved to conquer and attain....
Once, walking ’thwart the crowded market-place,
With other maidens, bearing in the twigs
White doves for Aphrodite’s sacrifice,
I saw him, all ungainly and uncouth,
Yet many gathered round to hear his words,
Tall youths and stranger-maidens—Sokrates—
I saw his face and marked it, half with awe,
Half with a quick repulsion at the shape....
The richest gem lies hidden furthest down,
And is the dearer for the weary search;
We grasp the shining shells which strew the shore,
Yet swift we fling them from us; but the gem
We keep for aye and cherish. So a soul,
Found after weary searching in the flesh
Which half repelled our senses, is more dear,
For that same seeking, than the sunny mind
Which lavish Nature marks with thousand hints
Upon a brow of beauty. We are prone
To overweigh such subtle hints, then deem,
In after disappointment, we are fooled....
And when, at length, my father told me all,
Th I h ld d ih S k
That I should wed me with great Sokrates,
I, foolish, wept to see at once cast down
The maiden image of a future love,
Where perfect body matched the perfect soul.
But slowly, softly did I cease to weep;
Slowly I ’gan to mark the magic flash
Leap to the eyes, to watch the sudden smile
Break round the mouth, and linger in the eyes;
To listen for the voice’s lightest tone—
Great voice, whose cunning modulations seemed
Like to the notes of some sweet instrument.
So did I reach and strain, until at last
I caught the soul athwart the grosser flesh.
Again of thee, sweet Hope, my spirit dreamed!
I, guided by his wisdom and his love,
Led by his words, and counselled by his care,
Should lift the shrouding veil from things which be,
And at the flowing fountain of his soul
Refresh my thirsting spirit....
And indeed,
In those long days which followed that strange day
When rites and song, and sacrifice and flow’rs,
Proclaimed that we were wedded, did I learn,
In sooth, a-many lessons; bitter ones
Which sorrow taught me, and not love inspired,
Which deeper knowledge of my kind impressed
With dark insistence on reluctant brain;—
But that great wisdom, deeper, which dispels
Narrowed conclusions of a half-grown mind,
And sees athwart the littleness of life
Nature’s divineness and her harmony,
Was never poor Xantippe’s....
I would pause
And would recall no more, no more of life,
Than just the incomplete, imperfect dream
Of early summers, with their light and shade,
Their blossom-hopes, whose fruit was never ripe;
But something strong within me, some sad chord
g g ,
Which loudly echoes to the later life,
Me to unfold the after-misery
Urges, with plaintive wailing in my heart.
Yet, maidens, mark; I would not that ye thought
I blame my lord departed, for he meant
No evil, so I take it, to his wife.
’Twas only that the high philosopher,
Pregnant with noble theories and great thoughts,
Deigned not to stoop to touch so slight a thing
As the fine fabric of a woman’s brain—
So subtle as a passionate woman’s soul.
I think, if he had stooped a little, and cared,
I might have risen nearer to his height,
And not lain shattered, neither fit for use
As goodly household vessel, nor for that
Far finer thing which I had hoped to be....
Death, holding high his retrospective lamp,
Shows me those first, far years of wedded life,
Ere I had learnt to grasp the barren shape
Of what the Fates had destined for my life
Then, as all youthful spirits are, was I
Wholly incredulous that Nature meant
So little, who had promised me so much.
At first I fought my fate with gentle words,
With high endeavours after greater things;
Striving to win the soul of Sokrates,
Like some slight bird, who sings her burning love
To human master, till at length she finds
Her tender language wholly misconceived,
And that same hand whose kind caress she sought,
With fingers flippant flings the careless corn....
I do remember how, one summer’s eve,
He, seated in an arbour’s leafy shade,
Had bade me bring fresh wine-skins....
As I stood
Ling’ring upon the threshold, half concealed
By tender foliage, and my spirit light
With dra ghts of s nn eather did I mark
With draughts of sunny weather, did I mark
An instant the gay group before mine eyes.
Deepest in shade, and facing where I stood,
Sat Plato, with his calm face and low brows
Which met above the narrow Grecian eyes,
The pale, thin lips just parted to the smile,
Which dimpled that smooth olive of his cheek.
His head a little bent, sat Sokrates,
With one swart finger raised admonishing,
And on the air were borne his changing tones.
Low lounging at his feet, one fair arm thrown
Around his knee (the other, high in air
Brandish’d a brazen amphor, which yet rained
Bright drops of ruby on the golden locks
And temples with their fillets of the vine),
Lay Alkibiades the beautiful.
And thus, with solemn tone, spake Sokrates:
“This fair Aspasia, which our Perikles
Hath brought from realms afar, and set on high
In our Athenian city, hath a mind,
I doubt not, of a strength beyond her race;
And makes employ of it, beyond the way
Of women nobly gifted: woman’s frail—
Her body rarely stands the test of soul;
She grows intoxicate with knowledge; throws
The laws of custom, order,’neath her feet,
Feasting at life’s great banquet with wide throat.”
Then sudden, stepping from my leafy screen,
Holding the swelling wine-skin o’er my head,
With breast that heaved, and eyes and cheeks aflame,
Lit by a fury and a thought, I spake:
“By all great powers around us! can it be
That we poor women are empirical?
That gods who fashioned us did strive to make
Beings too fine, too subtly delicate,
With sense that thrilled response to ev’ry touch
Of nature’s, and their task is not complete?
That they have sent their half-completed work
To bleed and quiver here upon the earth?
To bleed and quiver, and to weep and weep,
To beat its soul against the marble walls
Of men’s cold hearts, and then at last to sin!”
I ceased, the first hot passion stayed and stemmed
And frighted by the silence: I could see,
Framed by the arbour foliage, which the sun
In setting softly gilded with rich gold,
Those upturned faces, and those placid limbs;
Saw Plato’s narrow eyes and niggard mouth,
Which half did smile and half did criticise,
One hand held up, the shapely fingers framed
To gesture of entreaty—“Hush, I pray,
Do not disturb her; let us hear the rest;
Follow her mood, for here’s another phase
Of your black-browed Xantippe....”
Then I saw
Young Alkibiades, with laughing lips
And half-shut eyes, contemptuous shrugging up
Soft, snowy shoulders, till he brought the gold
Of flowing ringlets round about his breasts.
But Sokrates, all slow and solemnly,
Raised, calm, his face to mine, and sudden spake:
“I thank thee for the wisdom which thy lips
Have thus let fall among us: prythee tell
From what high source, from what philosophies
Didst cull the sapient notion of thy words?”
Then stood I straight and silent for a breath,
Dumb, crushed with all that weight of cold contempt;
But swiftly in my bosom there uprose
A sudden flame, a merciful fury sent
To save me; with both angry hands I flung
The skin upon the marble, where it lay
Spouting red rills and fountains on the white;
Then, all unheeding faces, voices, eyes,
I fled across the threshold, hair unbound—
White garment stained to redness—beating heart
Flooded with all the flowing tide of hopes
Flooded with all the flowing tide of hopes
Which once had gushed out golden, now sent back
Swift to their sources, never more to rise....
I think I could have borne the weary life,
The narrow life within the narrow walls,
If he had loved me; but he kept his love
For this Athenian city and her sons;
And, haply, for some stranger-woman, bold
With freedom, thought, and glib philosophy....
Ah me! the long, long weeping through the nights,
The weary watching for the pale-eyed dawn
Which only brought fresh grieving: then I grew
Fiercer, and cursed from out my inmost heart
The Fates which marked me an Athenian maid.
Then faded that vain fury; hope died out;
A huge despair was stealing on my soul,
A sort of fierce acceptance of my fate,—
He wished a household vessel—well ’twas good,
For he should have it! He should have no more
The yearning treasure of a woman’s love,
But just the baser treasure which he sought.
I called my maidens, ordered out the loom,
And spun unceasing from the morn till eve;
Watching all keenly over warp and woof,
Weighing the white wool with a jealous hand.
I spun until, methinks, I spun away
The soul from out my body, the high thoughts
From out my spirit; till at last I grew
As ye have known me,—eye exact to mark
The texture of the spinning; ear all keen
For aimless talking when the moon is up,
And ye should be a-sleeping; tongue to cut
With quick incision, ’thwart the merry words
Of idle maidens....
Only yesterday
My hands did cease from spinning; I have wrought
My dreary duties, patient till the last.
The gods reward me! Nay, I will not tell
The after years of sorrow; wretched strife
With grimmest foes—sad Want and Poverty;—
Nor yet the time of horror, when they bore
My husband from the threshold; nay, nor when
The subtle weed had wrought its deadly work.
Alas! alas! I was not there to soothe
The last great moment; never any thought
Of her that loved him—save at least the charge,
All earthly, that her body should not starve....
You weep, you weep; I would not that ye wept;
Such tears are idle; with the young, such grief
Soon grows to gratulation, as, “her love
Was withered by misfortune; mine shall grow
All nurtured by the loving,” or, “her life
Was wrecked and shattered—mine shall smoothly sail.”
Enough, enough. In vain, in vain, in vain!
The gods forgive me! Sorely have I sinned
In all my life. A fairer fate befall
You all that stand there....
Ha! the dawn has come;
I see a rosy glimmer—nay! it grows dark;
Why stand ye so in silence? throw it wide,
The casement, quick; why tarry?—give me air—
O fling it wide, I say, and give me light!
Medea.

(A FRAGMENT IN DRAMA FORM, AFTER EURIPIDES.)

πάντων δ’ ὅσ’ ἔστ’ ἔμψυχα καὶ


γνώμην ἔχει γυναῖκές ἐσμεν
ἀθλιώτατον φυτόν:

PERSONS.
Medea. Jason.
}
Ægeus. Nikias. Citizens of Corinth.

Scene: Before Medea’s House.


[Enter Medea.]

Medea.
T O-DAY, to-day, I know not why it is,
I do bethink me of my Colchian home.
To-day, that I am lone and weary and sad,
I fain would call back days of pride and hope;
Of pride in strength, when strength was all unprov’d,
Of hope too high, too sweet, to be confined
In limits of conception.
I am sad
Here in this gracious city, whose white walls
Gleam snow-like in the sunlight; whose fair shrines
Are filled with wondrous images of gods;
Upon whose harbour’s bosom ride tall ships,
Black-masted, fraught with fragrant merchandise;
Whose straight-limbed people, in fair stuffs arrayed,
Do throng from morn till eve the sunny streets.
For what avail fair shrines and images?
What, cunning workmanship and purple robes?
Light of sweet sunlight, play and spray of waves?
When all around the air is charged and chill,
And all the place is drear and dark with hate?
Alas, alas, this people loves me not!
This strong, fair people, marble-cold and smooth
As modelled marble. I, an alien here,
That well can speak the language of their lips,
The language of their souls may never learn.
And in their hands, I, that did know myself
Ere now, a creature in whose veins ran blood
Redder, more rapid, than flows round most hearts,
Do seem a creature reft of life and soul.
If they would only teach the subtle trick
By which their hearts are melted into love,
I’d strive to learn it. I am very meek.
They think me proud, but I am very meek,
Ready to do their bidding. Hear me, friends!
Friends, I am very hungry, give me love!
’Tis all I ask! is it so hard to give?
You stand and front me with your hostile eyes;
You stand and front me with your hostile eyes;
You only give me hatred?
Yet I know
Ye are not all unloving. Oft I see
The men and women walking in the ways,
Hand within hand, and tender-bated breath,
On summer evenings when the sky is fair.
O men and women, are ye then so hard?
Will ye not give a little of your love
To me that am so hungry?

[Enter Ægeus and Nikias, on the opposite side. Medea steps back on the
threshold and pauses.]

Ha, that word!


’Tis Jason’s name they bandy to and fro.
I know not why, whene’er his name is spoke,
Once name of joy and ever name of love,
I wax white and do tremble; sudden seized
With shadowy apprehension. May’t forbode
No evil unto him I hold so dear;
And ever dearer with the waxing years:—
For this indeed is woman’s chiefest curse,
That still her constant heart clings to its love
Through all time and all chances; while the man
Is caught with newness; coldly calculates,
And measures pain and pleasure, loss and gain;
And ever grows to look with the world’s eye
Upon a woman, tho’ his, body and soul.
[She goes within.]

[The two citizens come forward.]

Nikias.
I, in this thing, do hold our Jason wise;
Kreon is mighty; Glaukê very fair.

Ægeus.

An ’twere for that—the Colchian’s fair enough.

Nikias.

I like not your swart skins and purple hair;


Your black, fierce eyes where the brows meet across.
By all the gods! when yonder Colchian
Fixes me with her strange and sudden gaze,
Each hair upon my body stands erect!
Zeus, ’tis a very tiger, and as mute!

Ægeus.

’Tis certain that the woman’s something strange.

Nikias.

Gods, spare me your strange women, so say I.


Give me gold hair, lithe limbs and gracious smiles,
And spare the strangeness.

Ægeus.
I do marvel much
How she will bear the tidings.

Nikias.

Lo, behold!
Here comes our Jason striding ’thwart the streets.
Gods! what a gracious presence!

Ægeus.

I perceive
The Colchian on the threshold. By her looks,
Our idle talk has reached her listening ears.

[Enter Jason. Medea reappears on the threshold.]

Nikias.

Let’s draw aside and mark them; lo, they meet.

[The two citizens withdraw, unperceived, to a further corner of the stage.]

Medea.

’Tis false, ’tis false. O Jason, they speak false!

Jason.
Your looks are wild, Medea; you bring shame
Upon this house, that stand with hair unbound
Beyond the threshold. Get you in the house.

Medea.

But not till you have answered me this thing.

Jason.

What is this thing that you would know of me?

Medea.

O I have heard strange rumours—horrible!

Jason.

Oft lies the horror of a tale in the ear


Of him that hears it. What is ’t you have heard?

Medea.
Almost, for fear, I dare not give it tongue.
But tell me this? Love, you have not forgot
The long years passed in this Corinthian home?
The great love I have borne you through the years?
Nor that far time when, in your mighty craft,
You came, a stranger, to the Colchian shore?
O strong you were; but not of such a strength
To have escaped the doom of horrid death,
Had not I, counting neither loss nor gain,
Shown you the way to triumph and renown.

Jason.

And better had I then, a thousand times,


Have fought with my good sword and fall’n or stood
As the high Fates directed; than been caught
In the close meshes of the magic web
Wrought by your hand, dark-thoughted sorceress.

Nikias.

Did you mark that? Jason speaks low and smooth;


Yet there is that within his level tones,
And in the icy drooping of his lids
(More than his words, tho’ they are harsh enough),
Tells me he hates her.

Ægeus.

Hush! Medea speaks.


Medea.

O gods, gods; ye have cursed me in this gift!


Is it for this, for this that I have striven?
Have wrestled in the darkness? wept my tears?
Have fought with sweet desires and hopes and thoughts?
Have watched when men were sleeping? for long days
Have shunned the sunlight and the breaths of Heaven?
Is it for this, for this that I have prayed
Long prayers, poured out with blood and cries and tears?
Lo, I who strove for strength have grown more weak
Than is the weakest. I have poured the sap
Of all my being, my life’s very life,
Before a thankless godhead; and am grown
No woman, but a monster. What avail
Charms, spells and potions, all my hard-won arts,
My mystic workings, seeing they cannot win
One little common spark of human love?
O gods, gods, ye have cursed me in this gift!
More should ye have withheld or more have giv’n;
Have fashioned me more weak or else more strong.
Behold me now, your work, a thing of fear—
From natural human fellowship cut off,
And yet a woman—sick and sore with pain;
Hungry for love and music of men’s praise,
But walled about as with a mighty wall,
Far from men’s reach and sight, alone, alone.

Nikias.

Behold her, how she waves about her arms


And casts her eyes to Heaven.

ÆGEUS.
Ay, ’tis strange—
Not as our women do, yet scarce unmeet.

Nikias.

Unmeet, unmeet? But Jason holds it so!


Mark you his white cheeks and his knitted brows,
What wrath and hate and scorn upon his face!

Jason.
Hear me, Medea, if you still can hear
That seem so strangely lifted from yourself:
But I, that know you long, do know you well,
A thing of moods and passions; so I bear
Once more with your wild words and savage gests,
Ay, and for all your fury speak you fair.
You say you love me. Can I deem it so,
When what does most advantage me and mine
You shrink to hear of? For I make no doubt,
Fleet-footed rumour did anticipate
The tidings I was hastening to bear,
When you, wide-eyed, unveiled, unfilleted,
Rushed out upon me.
Know then this once more:
That I have sworn to take as wedded wife
Glaukê, the daughter of our mighty king,
In this, in nowise hurting you and yours.
For you all fair provision I have made,
So but you get beyond the city walls
Before the night comes on. Our little ones—
They too shall journey with you. I have said.
And had I found you in a mood more mild,
Less swayed by savage passion, I had told
How this thing, which mayhap seems a thing hard,
Is but a blessing, wrapped and cloaked about
In harsh disguisements. For tho’ Kreon rule
To-day within the city; Kreon dead,
Who else shall rule there saving I alone,
The king’s son loved of him and other men?
And in those days Medea’s sons and mine
Shall stand at my right hand, grown great in power.
Medea, too, if she do but control
Her fiery spirit, may yet reign a queen
Above this land of Corinth. I have said.
Nikias.

Well said.

Ægeus.

But none the better that ’twas false.

Nikias.

I’d sooner speak, for my part, fair than true.


Mark Jason there; how firm his lithe, straight limbs;
How high his gold-curled head, crisped like a girl’s.
And yet for all his curled locks and smooth tones
Jason is very strong. I never knew
A man of such a strange and subtle strength.

Ægeus.

The Colchian speaks no word; and her swart hands,


Which waved, a moment since, and beat the air
In mad entreaty, are together clasped
Before her white robe in an iron clasp.
And her wild eyes, which erst did seek the heav’ns,
And now her lord and now again the earth,
Are set on space and move not. The tall shape
Stands there erect and still. This calm, I think,
Is filled with strangest portent.

Nikias.
O ye gods,
She is a pregnant horror as she stands.

Ægeus.

She speaks; her voice sounds as a sound far off.

Medea.
As you have said, O Jason, let it be.
I for my part am nothing loth to break
A compact never in fair justice framed,
Seeing how much one gave and one how much.
For you, you thought: This maid has served me well,
And yet may serve me. When I touch her palm
The blood is set a-tingle in my veins;
For these things I will make her body mine.
And I, I stood before you, clean and straight,
A woman some deemed fair and all deemed wise;
A woman, yet no simple thing nor slight,
By nature fashioned in no niggard mould;
And looked into your eyes with eyes that spake:
Lo, utterly, for ever, I am yours.
And since that you, this gift I lavish laid
Low at your feet, have lightly held and spurned—
I in my two arms, thus, shall gather it up
So that your feet may not encounter it
Which is not worthy for your feet to tread!
Yet pause a moment, Jason. Haply now
In some such wise as this your thoughts run on:
I loved this woman for a little space;
Alas, poor soul, she loved me but too well—
It is the way with women! Some, I think,
Did deem her fierce; gods! she was meek enough,
Content with what I gave; when I gave not
Nothing importunate.
Ah, Jason, pause.
You never knew Medea. You forget,
Because so long she bends the knee to you,
She was not born to serfdom.
I have knelt
Too long before you. I have stood too long
Suppliant before this people. You forget
A redder stream flows in my Colchian veins
Than the slow flood which courses round your hearts,
O cold Corinthians with whom I long have dwelt
O cold Corinthians, with whom I long have dwelt
And never ere this day have known myself.
Nor have ye known me. Now behold me free,
Ungyved by any chains of this man wrought;
Nothing desiring at your hands nor his.
Free, freer than the air or winged birds;
Strong, stronger than the blast of wintry storms;
And lifted up into an awful realm
Where is nor love, nor pity, nor remorse,
Nor dread, but only purpose.
There shall be
A horror and a horror in this land;
Woe upon woe, red blood and biting flame;
Most horrid death and anguish worse than death;
Deeds that shall make the shores of Hades sound
With murmured terror; with an awful dread
Shall move the generations yet unborn;
A horror and a horror in the land.

Jason.

Shrew, triple-linked with Hell, get you within.


Shame not my house! ’Tis your own harm you work.

[Medea goes within. Jason moves off slowly. Ægeus and Nikias go off
conferring in whispers.]

SCENE II.
[Time—After an interval; the evening of the same day. Scene—A street. A
crowd of people running to and fro.]

Nikias.

O horror, horror, have ye heard the tale?

Ægeus.
Alas, a bloody rumour reached mine ears
Of awful purport: that the king lies dead—

Nikias.

And by his side, his daughter; both caught up


In sudden toils of torment. With his grief
Jason is all distraught; behold her deed,
The swift and subtle tigress!

Ægeus.

Woe! Alas!
Woe for the state, woe for our Kreon slain,
For hapless Glaukê, for our Jason, woe!
But three times woe for her that did the deed—
Her womanhood sham’d; her children basely wrong’d.

Nikias.

Hold back your pity till the tale be told,


For never was there horror like to this.
Ere now in Corinth, haply, you have heard
How she did use for her crime’s instruments
The tender boys sprung from great Jason’s loins;
Bidding them bear the garments wrought in Hell
As bridal gifts to grace the marriage morn
Of gold-hair’d Glaukê. Serpent! Sorceress!

Ægeus.
Alas, consider; so the tigress springs
When that her cubs are menaced. ’Twas her love
That wrought the deed—evil, yet wrought for love.

Nikias.

Spare me such love. I never yet could deem,


Ev’n ere the horror, that Medea held
The love of human mothers in her breast.
For I have seen her, when her children played
Their innocent, aimless sports about her knees,
Or held her gown across the market-place,
Move all unheeding with her swart brows knit
And fierce eyes fixed; not, as is mothers’ wont,
Eager to note the winning infant ways,
A-strain to catch the babbling treble tones
Of soft lips clamouring for a kiss or smile.
And once I marked her (’twas a summer’s morn)
Turn suddenly and, stooping, catch and strain
One tender infant to her breast. She held
Her lips to his and looked into his eyes,
Not gladly, as a mother with her child,
But stirred by some strange passion; then the boy
Cried out with terror, and Medea wept.

Ægeus.

Your tale is strange.

Nikias.
Stranger is yet to come.
How that the Colchian did send forth her sons,
Innocent doers of most deadly deed,
Has reached your knowledge. When the deed was done,
And the dead king lay stretched upon the floor
Clutching his daughter in a last embrace,
Arose great clamour in the palace halls;
Wailing and cries of terror; women’s screams;
A rush of flying feet from hall to hall;
The clanging fall of brazen instruments
Upon the marble.
The two tender boys,
Half apprehending what thing had befallen,
Fled forth unmarked, and all affrighted reached
The house of Jason, where Medea stood
Erect upon the threshold. From afar
Sounded and surged the fiercely frighted roar
Of the roused city, and, like waves of the sea,
Grew nearer ev’ry beating of the pulse.
Forth from the inmost chambers fled the slaves,
Made fleet with sudden fear; the little ones
With arms outspread rushed to the Colchian,
And clung about her limbs and caught her robe,
Hiding their faces.
And Medea stood
Calm as a carven image. As the sound
Of wrath and lamentation drew more near,
The pale lips seemed to smile. But when she saw
Her children clinging round her, she stretched forth
One strong, swart hand and put the twain away,
And gathered up the trailing of her robe.
I saw the deed, I, Nikias, with these eyes!
Then spake she (Zeus! grant that I may not hear
Such tones once more from human lips!). She spake:
“I will not have ye, for I love ye not!”
Then all her face grew alien. Those around
Stood still not knowing what she planned
Stood still, not knowing what she planned.
Then she
Forth from her gathered garment swiftly drew
A thing that gleamed and glinted; in the air
She held it poised an instant; then—O gods!
How shall I speak it?—on the marble floor
Was blood that streamed and spurted; blood that flow’d
From two slain, innocent babes!

Ægeus.

O woful day!

Nikias.

Then brake a cry from all about: a wail


Of lamentation. But above the sound
A fierce long shriek, that froze the blood i’ the veins,
Rang out and rose, cleaving the topmost cloud.

Ægeus.

O evil deed! O essence of all evil


Stealing the shape of woman!

Nikias.
After that
All is confusion; from all sides surged up
The people, cursing, weeping. ’Thwart the din
Each other moment the strained ear might catch
Medea’s name, or Jason’s, or the King’s;
And women wailed out “Glaukê” through their tears.
Then sudden came a pause; the angry roar
Died down into a murmur; and the throng
Grew still, and rolled aside like a clov’n sea.
And Jason strode between them till he reached
His own home’s threshold where the twain lay dead,
Long gazed he on their faces; then he turned
To the hush’d people; turned to them and spake:
(His face was whiter than the dead’s, his eyes
Like to a creature’s that has looked on Hell)
“Where is the woman?” Lo, and when they sought
Medea, no eye beheld her. And no man
Had looked upon her since that moment’s space
When steel had flashed and blood foamed in the air.
Then Jason stood erect and spake again:
“Let no man seek this woman; blood enough
Has stained our city. Let the furies rend
Her guilty soul; nor we pollute our hands
With her accursèd body....”

Ægeus.

Cease, my friend;
It is enough. You judged this thing aright;
This woman was dark and evil in her soul;
Black to her fiend-heart’s root; a festering plague
In our fair city’s midst.

Nikias.

You might also like