├── .gitattributes ├── .gitignore ├── Chapter10 ├── ForceGraph.html ├── GDF2JSON.py ├── Male2FemaleRatio.py └── NodeDegreeAndHist.py ├── Chapter11 ├── GetFollowersByName.py ├── NaiveBayesTweetSentimenClassification.py ├── PlaceTrends.py ├── TimeLine.py └── TwitterQuery.py ├── Chapter12 ├── ComplexAggregation.py ├── MasiveInsertMongo.py ├── PipelineAggregation.py ├── SimpleAggregation.py └── SimpleGroup.py ├── Chapter13 ├── GroupAggregate.py ├── basketball-data.py ├── countingMapReduce.py ├── d3.layout.cloud.js ├── data.csv ├── filtering.py ├── summarization.py ├── word-cloud.html └── word-frecuency.py ├── Chapter14 ├── Basic Notebook.ipynb ├── Basic Notebook.py ├── Intro to Pandas.ipynb ├── Intro to Pandas.py └── iris.csv ├── Chapter2 ├── OpenRefineExcelData.csv ├── Regex.py ├── WebScraping.py ├── csvReader.py ├── csvReaderNumpy.py ├── jsonReader.py ├── pokemon.csv ├── pokemon.json └── pokemonXml.xml ├── Chapter3 ├── BarchartAnimated.html ├── Line-chart.html ├── MultiLine-chart.html ├── Pie-chart.html ├── Scatterplot.html ├── SumJson.py ├── bar-chart.html ├── line.csv ├── line.tsv ├── multiLine.csv ├── pokemon.json ├── pokemonByType.csv └── pokemonByType.tsv ├── Chapter4 ├── NaiveBayes.py ├── SubjectsExtraction.py ├── dataSpam.out ├── test.csv └── training.csv ├── Chapter5 └── DTW_Implementation.py ├── Chapter6 └── RandomWalk.html ├── Chapter7 ├── Gold.csv ├── KRR.py ├── matplotlibExample.py.txt ├── smoothFunction.py.txt ├── smoothKRR.py └── smoothTS.py ├── Chapter8 ├── PCA-SVM.py ├── PlotWineFeatures.py └── wine.data ├── Chapter9 ├── CellularSIRSmodel.html ├── Ode4SIRmodel.py └── PltRecordCAData.py └── README.md /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | *.sln merge=union 7 | *.csproj merge=union 8 | *.vbproj merge=union 9 | *.fsproj merge=union 10 | *.dbproj merge=union 11 | 12 | # Standard to msysgit 13 | *.doc diff=astextplain 14 | *.DOC diff=astextplain 15 | *.docx diff=astextplain 16 | *.DOCX diff=astextplain 17 | *.dot diff=astextplain 18 | *.DOT diff=astextplain 19 | *.pdf diff=astextplain 20 | *.PDF diff=astextplain 21 | *.rtf diff=astextplain 22 | *.RTF diff=astextplain 23 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ################# 2 | ## Eclipse 3 | ################# 4 | 5 | *.pydevproject 6 | .project 7 | .metadata 8 | bin/ 9 | tmp/ 10 | *.tmp 11 | *.bak 12 | *.swp 13 | *~.nib 14 | local.properties 15 | .classpath 16 | .settings/ 17 | .loadpath 18 | 19 | # External tool builders 20 | .externalToolBuilders/ 21 | 22 | # Locally stored "Eclipse launch configurations" 23 | *.launch 24 | 25 | # CDT-specific 26 | .cproject 27 | 28 | # PDT-specific 29 | .buildpath 30 | 31 | 32 | ################# 33 | ## Visual Studio 34 | ################# 35 | 36 | ## Ignore Visual Studio temporary files, build results, and 37 | ## files generated by popular Visual Studio add-ons. 38 | 39 | # User-specific files 40 | *.suo 41 | *.user 42 | *.sln.docstates 43 | 44 | # Build results 45 | 46 | [Dd]ebug/ 47 | [Rr]elease/ 48 | x64/ 49 | build/ 50 | [Bb]in/ 51 | [Oo]bj/ 52 | 53 | # MSTest test Results 54 | [Tt]est[Rr]esult*/ 55 | [Bb]uild[Ll]og.* 56 | 57 | *_i.c 58 | *_p.c 59 | *.ilk 60 | *.meta 61 | *.obj 62 | *.pch 63 | *.pdb 64 | *.pgc 65 | *.pgd 66 | *.rsp 67 | *.sbr 68 | *.tlb 69 | *.tli 70 | *.tlh 71 | *.tmp 72 | *.tmp_proj 73 | *.log 74 | *.vspscc 75 | *.vssscc 76 | .builds 77 | *.pidb 78 | *.log 79 | *.scc 80 | 81 | # Visual C++ cache files 82 | ipch/ 83 | *.aps 84 | *.ncb 85 | *.opensdf 86 | *.sdf 87 | *.cachefile 88 | 89 | # Visual Studio profiler 90 | *.psess 91 | *.vsp 92 | *.vspx 93 | 94 | # Guidance Automation Toolkit 95 | *.gpState 96 | 97 | # ReSharper is a .NET coding add-in 98 | _ReSharper*/ 99 | *.[Rr]e[Ss]harper 100 | 101 | # TeamCity is a build add-in 102 | _TeamCity* 103 | 104 | # DotCover is a Code Coverage Tool 105 | *.dotCover 106 | 107 | # NCrunch 108 | *.ncrunch* 109 | .*crunch*.local.xml 110 | 111 | # Installshield output folder 112 | [Ee]xpress/ 113 | 114 | # DocProject is a documentation generator add-in 115 | DocProject/buildhelp/ 116 | DocProject/Help/*.HxT 117 | DocProject/Help/*.HxC 118 | DocProject/Help/*.hhc 119 | DocProject/Help/*.hhk 120 | DocProject/Help/*.hhp 121 | DocProject/Help/Html2 122 | DocProject/Help/html 123 | 124 | # Click-Once directory 125 | publish/ 126 | 127 | # Publish Web Output 128 | *.Publish.xml 129 | *.pubxml 130 | 131 | # NuGet Packages Directory 132 | ## TODO: If you have NuGet Package Restore enabled, uncomment the next line 133 | #packages/ 134 | 135 | # Windows Azure Build Output 136 | csx 137 | *.build.csdef 138 | 139 | # Windows Store app package directory 140 | AppPackages/ 141 | 142 | # Others 143 | sql/ 144 | *.Cache 145 | ClientBin/ 146 | [Ss]tyle[Cc]op.* 147 | ~$* 148 | *~ 149 | *.dbmdl 150 | *.[Pp]ublish.xml 151 | *.pfx 152 | *.publishsettings 153 | 154 | # RIA/Silverlight projects 155 | Generated_Code/ 156 | 157 | # Backup & report files from converting an old project file to a newer 158 | # Visual Studio version. Backup files are not needed, because we have git ;-) 159 | _UpgradeReport_Files/ 160 | Backup*/ 161 | UpgradeLog*.XML 162 | UpgradeLog*.htm 163 | 164 | # SQL Server files 165 | App_Data/*.mdf 166 | App_Data/*.ldf 167 | 168 | ############# 169 | ## Windows detritus 170 | ############# 171 | 172 | # Windows image file caches 173 | Thumbs.db 174 | ehthumbs.db 175 | 176 | # Folder config file 177 | Desktop.ini 178 | 179 | # Recycle Bin used on file shares 180 | $RECYCLE.BIN/ 181 | 182 | # Mac crap 183 | .DS_Store 184 | 185 | 186 | ############# 187 | ## Python 188 | ############# 189 | 190 | *.py[co] 191 | 192 | # Packages 193 | *.egg 194 | *.egg-info 195 | dist/ 196 | build/ 197 | eggs/ 198 | parts/ 199 | var/ 200 | sdist/ 201 | develop-eggs/ 202 | .installed.cfg 203 | 204 | # Installer logs 205 | pip-log.txt 206 | 207 | # Unit test / coverage reports 208 | .coverage 209 | .tox 210 | 211 | #Translations 212 | *.mo 213 | 214 | #Mr Developer 215 | .mr.developer.cfg 216 | -------------------------------------------------------------------------------- /Chapter10/ForceGraph.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /Chapter10/GDF2JSON.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import json 3 | from io import StringIO 4 | 5 | nodes = np.genfromtxt("nodes.csv", dtype='object', delimiter=',', skip_header=1, 6 | usecols=(0,1,3)) 7 | 8 | links = np.genfromtxt("links.csv", dtype='object', delimiter=',', skip_header=1, 9 | usecols=(0,1)) 10 | 11 | for n in range(len(nodes)): 12 | for ls in range(len(links)): 13 | if nodes[n][0] == links[ls][0]: 14 | links[ls][0] = n 15 | 16 | if nodes[n][0] == links[ls][1]: 17 | links[ls][1] = n 18 | data ={} 19 | 20 | lst = [] 21 | for x in nodes: 22 | d = {} 23 | d["name"] = str(x[1]).replace("b'","").replace("'","") 24 | lst.append(d) 25 | 26 | data["nodes"] = lst 27 | 28 | lnks = [] 29 | 30 | for ls in links: 31 | d = {} 32 | d["source"] = ls[0] 33 | d["target"] = ls[1] 34 | lnks.append(d) 35 | 36 | data["links"] = lnks 37 | 38 | with open("newJson.json","w") as f: 39 | f.write(json.dumps(data)) 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /Chapter10/Male2FemaleRatio.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import operator 3 | from pylab import * 4 | 5 | nodes = np.genfromtxt("nodes.csv", dtype=str, delimiter=',', skip_header=1, 6 | usecols=(2)) 7 | 8 | 9 | counter = operator.countOf(nodes, 'male') 10 | male = (counter *100) / len(nodes) 11 | female = 100 - male 12 | print(female) 13 | 14 | figure(1, figsize=(6,6)) 15 | ax = axes([0.1, 0.1, 0.8, 0.8]) 16 | 17 | labels = 'Male', 'Female' 18 | fracs = [male,female] 19 | explode=(0, 0.05) 20 | 21 | pie(fracs, explode=explode, labels=labels, 22 | autopct='%1.1f%%', shadow=True, startangle=90) 23 | 24 | title('Male to Female Ratio', bbox={'facecolor':'0.8', 'pad':5}) 25 | 26 | show() 27 | -------------------------------------------------------------------------------- /Chapter10/NodeDegreeAndHist.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import matplotlib.pyplot as plt 3 | import operator 4 | 5 | links = np.genfromtxt("links.csv", dtype=str, delimiter=',', skip_header=1, 6 | usecols=(0,1)) 7 | 8 | dic = {} 9 | #Node Degree 10 | for n in sorted(np.reshape(links,558)): 11 | 12 | if n not in dic: 13 | dic[n] = 1 14 | else: 15 | dic[n] += 1 16 | 17 | size = len(dic) 18 | 19 | #Centrality 20 | sort = sorted(dic.items(), key=lambda x: x[1], reverse=True) 21 | 22 | plt.bar(range(size),list(dic.values())) 23 | plt.xticks(range(size), list(dic.keys()), rotation=90) 24 | plt.show() 25 | 26 | 27 | #Histogram 28 | histogram = {} 29 | 30 | for n in range(26): 31 | histogram[n] = operator.countOf(list(dic.values()), n) 32 | 33 | plt.plot(range(26),list(histogram.values())) 34 | plt.show() 35 | -------------------------------------------------------------------------------- /Chapter11/GetFollowersByName.py: -------------------------------------------------------------------------------- 1 | from twython import Twython 2 | 3 | ConsumerKey = "..." 4 | ConsumerSecret = "..." 5 | AccessToken = "..." 6 | AccessTokenSecret = "..." 7 | 8 | 9 | twitter = Twython(ConsumerKey, 10 | ConsumerSecret, 11 | AccessToken, 12 | AccessTokenSecret) 13 | 14 | 15 | followers = twitter.get_followers_list(screen_name="hmcuesta") 16 | 17 | for follower in followers["users"]: 18 | print(" user: {0} \n name: {1} \n Number of tweets: {2} " 19 | .format(follower["screen_name"], 20 | follower["name"], 21 | follower["statuses_count"])) 22 | 23 | -------------------------------------------------------------------------------- /Chapter11/NaiveBayesTweetSentimenClassification.py: -------------------------------------------------------------------------------- 1 | import nltk 2 | from twython import Twython 3 | 4 | 5 | def bagOfWords(tweets): 6 | wordsList = [] 7 | for (words, sentiment) in tweets: 8 | wordsList.extend(words) 9 | return wordsList 10 | 11 | def wordFeatures(wordList): 12 | wordList = nltk.FreqDist(wordList) 13 | wordFeatures = wordList.keys() 14 | return wordFeatures 15 | 16 | def getFeatures(doc): 17 | docWords = set(doc) 18 | feat = {} 19 | for word in wordFeatures: 20 | feat['contains(%s)' % word] = (word in docWords) 21 | return feat 22 | 23 | 24 | 25 | positiveTweets = [('...', 'positive'), 26 | ('...', 'positive'), 27 | ('...', 'positive'), 28 | ('...', 'positive'), 29 | ('...', 'positive')] 30 | 31 | 32 | negativeTweets = [('...', 'negative'), 33 | ('...', 'negative'), 34 | ('...', 'negative'), 35 | ('...', 'negative'), 36 | ('...', 'negative')] 37 | 38 | 39 | tweets = [] 40 | for (words, sentiment) in positiveTweets + negativeTweets: 41 | words_filtered = [e.lower() for e in nltk.word_tokenize(words) if len(e) >= 3] 42 | tweets.append((words_filtered, sentiment)) 43 | 44 | for t in tweets: 45 | print(t) 46 | 47 | wordFeatures = wordFeatures(bagOfWords(tweets)) 48 | 49 | training_set = nltk.classify.apply_features(getFeatures, tweets) 50 | 51 | classifier = nltk.NaiveBayesClassifier.train(training_set) 52 | 53 | print(classifier.show_most_informative_features(32)) 54 | 55 | 56 | ConsumerKey = "..." 57 | ConsumerSecret = "..." 58 | AccessToken = "..." 59 | AccessTokenSecret = "..." 60 | 61 | 62 | twitter = Twython(ConsumerKey, 63 | ConsumerSecret, 64 | AccessToken, 65 | AccessTokenSecret) 66 | 67 | queryText = "python" 68 | result = twitter.search(q=queryText) 69 | 70 | for status in result["statuses"]: 71 | print("Tweet: {0} \n Sentiment: {1} \n".format( status["text"], classifier.classify(extract_features( status["text"].split())))) 72 | 73 | -------------------------------------------------------------------------------- /Chapter11/PlaceTrends.py: -------------------------------------------------------------------------------- 1 | from twython import Twython 2 | 3 | ConsumerKey = "..." 4 | ConsumerSecret = "..." 5 | AccessToken = "..." 6 | AccessTokenSecret = "..." 7 | 8 | 9 | twitter = Twython(ConsumerKey, 10 | ConsumerSecret, 11 | AccessToken, 12 | AccessTokenSecret) 13 | 14 | 15 | 16 | result = twitter.get_place_trends(id = 23424977) 17 | 18 | if result: 19 | for trend in result[0].get("trends", []): 20 | print("{0} \n".format(trend["name"])) 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /Chapter11/TimeLine.py: -------------------------------------------------------------------------------- 1 | 2 | from twython import Twython 3 | 4 | 5 | ConsumerKey = "..." 6 | ConsumerSecret = "..." 7 | AccessToken = "..." 8 | AccessTokenSecret = "..." 9 | 10 | twitter = Twython(ConsumerKey, 11 | ConsumerSecret, 12 | AccessToken, 13 | AccessTokenSecret) 14 | 15 | 16 | time = twitter.get_user_timeline(screen_name = "stanfordeng", count = 5) 17 | for tweet in time: 18 | print(" User: {0} \n Created: {1} \n Text: {2} " 19 | .format(tweet["user"]["name"], 20 | tweet["created_at"], 21 | tweet["text"])) 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /Chapter11/TwitterQuery.py: -------------------------------------------------------------------------------- 1 | from twython import Twython 2 | 3 | ConsumerKey = "..." 4 | ConsumerSecret = "..." 5 | AccessToken = "..." 6 | AccessTokenSecret = "..." 7 | 8 | 9 | twitter = Twython(ConsumerKey, 10 | ConsumerSecret, 11 | AccessToken, 12 | AccessTokenSecret) 13 | 14 | 15 | result = twitter.search(q="python") 16 | 17 | for status in result["statuses"]: 18 | print("user: {0} text: {1}".format(status["user"]["name"], status["text"])) 19 | 20 | 21 | -------------------------------------------------------------------------------- /Chapter12/ComplexAggregation.py: -------------------------------------------------------------------------------- 1 | from pymongo import MongoClient 2 | 3 | con = MongoClient() 4 | db = con.Corpus 5 | tweets = db.tweets 6 | 7 | results = tweets.aggregate([ 8 | {"$group": {"_id": "$via", 9 | "avgId": {"$avg": "$id"} , 10 | "maxId": {"$max": "$id"} , 11 | "minId": {"$min": "$id"} , 12 | "count": {"$sum": 1}}} 13 | ]) 14 | 15 | for doc in results["result"]: 16 | print(doc) 17 | -------------------------------------------------------------------------------- /Chapter12/MasiveInsertMongo.py: -------------------------------------------------------------------------------- 1 | import json 2 | from pymongo import MongoClient 3 | 4 | con = MongoClient() 5 | db = con.Corpus 6 | tweets = db.tweets 7 | 8 | with open("test.txt") as f: 9 | data = json.loads(f.read()) 10 | 11 | for tweet in data["rows"]: 12 | tweets.insert(tweet) 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /Chapter12/PipelineAggregation.py: -------------------------------------------------------------------------------- 1 | from pymongo import MongoClient 2 | 3 | con = MongoClient() 4 | db = con.Corpus 5 | tweets = db.tweets 6 | 7 | 8 | results = tweets.aggregate([ 9 | {"$group": {"_id": "$via", 10 | "count": {"$sum": 1}}}, 11 | {"$sort": {"via":1}}, 12 | {"$limit":10}, 13 | 14 | 15 | ]) 16 | 17 | for doc in results["result"]: 18 | print(doc) 19 | -------------------------------------------------------------------------------- /Chapter12/SimpleAggregation.py: -------------------------------------------------------------------------------- 1 | from pymongo import MongoClient 2 | 3 | con = MongoClient() 4 | db = con.Corpus 5 | tweets = db.tweets 6 | 7 | 8 | results = tweets.aggregate([ 9 | {"$group": {"_id": "$sentiment", "count": {"$sum": 1}}} 10 | ]) 11 | 12 | 13 | for doc in results["result"]: 14 | print(doc) 15 | -------------------------------------------------------------------------------- /Chapter12/SimpleGroup.py: -------------------------------------------------------------------------------- 1 | from pymongo import MongoClient 2 | 3 | con = MongoClient() 4 | db = con.Corpus 5 | tweets = db.tweets 6 | 7 | results = tweets.group(key={"sentiment":1}, 8 | condition={"via": "kindle2"}, 9 | initial={"count": 0}, 10 | reduce="function(obj, prev){prev.count++;}") 11 | for doc in results: 12 | print(doc) 13 | 14 | #>>> 15 | #{'count': 181.0, 'sentiment': 4.0} 16 | #{'count': 177.0, 'sentiment': 0.0} 17 | #{'count': 139.0, 'sentiment': 2.0} 18 | #>>> 19 | -------------------------------------------------------------------------------- /Chapter13/GroupAggregate.py: -------------------------------------------------------------------------------- 1 | from bson.code import Code 2 | from pymongo import MongoClient 3 | 4 | con = MongoClient() 5 | db = con.baseball 6 | games = db.games 7 | 8 | map = Code("""function(){ 9 | emit(this.player, this.points); 10 | 11 | }""") 12 | 13 | reduce = Code("""function(key, values) { 14 | var explain = {total:Array.sum(values), 15 | max:Math.max.apply(Math, values), 16 | min:Math.min.apply(Math, values), 17 | avg:Array.sum(values)/values.length} 18 | return explain; 19 | }""") 20 | 21 | result = games.map_reduce(map,reduce,"_result") 22 | 23 | print(result) 24 | 25 | for p in db._result.find(): 26 | print(p) 27 | -------------------------------------------------------------------------------- /Chapter13/basketball-data.py: -------------------------------------------------------------------------------- 1 | import random as ran 2 | from pymongo import MongoClient 3 | 4 | con = MongoClient() 5 | db = con.baseball 6 | games = db.games 7 | 8 | 9 | players = ["LeBron James", 10 | "Allen Iverson", 11 | "Kobe Bryant", 12 | "Rick Barry", 13 | "Dominique Wilkins", 14 | "George Gervin", 15 | "Dwyane Wade", 16 | "Jerry West", 17 | "Pete Maravich", 18 | "Carmelo Anthony"] 19 | 20 | 21 | for x in range(100): 22 | games.insert({ "player" : players[ran.randint(0,9)], 23 | "points" : ran.randint(0,100)}) 24 | 25 | -------------------------------------------------------------------------------- /Chapter13/countingMapReduce.py: -------------------------------------------------------------------------------- 1 | from bson.code import Code 2 | from pymongo import MongoClient 3 | 4 | con = MongoClient() 5 | db = con.Corpus 6 | tweets = db.tweets 7 | 8 | map = Code("function(){ emit(this.via, 1); }") 9 | 10 | reduce = Code("""function(key, values) { 11 | var res = 0; 12 | values.forEach(function(v){ res += 1}) 13 | return {count: res}; 14 | }""") 15 | 16 | result = tweets.map_reduce(map,reduce,"via_count", full_response=True) 17 | 18 | print(result) 19 | 20 | for doc in db.via_count.find(): 21 | print(doc) 22 | -------------------------------------------------------------------------------- /Chapter13/d3.layout.cloud.js: -------------------------------------------------------------------------------- 1 | // Word cloud layout by Jason Davies, http://www.jasondavies.com/word-cloud/ 2 | // Algorithm due to Jonathan Feinberg, http://static.mrfeinberg.com/bv_ch03.pdf 3 | (function(exports) { 4 | function cloud() { 5 | var size = [256, 256], 6 | text = cloudText, 7 | font = cloudFont, 8 | fontSize = cloudFontSize, 9 | fontStyle = cloudFontNormal, 10 | fontWeight = cloudFontNormal, 11 | rotate = cloudRotate, 12 | padding = cloudPadding, 13 | spiral = archimedeanSpiral, 14 | words = [], 15 | timeInterval = Infinity, 16 | event = d3.dispatch("word", "end"), 17 | timer = null, 18 | cloud = {}; 19 | 20 | cloud.start = function() { 21 | var board = zeroArray((size[0] >> 5) * size[1]), 22 | bounds = null, 23 | n = words.length, 24 | i = -1, 25 | tags = [], 26 | data = words.map(function(d, i) { 27 | d.text = text.call(this, d, i); 28 | d.font = font.call(this, d, i); 29 | d.style = fontStyle.call(this, d, i); 30 | d.weight = fontWeight.call(this, d, i); 31 | d.rotate = rotate.call(this, d, i); 32 | d.size = ~~fontSize.call(this, d, i); 33 | d.padding = padding.call(this, d, i); 34 | return d; 35 | }).sort(function(a, b) { return b.size - a.size; }); 36 | 37 | if (timer) clearInterval(timer); 38 | timer = setInterval(step, 0); 39 | step(); 40 | 41 | return cloud; 42 | 43 | function step() { 44 | var start = +new Date, 45 | d; 46 | while (+new Date - start < timeInterval && ++i < n && timer) { 47 | d = data[i]; 48 | d.x = (size[0] * (Math.random() + .5)) >> 1; 49 | d.y = (size[1] * (Math.random() + .5)) >> 1; 50 | cloudSprite(d, data, i); 51 | if (d.hasText && place(board, d, bounds)) { 52 | tags.push(d); 53 | event.word(d); 54 | if (bounds) cloudBounds(bounds, d); 55 | else bounds = [{x: d.x + d.x0, y: d.y + d.y0}, {x: d.x + d.x1, y: d.y + d.y1}]; 56 | // Temporary hack 57 | d.x -= size[0] >> 1; 58 | d.y -= size[1] >> 1; 59 | } 60 | } 61 | if (i >= n) { 62 | cloud.stop(); 63 | event.end(tags, bounds); 64 | } 65 | } 66 | } 67 | 68 | cloud.stop = function() { 69 | if (timer) { 70 | clearInterval(timer); 71 | timer = null; 72 | } 73 | return cloud; 74 | }; 75 | 76 | cloud.timeInterval = function(x) { 77 | if (!arguments.length) return timeInterval; 78 | timeInterval = x == null ? Infinity : x; 79 | return cloud; 80 | }; 81 | 82 | function place(board, tag, bounds) { 83 | var perimeter = [{x: 0, y: 0}, {x: size[0], y: size[1]}], 84 | startX = tag.x, 85 | startY = tag.y, 86 | maxDelta = Math.sqrt(size[0] * size[0] + size[1] * size[1]), 87 | s = spiral(size), 88 | dt = Math.random() < .5 ? 1 : -1, 89 | t = -dt, 90 | dxdy, 91 | dx, 92 | dy; 93 | 94 | while (dxdy = s(t += dt)) { 95 | dx = ~~dxdy[0]; 96 | dy = ~~dxdy[1]; 97 | 98 | if (Math.min(dx, dy) > maxDelta) break; 99 | 100 | tag.x = startX + dx; 101 | tag.y = startY + dy; 102 | 103 | if (tag.x + tag.x0 < 0 || tag.y + tag.y0 < 0 || 104 | tag.x + tag.x1 > size[0] || tag.y + tag.y1 > size[1]) continue; 105 | // TODO only check for collisions within current bounds. 106 | if (!bounds || !cloudCollide(tag, board, size[0])) { 107 | if (!bounds || collideRects(tag, bounds)) { 108 | var sprite = tag.sprite, 109 | w = tag.width >> 5, 110 | sw = size[0] >> 5, 111 | lx = tag.x - (w << 4), 112 | sx = lx & 0x7f, 113 | msx = 32 - sx, 114 | h = tag.y1 - tag.y0, 115 | x = (tag.y + tag.y0) * sw + (lx >> 5), 116 | last; 117 | for (var j = 0; j < h; j++) { 118 | last = 0; 119 | for (var i = 0; i <= w; i++) { 120 | board[x + i] |= (last << msx) | (i < w ? (last = sprite[j * w + i]) >>> sx : 0); 121 | } 122 | x += sw; 123 | } 124 | delete tag.sprite; 125 | return true; 126 | } 127 | } 128 | } 129 | return false; 130 | } 131 | 132 | cloud.words = function(x) { 133 | if (!arguments.length) return words; 134 | words = x; 135 | return cloud; 136 | }; 137 | 138 | cloud.size = function(x) { 139 | if (!arguments.length) return size; 140 | size = [+x[0], +x[1]]; 141 | return cloud; 142 | }; 143 | 144 | cloud.font = function(x) { 145 | if (!arguments.length) return font; 146 | font = d3.functor(x); 147 | return cloud; 148 | }; 149 | 150 | cloud.fontStyle = function(x) { 151 | if (!arguments.length) return fontStyle; 152 | fontStyle = d3.functor(x); 153 | return cloud; 154 | }; 155 | 156 | cloud.fontWeight = function(x) { 157 | if (!arguments.length) return fontWeight; 158 | fontWeight = d3.functor(x); 159 | return cloud; 160 | }; 161 | 162 | cloud.rotate = function(x) { 163 | if (!arguments.length) return rotate; 164 | rotate = d3.functor(x); 165 | return cloud; 166 | }; 167 | 168 | cloud.text = function(x) { 169 | if (!arguments.length) return text; 170 | text = d3.functor(x); 171 | return cloud; 172 | }; 173 | 174 | cloud.spiral = function(x) { 175 | if (!arguments.length) return spiral; 176 | spiral = spirals[x + ""] || x; 177 | return cloud; 178 | }; 179 | 180 | cloud.fontSize = function(x) { 181 | if (!arguments.length) return fontSize; 182 | fontSize = d3.functor(x); 183 | return cloud; 184 | }; 185 | 186 | cloud.padding = function(x) { 187 | if (!arguments.length) return padding; 188 | padding = d3.functor(x); 189 | return cloud; 190 | }; 191 | 192 | return d3.rebind(cloud, event, "on"); 193 | } 194 | 195 | function cloudText(d) { 196 | return d.text; 197 | } 198 | 199 | function cloudFont() { 200 | return "serif"; 201 | } 202 | 203 | function cloudFontNormal() { 204 | return "normal"; 205 | } 206 | 207 | function cloudFontSize(d) { 208 | return Math.sqrt(d.value); 209 | } 210 | 211 | function cloudRotate() { 212 | return (~~(Math.random() * 6) - 3) * 30; 213 | } 214 | 215 | function cloudPadding() { 216 | return 1; 217 | } 218 | 219 | // Fetches a monochrome sprite bitmap for the specified text. 220 | // Load in batches for speed. 221 | function cloudSprite(d, data, di) { 222 | if (d.sprite) return; 223 | c.clearRect(0, 0, (cw << 5) / ratio, ch / ratio); 224 | var x = 0, 225 | y = 0, 226 | maxh = 0, 227 | n = data.length; 228 | --di; 229 | while (++di < n) { 230 | d = data[di]; 231 | c.save(); 232 | c.font = d.style + " " + d.weight + " " + ~~((d.size + 1) / ratio) + "px " + d.font; 233 | var w = c.measureText(d.text + "m").width * ratio, 234 | h = d.size << 1; 235 | if (d.rotate) { 236 | var sr = Math.sin(d.rotate * cloudRadians), 237 | cr = Math.cos(d.rotate * cloudRadians), 238 | wcr = w * cr, 239 | wsr = w * sr, 240 | hcr = h * cr, 241 | hsr = h * sr; 242 | w = (Math.max(Math.abs(wcr + hsr), Math.abs(wcr - hsr)) + 0x1f) >> 5 << 5; 243 | h = ~~Math.max(Math.abs(wsr + hcr), Math.abs(wsr - hcr)); 244 | } else { 245 | w = (w + 0x1f) >> 5 << 5; 246 | } 247 | if (h > maxh) maxh = h; 248 | if (x + w >= (cw << 5)) { 249 | x = 0; 250 | y += maxh; 251 | maxh = 0; 252 | } 253 | if (y + h >= ch) break; 254 | c.translate((x + (w >> 1)) / ratio, (y + (h >> 1)) / ratio); 255 | if (d.rotate) c.rotate(d.rotate * cloudRadians); 256 | c.fillText(d.text, 0, 0); 257 | if (d.padding) c.lineWidth = 2 * d.padding, c.strokeText(d.text, 0, 0); 258 | c.restore(); 259 | d.width = w; 260 | d.height = h; 261 | d.xoff = x; 262 | d.yoff = y; 263 | d.x1 = w >> 1; 264 | d.y1 = h >> 1; 265 | d.x0 = -d.x1; 266 | d.y0 = -d.y1; 267 | d.hasText = true; 268 | x += w; 269 | } 270 | var pixels = c.getImageData(0, 0, (cw << 5) / ratio, ch / ratio).data, 271 | sprite = []; 272 | while (--di >= 0) { 273 | d = data[di]; 274 | if (!d.hasText) continue; 275 | var w = d.width, 276 | w32 = w >> 5, 277 | h = d.y1 - d.y0; 278 | // Zero the buffer 279 | for (var i = 0; i < h * w32; i++) sprite[i] = 0; 280 | x = d.xoff; 281 | if (x == null) return; 282 | y = d.yoff; 283 | var seen = 0, 284 | seenRow = -1; 285 | for (var j = 0; j < h; j++) { 286 | for (var i = 0; i < w; i++) { 287 | var k = w32 * j + (i >> 5), 288 | m = pixels[((y + j) * (cw << 5) + (x + i)) << 2] ? 1 << (31 - (i % 32)) : 0; 289 | sprite[k] |= m; 290 | seen |= m; 291 | } 292 | if (seen) seenRow = j; 293 | else { 294 | d.y0++; 295 | h--; 296 | j--; 297 | y++; 298 | } 299 | } 300 | d.y1 = d.y0 + seenRow; 301 | d.sprite = sprite.slice(0, (d.y1 - d.y0) * w32); 302 | } 303 | } 304 | 305 | // Use mask-based collision detection. 306 | function cloudCollide(tag, board, sw) { 307 | sw >>= 5; 308 | var sprite = tag.sprite, 309 | w = tag.width >> 5, 310 | lx = tag.x - (w << 4), 311 | sx = lx & 0x7f, 312 | msx = 32 - sx, 313 | h = tag.y1 - tag.y0, 314 | x = (tag.y + tag.y0) * sw + (lx >> 5), 315 | last; 316 | for (var j = 0; j < h; j++) { 317 | last = 0; 318 | for (var i = 0; i <= w; i++) { 319 | if (((last << msx) | (i < w ? (last = sprite[j * w + i]) >>> sx : 0)) 320 | & board[x + i]) return true; 321 | } 322 | x += sw; 323 | } 324 | return false; 325 | } 326 | 327 | function cloudBounds(bounds, d) { 328 | var b0 = bounds[0], 329 | b1 = bounds[1]; 330 | if (d.x + d.x0 < b0.x) b0.x = d.x + d.x0; 331 | if (d.y + d.y0 < b0.y) b0.y = d.y + d.y0; 332 | if (d.x + d.x1 > b1.x) b1.x = d.x + d.x1; 333 | if (d.y + d.y1 > b1.y) b1.y = d.y + d.y1; 334 | } 335 | 336 | function collideRects(a, b) { 337 | return a.x + a.x1 > b[0].x && a.x + a.x0 < b[1].x && a.y + a.y1 > b[0].y && a.y + a.y0 < b[1].y; 338 | } 339 | 340 | function archimedeanSpiral(size) { 341 | var e = size[0] / size[1]; 342 | return function(t) { 343 | return [e * (t *= .1) * Math.cos(t), t * Math.sin(t)]; 344 | }; 345 | } 346 | 347 | function rectangularSpiral(size) { 348 | var dy = 4, 349 | dx = dy * size[0] / size[1], 350 | x = 0, 351 | y = 0; 352 | return function(t) { 353 | var sign = t < 0 ? -1 : 1; 354 | // See triangular numbers: T_n = n * (n + 1) / 2. 355 | switch ((Math.sqrt(1 + 4 * sign * t) - sign) & 3) { 356 | case 0: x += dx; break; 357 | case 1: y += dy; break; 358 | case 2: x -= dx; break; 359 | default: y -= dy; break; 360 | } 361 | return [x, y]; 362 | }; 363 | } 364 | 365 | // TODO reuse arrays? 366 | function zeroArray(n) { 367 | var a = [], 368 | i = -1; 369 | while (++i < n) a[i] = 0; 370 | return a; 371 | } 372 | 373 | var cloudRadians = Math.PI / 180, 374 | cw = 1 << 11 >> 5, 375 | ch = 1 << 11, 376 | canvas, 377 | ratio = 1; 378 | 379 | if (typeof document !== "undefined") { 380 | canvas = document.createElement("canvas"); 381 | canvas.width = 1; 382 | canvas.height = 1; 383 | ratio = Math.sqrt(canvas.getContext("2d").getImageData(0, 0, 1, 1).data.length >> 2); 384 | canvas.width = (cw << 5) / ratio; 385 | canvas.height = ch / ratio; 386 | } else { 387 | // node-canvas support 388 | var Canvas = require("canvas"); 389 | canvas = new Canvas(cw << 5, ch); 390 | } 391 | 392 | var c = canvas.getContext("2d"), 393 | spirals = { 394 | archimedean: archimedeanSpiral, 395 | rectangular: rectangularSpiral 396 | }; 397 | c.fillStyle = c.strokeStyle = "red"; 398 | c.textAlign = "center"; 399 | 400 | exports.cloud = cloud; 401 | })(typeof exports === "undefined" ? d3.layout || (d3.layout = {}) : exports); 402 | -------------------------------------------------------------------------------- /Chapter13/data.csv: -------------------------------------------------------------------------------- 1 | text,size 2 | love,58.0 3 | good,48.0 4 | just,48.0 5 | with,48.0 6 | have,47.0 7 | night,45.0 8 | from,43.0 9 | nike,43.0 10 | great,42.0 11 | lebron,42.0 12 | best,40.0 13 | museum,40.0 14 | google,39.0 15 | will,39.0 16 | &,38.0 17 | awesome,38.0 18 | malcolm,37.0 19 | much,37.0 20 | really,37.0 21 | stanford,37.0 22 | this,37.0 23 | your,37.0 24 | about,36.0 25 | bobby,36.0 26 | goodby,36.0 27 | kindle2,36.0 28 | last,36.0 29 | like,36.0 30 | obama,36.0 31 | using,36.0 32 | very,36.0 33 | want,36.0 34 | <3,35.0 35 | back,35.0 36 | happy,35.0 37 | kindle2.,35.0 38 | lakers,35.0 39 | than,35.0 40 | today,35.0 41 | warren,35.0 42 | watching,35.0 43 | went,35.0 44 | book,34.0 45 | buffet,34.0 46 | danny,34.0 47 | ever,34.0 48 | free,34.0 49 | gladwell,34.0 50 | going,34.0 51 | good.,34.0 52 | -------------------------------------------------------------------------------- /Chapter13/filtering.py: -------------------------------------------------------------------------------- 1 | from bson.code import Code 2 | from pymongo import MongoClient 3 | 4 | con = MongoClient() 5 | db = con.Corpus 6 | tweets = db.tweets 7 | 8 | map = Code("function(){ emit(this.via, 1); }") 9 | 10 | reduce = Code("""function(key, values) { 11 | var res = 0; 12 | values.forEach(function(v){ res += 1}) 13 | return {count: res}; 14 | }""") 15 | 16 | result = tweets.map_reduce(map,reduce,"filtering", limit = 100) 17 | 18 | print(result) 19 | 20 | for doc in db.filtering.find(): 21 | print(doc) 22 | -------------------------------------------------------------------------------- /Chapter13/summarization.py: -------------------------------------------------------------------------------- 1 | from bson.code import Code 2 | from pymongo import MongoClient 3 | 4 | con = MongoClient() 5 | db = con.baseball 6 | games = db.games 7 | 8 | map = Code("""function(){ 9 | emit(this.player, this.points); 10 | 11 | }""") 12 | 13 | reduce = Code("""function(key, values) { 14 | var explain = {total:Array.sum(values), 15 | max:Math.max.apply(Math, values), 16 | min:Math.min.apply(Math, values), 17 | avg:Array.sum(values)/values.length} 18 | return explain; 19 | }""") 20 | 21 | result = games.map_reduce(map,reduce,"_result",query= {"player":"Allen Iverson"}) 22 | 23 | print(result) 24 | 25 | for p in db._result.find(): 26 | print(p) 27 | -------------------------------------------------------------------------------- /Chapter13/word-cloud.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 44 | -------------------------------------------------------------------------------- /Chapter13/word-frecuency.py: -------------------------------------------------------------------------------- 1 | from bson.code import Code 2 | import csv 3 | from pymongo import MongoClient 4 | 5 | con = MongoClient() 6 | db = con.Corpus 7 | tweets = db.tweets 8 | 9 | map = Code("""function(){ 10 | this.text.split(' ').forEach( 11 | function(word){ 12 | var txt = word.toLowerCase(); 13 | if(!(/^@/).test(txt) && txt.length > 3 && !(/^http/).test(txt)){ 14 | emit(txt,1) 15 | } 16 | } 17 | ) 18 | }""") 19 | 20 | reduce = Code("""function(key, values) { 21 | var res = 0; 22 | values.forEach(function(v){ res += 1}) 23 | return {count: res}; 24 | }""") 25 | 26 | result = tweets.map_reduce(map,reduce,"TweetWords", query={"sentiment":4}) 27 | 28 | print(result) 29 | 30 | with open("data.csv", "w") as f: 31 | 32 | f_csv = csv.writer(f, delimiter=',') 33 | f_csv.writerow(["text","size"]) 34 | 35 | for doc in db.TweetWords.find().sort("value", direction = -1).limit(50): 36 | f_csv.writerow([doc["_id"],doc["value"]["count"]+30]) 37 | print(doc) 38 | -------------------------------------------------------------------------------- /Chapter14/Basic Notebook.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3.0 3 | 4 | # 5 | 6 | import random as r 7 | plot(range(100), [r.randint(0,10) for i in range(100) ]) 8 | 9 | # 10 | 11 | from PIL import Image 12 | import pylab 13 | dino = Image.open("412.jpg") 14 | pylab.imshow(dino) 15 | 16 | # 17 | 18 | land = Image.open("826.jpg") 19 | pylab.imshow(land) 20 | pylab.show() 21 | hist = land.histogram() 22 | pylab.hist(hist,bins=40) 23 | 24 | # 25 | 26 | from PIL import ImageFilter 27 | im1 = dino.filter(ImageFilter.BLUR) 28 | pylab.imshow(im1) 29 | 30 | # 31 | 32 | im2 = dino.filter(ImageFilter.FIND_EDGES) 33 | pylab.imshow(im2) 34 | 35 | # 36 | 37 | im3 = land.filter(ImageFilter.EDGE_ENHANCE_MORE) 38 | pylab.imshow(im3) 39 | 40 | # 41 | 42 | im4 = land.filter(ImageFilter.CONTOUR) 43 | pylab.imshow(im4) 44 | 45 | # 46 | 47 | from PIL import ImageOps 48 | im5 = ImageOps.invert(dino) 49 | pylab.imshow(im5) 50 | 51 | # 52 | 53 | im6 = ImageOps.grayscale(dino) 54 | pylab.imshow(im6) 55 | 56 | # 57 | 58 | im7 = ImageOps.solarize(dino, threshold=128) 59 | pylab.imshow(im7) 60 | 61 | # 62 | 63 | im8 = land.transpose(Image.ROTATE_270) 64 | pylab.imshow(im8) 65 | 66 | # 67 | 68 | im8 = land.transpose(Image.FLIP_TOP_BOTTOM) 69 | pylab.imshow(im8) 70 | 71 | # 72 | 73 | im9 = land.crop((20, 20, 200, 100)) 74 | pylab.imshow(im9) 75 | 76 | # 77 | 78 | 79 | -------------------------------------------------------------------------------- /Chapter14/Intro to Pandas.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3.0 3 | 4 | # 5 | 6 | import pandas as pd 7 | ts = pd.read_csv('Gold.csv', index_col=0, parse_dates=True) 8 | ts 9 | 10 | # 11 | 12 | ts.plot() 13 | 14 | # 15 | 16 | ts["2006":"2007"].plot(color = "green") 17 | 18 | # 19 | 20 | ts_res = ts.resample("A") 21 | ts_res.plot(style='g--') 22 | 23 | # 24 | 25 | ts_res = ts.resample("A", how=["mean", np.max, np.min]) 26 | ts_res.plot(subplots=True) 27 | ts_res.plot() 28 | 29 | # 30 | 31 | iris = pd.read_csv("iris.csv") 32 | pd.tools.plotting.radviz(iris, "name") 33 | 34 | # 35 | 36 | iris.head() 37 | 38 | # 39 | 40 | iris.describe() 41 | 42 | # 43 | 44 | iris.groupby("name").sum() 45 | 46 | # 47 | 48 | iris.groupby("name").max() 49 | 50 | # 51 | 52 | iris.groupby("name").min() 53 | 54 | # 55 | 56 | iris.groupby("name").describe() 57 | 58 | # 59 | 60 | iris["SepalLength"].corr(iris["PetalLength"]) 61 | 62 | # 63 | 64 | iris.corr() 65 | 66 | # 67 | 68 | 69 | -------------------------------------------------------------------------------- /Chapter14/iris.csv: -------------------------------------------------------------------------------- 1 | name,SepalLength,SepalWidth,PetalLength,PetalWidth 2 | setosa,5.1,3.5,1.4,0.2 3 | setosa,4.9,3,1.4,0.2 4 | setosa,4.7,3.2,1.3,0.2 5 | setosa,4.6,3.1,1.5,0.2 6 | setosa,5,3.6,1.4,0.2 7 | setosa,5.4,3.9,1.7,0.4 8 | setosa,4.6,3.4,1.4,0.3 9 | setosa,5,3.4,1.5,0.2 10 | setosa,4.4,2.9,1.4,0.2 11 | setosa,4.9,3.1,1.5,0.1 12 | setosa,5.4,3.7,1.5,0.2 13 | setosa,4.8,3.4,1.6,0.2 14 | setosa,4.8,3,1.4,0.1 15 | setosa,4.3,3,1.1,0.1 16 | setosa,5.8,4,1.2,0.2 17 | setosa,5.7,4.4,1.5,0.4 18 | setosa,5.4,3.9,1.3,0.4 19 | setosa,5.1,3.5,1.4,0.3 20 | setosa,5.7,3.8,1.7,0.3 21 | setosa,5.1,3.8,1.5,0.3 22 | setosa,5.4,3.4,1.7,0.2 23 | setosa,5.1,3.7,1.5,0.4 24 | setosa,4.6,3.6,1,0.2 25 | setosa,5.1,3.3,1.7,0.5 26 | setosa,4.8,3.4,1.9,0.2 27 | setosa,5,3,1.6,0.2 28 | setosa,5,3.4,1.6,0.4 29 | setosa,5.2,3.5,1.5,0.2 30 | setosa,5.2,3.4,1.4,0.2 31 | setosa,4.7,3.2,1.6,0.2 32 | setosa,4.8,3.1,1.6,0.2 33 | setosa,5.4,3.4,1.5,0.4 34 | setosa,5.2,4.1,1.5,0.1 35 | setosa,5.5,4.2,1.4,0.2 36 | setosa,4.9,3.1,1.5,0.2 37 | setosa,5,3.2,1.2,0.2 38 | setosa,5.5,3.5,1.3,0.2 39 | setosa,4.9,3.6,1.4,0.1 40 | setosa,4.4,3,1.3,0.2 41 | setosa,5.1,3.4,1.5,0.2 42 | setosa,5,3.5,1.3,0.3 43 | setosa,4.5,2.3,1.3,0.3 44 | setosa,4.4,3.2,1.3,0.2 45 | setosa,5,3.5,1.6,0.6 46 | setosa,5.1,3.8,1.9,0.4 47 | setosa,4.8,3,1.4,0.3 48 | setosa,5.1,3.8,1.6,0.2 49 | setosa,4.6,3.2,1.4,0.2 50 | setosa,5.3,3.7,1.5,0.2 51 | setosa,5,3.3,1.4,0.2 52 | versicolor,7,3.2,4.7,1.4 53 | versicolor,6.4,3.2,4.5,1.5 54 | versicolor,6.9,3.1,4.9,1.5 55 | versicolor,5.5,2.3,4,1.3 56 | versicolor,6.5,2.8,4.6,1.5 57 | versicolor,5.7,2.8,4.5,1.3 58 | versicolor,6.3,3.3,4.7,1.6 59 | versicolor,4.9,2.4,3.3,1 60 | versicolor,6.6,2.9,4.6,1.3 61 | versicolor,5.2,2.7,3.9,1.4 62 | versicolor,5,2,3.5,1 63 | versicolor,5.9,3,4.2,1.5 64 | versicolor,6,2.2,4,1 65 | versicolor,6.1,2.9,4.7,1.4 66 | versicolor,5.6,2.9,3.6,1.3 67 | versicolor,6.7,3.1,4.4,1.4 68 | versicolor,5.6,3,4.5,1.5 69 | versicolor,5.8,2.7,4.1,1 70 | versicolor,6.2,2.2,4.5,1.5 71 | versicolor,5.6,2.5,3.9,1.1 72 | versicolor,5.9,3.2,4.8,1.8 73 | versicolor,6.1,2.8,4,1.3 74 | versicolor,6.3,2.5,4.9,1.5 75 | versicolor,6.1,2.8,4.7,1.2 76 | versicolor,6.4,2.9,4.3,1.3 77 | versicolor,6.6,3,4.4,1.4 78 | versicolor,6.8,2.8,4.8,1.4 79 | versicolor,6.7,3,5,1.7 80 | versicolor,6,2.9,4.5,1.5 81 | versicolor,5.7,2.6,3.5,1 82 | versicolor,5.5,2.4,3.8,1.1 83 | versicolor,5.5,2.4,3.7,1 84 | versicolor,5.8,2.7,3.9,1.2 85 | versicolor,6,2.7,5.1,1.6 86 | versicolor,5.4,3,4.5,1.5 87 | versicolor,6,3.4,4.5,1.6 88 | versicolor,6.7,3.1,4.7,1.5 89 | versicolor,6.3,2.3,4.4,1.3 90 | versicolor,5.6,3,4.1,1.3 91 | versicolor,5.5,2.5,4,1.3 92 | versicolor,5.5,2.6,4.4,1.2 93 | versicolor,6.1,3,4.6,1.4 94 | versicolor,5.8,2.6,4,1.2 95 | versicolor,5,2.3,3.3,1 96 | versicolor,5.6,2.7,4.2,1.3 97 | versicolor,5.7,3,4.2,1.2 98 | versicolor,5.7,2.9,4.2,1.3 99 | versicolor,6.2,2.9,4.3,1.3 100 | versicolor,5.1,2.5,3,1.1 101 | versicolor,5.7,2.8,4.1,1.3 102 | virginica,6.3,3.3,6,2.5 103 | virginica,5.8,2.7,5.1,1.9 104 | virginica,7.1,3,5.9,2.1 105 | virginica,6.3,2.9,5.6,1.8 106 | virginica,6.5,3,5.8,2.2 107 | virginica,7.6,3,6.6,2.1 108 | virginica,4.9,2.5,4.5,1.7 109 | virginica,7.3,2.9,6.3,1.8 110 | virginica,6.7,2.5,5.8,1.8 111 | virginica,7.2,3.6,6.1,2.5 112 | virginica,6.5,3.2,5.1,2 113 | virginica,6.4,2.7,5.3,1.9 114 | virginica,6.8,3,5.5,2.1 115 | virginica,5.7,2.5,5,2 116 | virginica,5.8,2.8,5.1,2.4 117 | virginica,6.4,3.2,5.3,2.3 118 | virginica,6.5,3,5.5,1.8 119 | virginica,7.7,3.8,6.7,2.2 120 | virginica,7.7,2.6,6.9,2.3 121 | virginica,6,2.2,5,1.5 122 | virginica,6.9,3.2,5.7,2.3 123 | virginica,5.6,2.8,4.9,2 124 | virginica,7.7,2.8,6.7,2 125 | virginica,6.3,2.7,4.9,1.8 126 | virginica,6.7,3.3,5.7,2.1 127 | virginica,7.2,3.2,6,1.8 128 | virginica,6.2,2.8,4.8,1.8 129 | virginica,6.1,3,4.9,1.8 130 | virginica,6.4,2.8,5.6,2.1 131 | virginica,7.2,3,5.8,1.6 132 | virginica,7.4,2.8,6.1,1.9 133 | virginica,7.9,3.8,6.4,2 134 | virginica,6.4,2.8,5.6,2.2 135 | virginica,6.3,2.8,5.1,1.5 136 | virginica,6.1,2.6,5.6,1.4 137 | virginica,7.7,3,6.1,2.3 138 | virginica,6.3,3.4,5.6,2.4 139 | virginica,6.4,3.1,5.5,1.8 140 | virginica,6,3,4.8,1.8 141 | virginica,6.9,3.1,5.4,2.1 142 | virginica,6.7,3.1,5.6,2.4 143 | virginica,6.9,3.1,5.1,2.3 144 | virginica,5.8,2.7,5.1,1.9 145 | virginica,6.8,3.2,5.9,2.3 146 | virginica,6.7,3.3,5.7,2.5 147 | virginica,6.7,3,5.2,2.3 148 | virginica,6.3,2.5,5,1.9 149 | virginica,6.5,3,5.2,2 150 | virginica,6.2,3.4,5.4,2.3 151 | virginica,5.9,3,5.1,1.8 152 | -------------------------------------------------------------------------------- /Chapter2/OpenRefineExcelData.csv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hmcuesta/PDA_Book/52acc58b5a737d974990f9ec6d938013a240a64a/Chapter2/OpenRefineExcelData.csv -------------------------------------------------------------------------------- /Chapter2/Regex.py: -------------------------------------------------------------------------------- 1 | import re 2 | 3 | #Email Validation 4 | myString = 'From: readers@packt.com (readers email)' 5 | result = re.search('([\w.-]+)@([\w.-]+)', myString) 6 | if result: 7 | print (result.group(0)) ## 'alice-b@google.com' (the whole match) 8 | print (result.group(1)) ## 'alice-b' (the username, group 1) 9 | print (result.group(2)) ## 'google.com' (the host, group 2) 10 | 11 | # IP Address Validation 12 | isIP = re.compile('\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}') 13 | myString = "Your IP is: 192.168.1.254 " 14 | result = re.findall(isIP,myString) 15 | print(result) 16 | 17 | 18 | #Date Format 19 | myString = "01/04/2001" 20 | isDate = re.match('[0-1][0-9]\/[0-3][0-9]\/[1-2][0-9]{3}', myString) 21 | 22 | if isDate: 23 | print("valid") 24 | else: 25 | print("invalid") 26 | -------------------------------------------------------------------------------- /Chapter2/WebScraping.py: -------------------------------------------------------------------------------- 1 | from bs4 import BeautifulSoup 2 | import urllib.request 3 | from time import sleep 4 | from datetime import datetime 5 | 6 | def getGoldPrice(): 7 | url = "http://gold.org" 8 | req = urllib.request.urlopen(url) 9 | page = req.read() 10 | scraping = BeautifulSoup(page) 11 | price = scraping.findAll("td",attrs={"id":"spotpriceCellAsk"})[0].text 12 | return price 13 | 14 | 15 | with open("goldPrice.out","w") as f: 16 | for x in range(0,10): 17 | sNow = datetime.now().strftime("%I:%M:%S%p") 18 | f.write("{0}, {1} \n ".format(sNow, getGoldPrice())) 19 | sleep(1) 20 | -------------------------------------------------------------------------------- /Chapter2/csvReader.py: -------------------------------------------------------------------------------- 1 | import csv 2 | 3 | with open("pokemon.csv") as f: 4 | data = csv.reader(f) 5 | for line in data: 6 | print(" id: {0} , typeTwo: {1}, name: {2}, type: {3}" 7 | .format(line[0],line[1],line[2],line[3])) 8 | -------------------------------------------------------------------------------- /Chapter2/csvReaderNumpy.py: -------------------------------------------------------------------------------- 1 | import numpy 2 | 3 | data = numpy.genfromtxt("pokemon.csv" 4 | ,skip_header=1 5 | ,dtype=None 6 | ,delimiter=',') 7 | print(data) 8 | 9 | -------------------------------------------------------------------------------- /Chapter2/jsonReader.py: -------------------------------------------------------------------------------- 1 | import json 2 | from pprint import pprint 3 | 4 | with open("pokemon.json") as f: 5 | data = json.loads(f.read()) 6 | pprint(data) 7 | -------------------------------------------------------------------------------- /Chapter2/pokemon.csv: -------------------------------------------------------------------------------- 1 | id,typeTwo,name,type 2 | 001, Poison, Bulbasaur, Grass 3 | 002, Poison, Ivysaur, Grass 4 | 003, Poison, Venusaur, Grass 5 | 006, Flying, Charizard, Fire 6 | 012, Flying, Butterfree, Bug 7 | 013, Poison, Weedle, Bug 8 | 014, Poison, Kakuna, Bug 9 | 015, Poison, Beedrill, Bug 10 | 016, Flying, Pidgey, Normal 11 | 017, Flying, Pidgeotto, Normal 12 | 018, Flying, Pidgeot, Normal 13 | 021, Flying, Spearow, Normal 14 | 022, Flying, Fearow, Normal 15 | 031, Ground, Nidoqueen, Poison 16 | 034, Ground, Nidoking, Poison 17 | 041, Flying, Zubat, Poison 18 | 042, Flying, Golbat, Poison 19 | 043, Poison, Oddish, Grass 20 | 044, Poison, Gloom, Grass 21 | 045, Poison, Vileplume, Grass 22 | 046, Grass, Paras, Bug 23 | 047, Grass, Parasect, Bug 24 | 048, Poison, Venonat, Bug 25 | 049, Poison, Venomoth, Bug 26 | 062, Fighting, Poliwrath, Water 27 | 069, Poison, Bellsprout, Grass 28 | 070, Poison, Weepinbell, Grass 29 | 071, Poison, Victreebel, Grass 30 | 072, Poison, Tentacool, Water 31 | 073, Poison, Tentacruel, Water 32 | 074, Ground, Geodude, Rock 33 | 075, Ground, Graveler, Rock 34 | 076, Ground, Golem, Rock 35 | 079, Psychic, Slowpoke, Water 36 | 080, Psychic, Slowbro, Water 37 | 081, Steel, Magnemite, Electric 38 | 082, Steel, Magneton, Electric 39 | 083, Flying, Farfetch'd, Normal 40 | 084, Flying, Doduo, Normal 41 | 085, Flying, Dodrio, Normal 42 | 087, Ice, Dewgong, Water 43 | 091, Ice, Cloyster, Water 44 | 092, Poison, Gastly, Ghost 45 | 093, Poison, Haunter, Ghost 46 | 094, Poison, Gengar, Ghost 47 | 095, Ground, Onix, Rock 48 | 102, Psychic, Exeggcute, Grass 49 | 103, Psychic, Exeggutor, Grass 50 | 111, Rock, Rhyhorn, Ground 51 | 112, Rock, Rhydon, Ground 52 | 121, Psychic, Starmie, Water 53 | 123, Flying, Scyther, Bug 54 | 124, Psychic, Jynx, Ice 55 | 130, Flying, Gyarados, Water 56 | 131, Ice, Lapras, Water 57 | 138, Water, Omanyte, Rock 58 | 139, Water, Omastar, Rock 59 | 140, Water, Kabuto, Rock 60 | 141, Water, Kabutops, Rock 61 | 142, Flying, Aerodactyl, Rock 62 | 144, Flying, Articuno, Ice 63 | 145, Flying, Zapdos, Electric 64 | 146, Flying, Moltres, Fire 65 | 149, Flying, Dragonite, Dragon 66 | 163, Flying, Hoothoot, Normal 67 | 164, Flying, Noctowl, Normal 68 | 165, Flying, Ledyba, Bug 69 | 166, Flying, Ledian, Bug 70 | 167, Poison, Spinarak, Bug 71 | 168, Poison, Ariados, Bug 72 | 169, Flying, Crobat, Poison 73 | 170, Electric, Chinchou, Water 74 | 171, Electric, Lanturn, Water 75 | 176, Flying, Togetic, Normal 76 | 177, Flying, Natu, Psychic 77 | 178, Flying, Xatu, Psychic 78 | 187, Flying, Hoppip, Grass 79 | 188, Flying, Skiploom, Grass 80 | 189, Flying, Jumpluff, Grass 81 | 193, Flying, Yanma, Bug 82 | 194, Ground, Wooper, Water 83 | 195, Ground, Quagsire, Water 84 | 198, Flying, Murkrow, Dark 85 | 199, Psychic, Slowking, Water 86 | 203, Psychic, Girafarig, Normal 87 | 205, Steel, Forretress, Bug 88 | 207, Flying, Gligar, Ground 89 | 208, Ground, Steelix, Steel 90 | 211, Poison, Qwilfish, Water 91 | 212, Steel, Scizor, Bug 92 | 213, Rock, Shuckle, Bug 93 | 214, Fighting, Heracross, Bug 94 | 215, Ice, Sneasel, Dark 95 | 219, Rock, Magcargo, Fire 96 | 220, Ground, Swinub, Ice 97 | 221, Ground, Piloswine, Ice 98 | 222, Rock, Corsola, Water 99 | 225, Flying, Delibird, Ice 100 | 226, Flying, Mantine, Water 101 | 227, Flying, Skarmory, Steel 102 | 228, Fire, Houndour, Dark 103 | 229, Fire, Houndoom, Dark 104 | 230, Dragon, Kingdra, Water 105 | 238, Psychic, Smoochum, Ice 106 | 246, Ground, Larvitar, Rock 107 | 247, Ground, Pupitar, Rock 108 | 248, Dark, Tyranitar, Rock 109 | 249, Flying, Lugia, Psychic 110 | 250, Flying, Ho-Oh, Fire 111 | 251, Grass, Celebi, Psychic 112 | 256, Fighting, Combusken, Fire 113 | 257, Fighting, Blaziken, Fire 114 | 259, Ground, Marshtomp, Water 115 | 260, Ground, Swampert, Water 116 | 267, Flying, Beautifly, Bug 117 | 269, Poison, Dustox, Bug 118 | 270, Grass, Lotad, Water 119 | 271, Grass, Lombre, Water 120 | 272, Grass, Ludicolo, Water 121 | 274, Dark, Nuzleaf, Grass 122 | 275, Dark, Shiftry, Grass 123 | 276, Flying, Taillow, Normal 124 | 277, Flying, Swellow, Normal 125 | 278, Flying, Wingull, Water 126 | 279, Flying, Pelipper, Water 127 | 283, Water, Surskit, Bug 128 | 284, Flying, Masquerain, Bug 129 | 286, Fighting, Breloom, Grass 130 | 290, Ground, Nincada, Bug 131 | 291, Flying, Ninjask, Bug 132 | 292, Ghost, Shedinja, Bug 133 | 302, Ghost, Sableye, Dark 134 | 304, Rock, Aron, Steel 135 | 305, Rock, Lairon, Steel 136 | 306, Rock, Aggron, Steel 137 | 307, Psychic, Meditite, Fighting 138 | 308, Psychic, Medicham, Fighting 139 | 315, Poison, Roselia, Grass 140 | 318, Dark, Carvanha, Water 141 | 319, Dark, Sharpedo, Water 142 | 322, Ground, Numel, Fire 143 | 323, Ground, Camerupt, Fire 144 | 329, Dragon, Vibrava, Ground 145 | 330, Dragon, Flygon, Ground 146 | 332, Dark, Cacturne, Grass 147 | 333, Flying, Swablu, Normal 148 | 334, Flying, Altaria, Dragon 149 | 337, Psychic, Lunatone, Rock 150 | 338, Psychic, Solrock, Rock 151 | 339, Ground, Barboach, Water 152 | 340, Ground, Whiscash, Water 153 | 342, Dark, Crawdaunt, Water 154 | 343, Psychic, Baltoy, Ground 155 | 344, Psychic, Claydol, Ground 156 | 345, Grass, Lileep, Rock 157 | 346, Grass, Cradily, Rock 158 | 347, Bug, Anorith, Rock 159 | 348, Bug, Armaldo, Rock 160 | 357, Flying, Tropius, Grass 161 | 363, Water, Spheal, Ice 162 | 364, Water, Sealeo, Ice 163 | 365, Water, Walrein, Ice 164 | 369, Rock, Relicanth, Water 165 | 373, Flying, Salamence, Dragon 166 | 374, Psychic, Beldum, Steel 167 | 375, Psychic, Metang, Steel 168 | 376, Psychic, Metagross, Steel 169 | 380, Psychic, Latias, Dragon 170 | 381, Psychic, Latios, Dragon 171 | 384, Flying, Rayquaza, Dragon 172 | 385, Psychic, Jirachi, Steel 173 | 389, Ground, Torterra, Grass 174 | 391, Fighting, Monferno, Fire 175 | 392, Fighting, Infernape, Fire 176 | 395, Steel, Empoleon, Water 177 | 396, Flying, Starly, Normal 178 | 397, Flying, Staravia, Normal 179 | 398, Flying, Staraptor, Normal 180 | 400, Water, Bibarel, Normal 181 | 406, Poison, Budew, Grass 182 | 407, Poison, Roserade, Grass 183 | 410, Steel, Shieldon, Rock 184 | 411, Steel, Bastiodon, Rock 185 | 413, Steel, Wormadam, Bug 186 | 414, Flying, Mothim, Bug 187 | 415, Flying, Combee, Bug 188 | 416, Flying, Vespiquen, Bug 189 | 423, Ground, Gastrodon, Water 190 | 425, Flying, Drifloon, Ghost 191 | 426, Flying, Drifblim, Ghost 192 | 430, Flying, Honchkrow, Dark 193 | 434, Dark, Stunky, Poison 194 | 435, Dark, Skuntank, Poison 195 | 436, Psychic, Bronzor, Steel 196 | 437, Psychic, Bronzong, Steel 197 | 441, Flying, Chatot, Normal 198 | 442, Dark, Spiritomb, Ghost 199 | 443, Ground, Gible, Dragon 200 | 444, Ground, Gabite, Dragon 201 | 445, Ground, Garchomp, Dragon 202 | 448, Steel, Lucario, Fighting 203 | 451, Bug, Skorupi, Poison 204 | 452, Dark, Drapion, Poison 205 | 453, Fighting, Croagunk, Poison 206 | 454, Fighting, Toxicroak, Poison 207 | 458, Flying, Mantyke, Water 208 | 459, Ice, Snover, Grass 209 | 460, Ice, Abomasnow, Grass 210 | 461, Ice, Weavile, Dark 211 | 462, Steel, Magnezone, Electric 212 | 464, Rock, Rhyperior, Ground 213 | 468, Flying, Togekiss, Normal 214 | 469, Flying, Yanmega, Bug 215 | 472, Flying, Gliscor, Ground 216 | 473, Ground, Mamoswine, Ice 217 | 475, Fighting, Gallade, Psychic 218 | 476, Steel, Probopass, Rock 219 | 478, Ghost, Froslass, Ice 220 | 479, Grass, Rotom, Electric 221 | 483, Dragon, Dialga, Steel 222 | 484, Dragon, Palkia, Water 223 | 485, Steel, Heatran, Fire 224 | 487, Dragon, Giratina, Ghost 225 | 492, Flying, Shaymin, Grass 226 | 494, Fire, Victini, Psychic 227 | 499, Fighting, Pignite, Fire 228 | 500, Fighting, Emboar, Fire 229 | 519, Flying, Pidove, Normal 230 | 520, Flying, Tranquill, Normal 231 | 521, Flying, Unfezant, Normal 232 | 527, Flying, Woobat, Psychic 233 | 528, Flying, Swoobat, Psychic 234 | 530, Steel, Excadrill, Ground 235 | 536, Ground, Palpitoad, Water 236 | 537, Ground, Seismitoad, Water 237 | 540, Grass, Sewaddle, Bug 238 | 541, Grass, Swadloon, Bug 239 | 542, Grass, Leavanny, Bug 240 | 543, Poison, Venipede, Bug 241 | 544, Poison, Whirlipede, Bug 242 | 545, Poison, Scolipede, Bug 243 | 551, Dark, Sandile, Ground 244 | 552, Dark, Krokorok, Ground 245 | 553, Dark, Krookodile, Ground 246 | 555, Psychic, Darmanitan, Fire 247 | 557, Rock, Dwebble, Bug 248 | 558, Rock, Crustle, Bug 249 | 559, Fighting, Scraggy, Dark 250 | 560, Fighting, Scrafty, Dark 251 | 561, Flying, Sigilyph, Psychic 252 | 564, Rock, Tirtouga, Water 253 | 565, Rock, Carracosta, Water 254 | 566, Flying, Archen, Rock 255 | 567, Flying, Archeops, Rock 256 | 580, Flying, Ducklett, Water 257 | 581, Flying, Swanna, Water 258 | 585, Grass, Deerling, Normal 259 | 586, Grass, Sawsbuck, Normal 260 | 587, Flying, Emolga, Electric 261 | 589, Steel, Escavalier, Bug 262 | 590, Poison, Foongus, Grass 263 | 591, Poison, Amoonguss, Grass 264 | 592, Ghost, Frillish, Water 265 | 593, Ghost, Jellicent, Water 266 | 595, Electric, Joltik, Bug 267 | 596, Electric, Galvantula, Bug 268 | 597, Steel, Ferroseed, Grass 269 | 598, Steel, Ferrothorn, Grass 270 | 607, Fire, Litwick, Ghost 271 | 608, Fire, Lampent, Ghost 272 | 609, Fire, Chandelure, Ghost 273 | 618, Electric, Stunfisk, Ground 274 | 622, Ghost, Golett, Ground 275 | 623, Ghost, Golurk, Ground 276 | 624, Steel, Pawniard, Dark 277 | 625, Steel, Bisharp, Dark 278 | 627, Flying, Rufflet, Normal 279 | 628, Flying, Braviary, Normal 280 | 629, Flying, Vullaby, Dark 281 | 630, Flying, Mandibuzz, Dark 282 | 632, Steel, Durant, Bug 283 | 633, Dragon, Deino, Dark 284 | 634, Dragon, Zweilous, Dark 285 | 635, Dragon, Hydreigon, Dark 286 | 636, Fire, Larvesta, Bug 287 | 637, Fire, Volcarona, Bug 288 | 638, Fighting, Cobalion, Steel 289 | 639, Fighting, Terrakion, Rock 290 | 640, Fighting, Virizion, Grass 291 | 642, Flying, Thundurus, Electric 292 | 643, Fire, Reshiram, Dragon 293 | 644, Electric, Zekrom , Dragon 294 | 645, Flying, Landorus, Ground 295 | 646, Ice, Kyurem, Dragon 296 | 647, Fighting, Keldeo, Water 297 | 648, Fighting, Meloetta, Normal 298 | 649, Steel, Genesect, Bug 299 | -------------------------------------------------------------------------------- /Chapter2/pokemon.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": " 001", 4 | "typeTwo": " Poison", 5 | "name": " Bulbasaur", 6 | "type": " Grass" 7 | }, 8 | { 9 | "id": " 002", 10 | "typeTwo": " Poison", 11 | "name": " Ivysaur", 12 | "type": " Grass" 13 | }, 14 | { 15 | "id": " 003", 16 | "typeTwo": " Poison", 17 | "name": " Venusaur", 18 | "type": " Grass" 19 | }, 20 | { 21 | "id": " 006", 22 | "typeTwo": " Flying", 23 | "name": " Charizard", 24 | "type": " Fire" 25 | }, 26 | { 27 | "id": " 012", 28 | "typeTwo": " Flying", 29 | "name": " Butterfree", 30 | "type": " Bug" 31 | }, 32 | { 33 | "id": " 013", 34 | "typeTwo": " Poison", 35 | "name": " Weedle", 36 | "type": " Bug" 37 | }, 38 | { 39 | "id": " 014", 40 | "typeTwo": " Poison", 41 | "name": " Kakuna", 42 | "type": " Bug" 43 | }, 44 | { 45 | "id": " 015", 46 | "typeTwo": " Poison", 47 | "name": " Beedrill", 48 | "type": " Bug" 49 | }, 50 | { 51 | "id": " 016", 52 | "typeTwo": " Flying", 53 | "name": " Pidgey", 54 | "type": " Normal" 55 | }, 56 | { 57 | "id": " 017", 58 | "typeTwo": " Flying", 59 | "name": " Pidgeotto", 60 | "type": " Normal" 61 | }, 62 | { 63 | "id": " 018", 64 | "typeTwo": " Flying", 65 | "name": " Pidgeot", 66 | "type": " Normal" 67 | }, 68 | { 69 | "id": " 021", 70 | "typeTwo": " Flying", 71 | "name": " Spearow", 72 | "type": " Normal" 73 | }, 74 | { 75 | "id": " 022", 76 | "typeTwo": " Flying", 77 | "name": " Fearow", 78 | "type": " Normal" 79 | }, 80 | { 81 | "id": " 031", 82 | "typeTwo": " Ground", 83 | "name": " Nidoqueen", 84 | "type": " Poison" 85 | }, 86 | { 87 | "id": " 034", 88 | "typeTwo": " Ground", 89 | "name": " Nidoking", 90 | "type": " Poison" 91 | }, 92 | { 93 | "id": " 041", 94 | "typeTwo": " Flying", 95 | "name": " Zubat", 96 | "type": " Poison" 97 | }, 98 | { 99 | "id": " 042", 100 | "typeTwo": " Flying", 101 | "name": " Golbat", 102 | "type": " Poison" 103 | }, 104 | { 105 | "id": " 043", 106 | "typeTwo": " Poison", 107 | "name": " Oddish", 108 | "type": " Grass" 109 | }, 110 | { 111 | "id": " 044", 112 | "typeTwo": " Poison", 113 | "name": " Gloom", 114 | "type": " Grass" 115 | }, 116 | { 117 | "id": " 045", 118 | "typeTwo": " Poison", 119 | "name": " Vileplume", 120 | "type": " Grass" 121 | }, 122 | { 123 | "id": " 046", 124 | "typeTwo": " Grass", 125 | "name": " Paras", 126 | "type": " Bug" 127 | }, 128 | { 129 | "id": " 047", 130 | "typeTwo": " Grass", 131 | "name": " Parasect", 132 | "type": " Bug" 133 | }, 134 | { 135 | "id": " 048", 136 | "typeTwo": " Poison", 137 | "name": " Venonat", 138 | "type": " Bug" 139 | }, 140 | { 141 | "id": " 049", 142 | "typeTwo": " Poison", 143 | "name": " Venomoth", 144 | "type": " Bug" 145 | }, 146 | { 147 | "id": " 062", 148 | "typeTwo": " Fighting", 149 | "name": " Poliwrath", 150 | "type": " Water" 151 | }, 152 | { 153 | "id": " 069", 154 | "typeTwo": " Poison", 155 | "name": " Bellsprout", 156 | "type": " Grass" 157 | }, 158 | { 159 | "id": " 070", 160 | "typeTwo": " Poison", 161 | "name": " Weepinbell", 162 | "type": " Grass" 163 | }, 164 | { 165 | "id": " 071", 166 | "typeTwo": " Poison", 167 | "name": " Victreebel", 168 | "type": " Grass" 169 | }, 170 | { 171 | "id": " 072", 172 | "typeTwo": " Poison", 173 | "name": " Tentacool", 174 | "type": " Water" 175 | }, 176 | { 177 | "id": " 073", 178 | "typeTwo": " Poison", 179 | "name": " Tentacruel", 180 | "type": " Water" 181 | }, 182 | { 183 | "id": " 074", 184 | "typeTwo": " Ground", 185 | "name": " Geodude", 186 | "type": " Rock" 187 | }, 188 | { 189 | "id": " 075", 190 | "typeTwo": " Ground", 191 | "name": " Graveler", 192 | "type": " Rock" 193 | }, 194 | { 195 | "id": " 076", 196 | "typeTwo": " Ground", 197 | "name": " Golem", 198 | "type": " Rock" 199 | }, 200 | { 201 | "id": " 079", 202 | "typeTwo": " Psychic", 203 | "name": " Slowpoke", 204 | "type": " Water" 205 | }, 206 | { 207 | "id": " 080", 208 | "typeTwo": " Psychic", 209 | "name": " Slowbro", 210 | "type": " Water" 211 | }, 212 | { 213 | "id": " 081", 214 | "typeTwo": " Steel", 215 | "name": " Magnemite", 216 | "type": " Electric" 217 | }, 218 | { 219 | "id": " 082", 220 | "typeTwo": " Steel", 221 | "name": " Magneton", 222 | "type": " Electric" 223 | }, 224 | { 225 | "id": " 083", 226 | "typeTwo": " Flying", 227 | "name": " Farfetch'd", 228 | "type": " Normal" 229 | }, 230 | { 231 | "id": " 084", 232 | "typeTwo": " Flying", 233 | "name": " Doduo", 234 | "type": " Normal" 235 | }, 236 | { 237 | "id": " 085", 238 | "typeTwo": " Flying", 239 | "name": " Dodrio", 240 | "type": " Normal" 241 | }, 242 | { 243 | "id": " 087", 244 | "typeTwo": " Ice", 245 | "name": " Dewgong", 246 | "type": " Water" 247 | }, 248 | { 249 | "id": " 091", 250 | "typeTwo": " Ice", 251 | "name": " Cloyster", 252 | "type": " Water" 253 | }, 254 | { 255 | "id": " 092", 256 | "typeTwo": " Poison", 257 | "name": " Gastly", 258 | "type": " Ghost" 259 | }, 260 | { 261 | "id": " 093", 262 | "typeTwo": " Poison", 263 | "name": " Haunter", 264 | "type": " Ghost" 265 | }, 266 | { 267 | "id": " 094", 268 | "typeTwo": " Poison", 269 | "name": " Gengar", 270 | "type": " Ghost" 271 | }, 272 | { 273 | "id": " 095", 274 | "typeTwo": " Ground", 275 | "name": " Onix", 276 | "type": " Rock" 277 | }, 278 | { 279 | "id": " 102", 280 | "typeTwo": " Psychic", 281 | "name": " Exeggcute", 282 | "type": " Grass" 283 | }, 284 | { 285 | "id": " 103", 286 | "typeTwo": " Psychic", 287 | "name": " Exeggutor", 288 | "type": " Grass" 289 | }, 290 | { 291 | "id": " 111", 292 | "typeTwo": " Rock", 293 | "name": " Rhyhorn", 294 | "type": " Ground" 295 | }, 296 | { 297 | "id": " 112", 298 | "typeTwo": " Rock", 299 | "name": " Rhydon", 300 | "type": " Ground" 301 | }, 302 | { 303 | "id": " 121", 304 | "typeTwo": " Psychic", 305 | "name": " Starmie", 306 | "type": " Water" 307 | }, 308 | { 309 | "id": " 123", 310 | "typeTwo": " Flying", 311 | "name": " Scyther", 312 | "type": " Bug" 313 | }, 314 | { 315 | "id": " 124", 316 | "typeTwo": " Psychic", 317 | "name": " Jynx", 318 | "type": " Ice" 319 | }, 320 | { 321 | "id": " 130", 322 | "typeTwo": " Flying", 323 | "name": " Gyarados", 324 | "type": " Water" 325 | }, 326 | { 327 | "id": " 131", 328 | "typeTwo": " Ice", 329 | "name": " Lapras", 330 | "type": " Water" 331 | }, 332 | { 333 | "id": " 138", 334 | "typeTwo": " Water", 335 | "name": " Omanyte", 336 | "type": " Rock" 337 | }, 338 | { 339 | "id": " 139", 340 | "typeTwo": " Water", 341 | "name": " Omastar", 342 | "type": " Rock" 343 | }, 344 | { 345 | "id": " 140", 346 | "typeTwo": " Water", 347 | "name": " Kabuto", 348 | "type": " Rock" 349 | }, 350 | { 351 | "id": " 141", 352 | "typeTwo": " Water", 353 | "name": " Kabutops", 354 | "type": " Rock" 355 | }, 356 | { 357 | "id": " 142", 358 | "typeTwo": " Flying", 359 | "name": " Aerodactyl", 360 | "type": " Rock" 361 | }, 362 | { 363 | "id": " 144", 364 | "typeTwo": " Flying", 365 | "name": " Articuno", 366 | "type": " Ice" 367 | }, 368 | { 369 | "id": " 145", 370 | "typeTwo": " Flying", 371 | "name": " Zapdos", 372 | "type": " Electric" 373 | }, 374 | { 375 | "id": " 146", 376 | "typeTwo": " Flying", 377 | "name": " Moltres", 378 | "type": " Fire" 379 | }, 380 | { 381 | "id": " 149", 382 | "typeTwo": " Flying", 383 | "name": " Dragonite", 384 | "type": " Dragon" 385 | }, 386 | { 387 | "id": " 163", 388 | "typeTwo": " Flying", 389 | "name": " Hoothoot", 390 | "type": " Normal" 391 | }, 392 | { 393 | "id": " 164", 394 | "typeTwo": " Flying", 395 | "name": " Noctowl", 396 | "type": " Normal" 397 | }, 398 | { 399 | "id": " 165", 400 | "typeTwo": " Flying", 401 | "name": " Ledyba", 402 | "type": " Bug" 403 | }, 404 | { 405 | "id": " 166", 406 | "typeTwo": " Flying", 407 | "name": " Ledian", 408 | "type": " Bug" 409 | }, 410 | { 411 | "id": " 167", 412 | "typeTwo": " Poison", 413 | "name": " Spinarak", 414 | "type": " Bug" 415 | }, 416 | { 417 | "id": " 168", 418 | "typeTwo": " Poison", 419 | "name": " Ariados", 420 | "type": " Bug" 421 | }, 422 | { 423 | "id": " 169", 424 | "typeTwo": " Flying", 425 | "name": " Crobat", 426 | "type": " Poison" 427 | }, 428 | { 429 | "id": " 170", 430 | "typeTwo": " Electric", 431 | "name": " Chinchou", 432 | "type": " Water" 433 | }, 434 | { 435 | "id": " 171", 436 | "typeTwo": " Electric", 437 | "name": " Lanturn", 438 | "type": " Water" 439 | }, 440 | { 441 | "id": " 176", 442 | "typeTwo": " Flying", 443 | "name": " Togetic", 444 | "type": " Normal" 445 | }, 446 | { 447 | "id": " 177", 448 | "typeTwo": " Flying", 449 | "name": " Natu", 450 | "type": " Psychic" 451 | }, 452 | { 453 | "id": " 178", 454 | "typeTwo": " Flying", 455 | "name": " Xatu", 456 | "type": " Psychic" 457 | }, 458 | { 459 | "id": " 187", 460 | "typeTwo": " Flying", 461 | "name": " Hoppip", 462 | "type": " Grass" 463 | }, 464 | { 465 | "id": " 188", 466 | "typeTwo": " Flying", 467 | "name": " Skiploom", 468 | "type": " Grass" 469 | }, 470 | { 471 | "id": " 189", 472 | "typeTwo": " Flying", 473 | "name": " Jumpluff", 474 | "type": " Grass" 475 | }, 476 | { 477 | "id": " 193", 478 | "typeTwo": " Flying", 479 | "name": " Yanma", 480 | "type": " Bug" 481 | }, 482 | { 483 | "id": " 194", 484 | "typeTwo": " Ground", 485 | "name": " Wooper", 486 | "type": " Water" 487 | }, 488 | { 489 | "id": " 195", 490 | "typeTwo": " Ground", 491 | "name": " Quagsire", 492 | "type": " Water" 493 | }, 494 | { 495 | "id": " 198", 496 | "typeTwo": " Flying", 497 | "name": " Murkrow", 498 | "type": " Dark" 499 | }, 500 | { 501 | "id": " 199", 502 | "typeTwo": " Psychic", 503 | "name": " Slowking", 504 | "type": " Water" 505 | }, 506 | { 507 | "id": " 203", 508 | "typeTwo": " Psychic", 509 | "name": " Girafarig", 510 | "type": " Normal" 511 | }, 512 | { 513 | "id": " 205", 514 | "typeTwo": " Steel", 515 | "name": " Forretress", 516 | "type": " Bug" 517 | }, 518 | { 519 | "id": " 207", 520 | "typeTwo": " Flying", 521 | "name": " Gligar", 522 | "type": " Ground" 523 | }, 524 | { 525 | "id": " 208", 526 | "typeTwo": " Ground", 527 | "name": " Steelix", 528 | "type": " Steel" 529 | }, 530 | { 531 | "id": " 211", 532 | "typeTwo": " Poison", 533 | "name": " Qwilfish", 534 | "type": " Water" 535 | }, 536 | { 537 | "id": " 212", 538 | "typeTwo": " Steel", 539 | "name": " Scizor", 540 | "type": " Bug" 541 | }, 542 | { 543 | "id": " 213", 544 | "typeTwo": " Rock", 545 | "name": " Shuckle", 546 | "type": " Bug" 547 | }, 548 | { 549 | "id": " 214", 550 | "typeTwo": " Fighting", 551 | "name": " Heracross", 552 | "type": " Bug" 553 | }, 554 | { 555 | "id": " 215", 556 | "typeTwo": " Ice", 557 | "name": " Sneasel", 558 | "type": " Dark" 559 | }, 560 | { 561 | "id": " 219", 562 | "typeTwo": " Rock", 563 | "name": " Magcargo", 564 | "type": " Fire" 565 | }, 566 | { 567 | "id": " 220", 568 | "typeTwo": " Ground", 569 | "name": " Swinub", 570 | "type": " Ice" 571 | }, 572 | { 573 | "id": " 221", 574 | "typeTwo": " Ground", 575 | "name": " Piloswine", 576 | "type": " Ice" 577 | }, 578 | { 579 | "id": " 222", 580 | "typeTwo": " Rock", 581 | "name": " Corsola", 582 | "type": " Water" 583 | }, 584 | { 585 | "id": " 225", 586 | "typeTwo": " Flying", 587 | "name": " Delibird", 588 | "type": " Ice" 589 | }, 590 | { 591 | "id": " 226", 592 | "typeTwo": " Flying", 593 | "name": " Mantine", 594 | "type": " Water" 595 | }, 596 | { 597 | "id": " 227", 598 | "typeTwo": " Flying", 599 | "name": " Skarmory", 600 | "type": " Steel" 601 | }, 602 | { 603 | "id": " 228", 604 | "typeTwo": " Fire", 605 | "name": " Houndour", 606 | "type": " Dark" 607 | }, 608 | { 609 | "id": " 229", 610 | "typeTwo": " Fire", 611 | "name": " Houndoom", 612 | "type": " Dark" 613 | }, 614 | { 615 | "id": " 230", 616 | "typeTwo": " Dragon", 617 | "name": " Kingdra", 618 | "type": " Water" 619 | }, 620 | { 621 | "id": " 238", 622 | "typeTwo": " Psychic", 623 | "name": " Smoochum", 624 | "type": " Ice" 625 | }, 626 | { 627 | "id": " 246", 628 | "typeTwo": " Ground", 629 | "name": " Larvitar", 630 | "type": " Rock" 631 | }, 632 | { 633 | "id": " 247", 634 | "typeTwo": " Ground", 635 | "name": " Pupitar", 636 | "type": " Rock" 637 | }, 638 | { 639 | "id": " 248", 640 | "typeTwo": " Dark", 641 | "name": " Tyranitar", 642 | "type": " Rock" 643 | }, 644 | { 645 | "id": " 249", 646 | "typeTwo": " Flying", 647 | "name": " Lugia", 648 | "type": " Psychic" 649 | }, 650 | { 651 | "id": " 250", 652 | "typeTwo": " Flying", 653 | "name": " Ho-Oh", 654 | "type": " Fire" 655 | }, 656 | { 657 | "id": " 251", 658 | "typeTwo": " Grass", 659 | "name": " Celebi", 660 | "type": " Psychic" 661 | }, 662 | { 663 | "id": " 256", 664 | "typeTwo": " Fighting", 665 | "name": " Combusken", 666 | "type": " Fire" 667 | }, 668 | { 669 | "id": " 257", 670 | "typeTwo": " Fighting", 671 | "name": " Blaziken", 672 | "type": " Fire" 673 | }, 674 | { 675 | "id": " 259", 676 | "typeTwo": " Ground", 677 | "name": " Marshtomp", 678 | "type": " Water" 679 | }, 680 | { 681 | "id": " 260", 682 | "typeTwo": " Ground", 683 | "name": " Swampert", 684 | "type": " Water" 685 | }, 686 | { 687 | "id": " 267", 688 | "typeTwo": " Flying", 689 | "name": " Beautifly", 690 | "type": " Bug" 691 | }, 692 | { 693 | "id": " 269", 694 | "typeTwo": " Poison", 695 | "name": " Dustox", 696 | "type": " Bug" 697 | }, 698 | { 699 | "id": " 270", 700 | "typeTwo": " Grass", 701 | "name": " Lotad", 702 | "type": " Water" 703 | }, 704 | { 705 | "id": " 271", 706 | "typeTwo": " Grass", 707 | "name": " Lombre", 708 | "type": " Water" 709 | }, 710 | { 711 | "id": " 272", 712 | "typeTwo": " Grass", 713 | "name": " Ludicolo", 714 | "type": " Water" 715 | }, 716 | { 717 | "id": " 274", 718 | "typeTwo": " Dark", 719 | "name": " Nuzleaf", 720 | "type": " Grass" 721 | }, 722 | { 723 | "id": " 275", 724 | "typeTwo": " Dark", 725 | "name": " Shiftry", 726 | "type": " Grass" 727 | }, 728 | { 729 | "id": " 276", 730 | "typeTwo": " Flying", 731 | "name": " Taillow", 732 | "type": " Normal" 733 | }, 734 | { 735 | "id": " 277", 736 | "typeTwo": " Flying", 737 | "name": " Swellow", 738 | "type": " Normal" 739 | }, 740 | { 741 | "id": " 278", 742 | "typeTwo": " Flying", 743 | "name": " Wingull", 744 | "type": " Water" 745 | }, 746 | { 747 | "id": " 279", 748 | "typeTwo": " Flying", 749 | "name": " Pelipper", 750 | "type": " Water" 751 | }, 752 | { 753 | "id": " 283", 754 | "typeTwo": " Water", 755 | "name": " Surskit", 756 | "type": " Bug" 757 | }, 758 | { 759 | "id": " 284", 760 | "typeTwo": " Flying", 761 | "name": " Masquerain", 762 | "type": " Bug" 763 | }, 764 | { 765 | "id": " 286", 766 | "typeTwo": " Fighting", 767 | "name": " Breloom", 768 | "type": " Grass" 769 | }, 770 | { 771 | "id": " 290", 772 | "typeTwo": " Ground", 773 | "name": " Nincada", 774 | "type": " Bug" 775 | }, 776 | { 777 | "id": " 291", 778 | "typeTwo": " Flying", 779 | "name": " Ninjask", 780 | "type": " Bug" 781 | }, 782 | { 783 | "id": " 292", 784 | "typeTwo": " Ghost", 785 | "name": " Shedinja", 786 | "type": " Bug" 787 | }, 788 | { 789 | "id": " 302", 790 | "typeTwo": " Ghost", 791 | "name": " Sableye", 792 | "type": " Dark" 793 | }, 794 | { 795 | "id": " 304", 796 | "typeTwo": " Rock", 797 | "name": " Aron", 798 | "type": " Steel" 799 | }, 800 | { 801 | "id": " 305", 802 | "typeTwo": " Rock", 803 | "name": " Lairon", 804 | "type": " Steel" 805 | }, 806 | { 807 | "id": " 306", 808 | "typeTwo": " Rock", 809 | "name": " Aggron", 810 | "type": " Steel" 811 | }, 812 | { 813 | "id": " 307", 814 | "typeTwo": " Psychic", 815 | "name": " Meditite", 816 | "type": " Fighting" 817 | }, 818 | { 819 | "id": " 308", 820 | "typeTwo": " Psychic", 821 | "name": " Medicham", 822 | "type": " Fighting" 823 | }, 824 | { 825 | "id": " 315", 826 | "typeTwo": " Poison", 827 | "name": " Roselia", 828 | "type": " Grass" 829 | }, 830 | { 831 | "id": " 318", 832 | "typeTwo": " Dark", 833 | "name": " Carvanha", 834 | "type": " Water" 835 | }, 836 | { 837 | "id": " 319", 838 | "typeTwo": " Dark", 839 | "name": " Sharpedo", 840 | "type": " Water" 841 | }, 842 | { 843 | "id": " 322", 844 | "typeTwo": " Ground", 845 | "name": " Numel", 846 | "type": " Fire" 847 | }, 848 | { 849 | "id": " 323", 850 | "typeTwo": " Ground", 851 | "name": " Camerupt", 852 | "type": " Fire" 853 | }, 854 | { 855 | "id": " 329", 856 | "typeTwo": " Dragon", 857 | "name": " Vibrava", 858 | "type": " Ground" 859 | }, 860 | { 861 | "id": " 330", 862 | "typeTwo": " Dragon", 863 | "name": " Flygon", 864 | "type": " Ground" 865 | }, 866 | { 867 | "id": " 332", 868 | "typeTwo": " Dark", 869 | "name": " Cacturne", 870 | "type": " Grass" 871 | }, 872 | { 873 | "id": " 333", 874 | "typeTwo": " Flying", 875 | "name": " Swablu", 876 | "type": " Normal" 877 | }, 878 | { 879 | "id": " 334", 880 | "typeTwo": " Flying", 881 | "name": " Altaria", 882 | "type": " Dragon" 883 | }, 884 | { 885 | "id": " 337", 886 | "typeTwo": " Psychic", 887 | "name": " Lunatone", 888 | "type": " Rock" 889 | }, 890 | { 891 | "id": " 338", 892 | "typeTwo": " Psychic", 893 | "name": " Solrock", 894 | "type": " Rock" 895 | }, 896 | { 897 | "id": " 339", 898 | "typeTwo": " Ground", 899 | "name": " Barboach", 900 | "type": " Water" 901 | }, 902 | { 903 | "id": " 340", 904 | "typeTwo": " Ground", 905 | "name": " Whiscash", 906 | "type": " Water" 907 | }, 908 | { 909 | "id": " 342", 910 | "typeTwo": " Dark", 911 | "name": " Crawdaunt", 912 | "type": " Water" 913 | }, 914 | { 915 | "id": " 343", 916 | "typeTwo": " Psychic", 917 | "name": " Baltoy", 918 | "type": " Ground" 919 | }, 920 | { 921 | "id": " 344", 922 | "typeTwo": " Psychic", 923 | "name": " Claydol", 924 | "type": " Ground" 925 | }, 926 | { 927 | "id": " 345", 928 | "typeTwo": " Grass", 929 | "name": " Lileep", 930 | "type": " Rock" 931 | }, 932 | { 933 | "id": " 346", 934 | "typeTwo": " Grass", 935 | "name": " Cradily", 936 | "type": " Rock" 937 | }, 938 | { 939 | "id": " 347", 940 | "typeTwo": " Bug", 941 | "name": " Anorith", 942 | "type": " Rock" 943 | }, 944 | { 945 | "id": " 348", 946 | "typeTwo": " Bug", 947 | "name": " Armaldo", 948 | "type": " Rock" 949 | }, 950 | { 951 | "id": " 357", 952 | "typeTwo": " Flying", 953 | "name": " Tropius", 954 | "type": " Grass" 955 | }, 956 | { 957 | "id": " 363", 958 | "typeTwo": " Water", 959 | "name": " Spheal", 960 | "type": " Ice" 961 | }, 962 | { 963 | "id": " 364", 964 | "typeTwo": " Water", 965 | "name": " Sealeo", 966 | "type": " Ice" 967 | }, 968 | { 969 | "id": " 365", 970 | "typeTwo": " Water", 971 | "name": " Walrein", 972 | "type": " Ice" 973 | }, 974 | { 975 | "id": " 369", 976 | "typeTwo": " Rock", 977 | "name": " Relicanth", 978 | "type": " Water" 979 | }, 980 | { 981 | "id": " 373", 982 | "typeTwo": " Flying", 983 | "name": " Salamence", 984 | "type": " Dragon" 985 | }, 986 | { 987 | "id": " 374", 988 | "typeTwo": " Psychic", 989 | "name": " Beldum", 990 | "type": " Steel" 991 | }, 992 | { 993 | "id": " 375", 994 | "typeTwo": " Psychic", 995 | "name": " Metang", 996 | "type": " Steel" 997 | }, 998 | { 999 | "id": " 376", 1000 | "typeTwo": " Psychic", 1001 | "name": " Metagross", 1002 | "type": " Steel" 1003 | }, 1004 | { 1005 | "id": " 380", 1006 | "typeTwo": " Psychic", 1007 | "name": " Latias", 1008 | "type": " Dragon" 1009 | }, 1010 | { 1011 | "id": " 381", 1012 | "typeTwo": " Psychic", 1013 | "name": " Latios", 1014 | "type": " Dragon" 1015 | }, 1016 | { 1017 | "id": " 384", 1018 | "typeTwo": " Flying", 1019 | "name": " Rayquaza", 1020 | "type": " Dragon" 1021 | }, 1022 | { 1023 | "id": " 385", 1024 | "typeTwo": " Psychic", 1025 | "name": " Jirachi", 1026 | "type": " Steel" 1027 | }, 1028 | { 1029 | "id": " 389", 1030 | "typeTwo": " Ground", 1031 | "name": " Torterra", 1032 | "type": " Grass" 1033 | }, 1034 | { 1035 | "id": " 391", 1036 | "typeTwo": " Fighting", 1037 | "name": " Monferno", 1038 | "type": " Fire" 1039 | }, 1040 | { 1041 | "id": " 392", 1042 | "typeTwo": " Fighting", 1043 | "name": " Infernape", 1044 | "type": " Fire" 1045 | }, 1046 | { 1047 | "id": " 395", 1048 | "typeTwo": " Steel", 1049 | "name": " Empoleon", 1050 | "type": " Water" 1051 | }, 1052 | { 1053 | "id": " 396", 1054 | "typeTwo": " Flying", 1055 | "name": " Starly", 1056 | "type": " Normal" 1057 | }, 1058 | { 1059 | "id": " 397", 1060 | "typeTwo": " Flying", 1061 | "name": " Staravia", 1062 | "type": " Normal" 1063 | }, 1064 | { 1065 | "id": " 398", 1066 | "typeTwo": " Flying", 1067 | "name": " Staraptor", 1068 | "type": " Normal" 1069 | }, 1070 | { 1071 | "id": " 400", 1072 | "typeTwo": " Water", 1073 | "name": " Bibarel", 1074 | "type": " Normal" 1075 | }, 1076 | { 1077 | "id": " 406", 1078 | "typeTwo": " Poison", 1079 | "name": " Budew", 1080 | "type": " Grass" 1081 | }, 1082 | { 1083 | "id": " 407", 1084 | "typeTwo": " Poison", 1085 | "name": " Roserade", 1086 | "type": " Grass" 1087 | }, 1088 | { 1089 | "id": " 410", 1090 | "typeTwo": " Steel", 1091 | "name": " Shieldon", 1092 | "type": " Rock" 1093 | }, 1094 | { 1095 | "id": " 411", 1096 | "typeTwo": " Steel", 1097 | "name": " Bastiodon", 1098 | "type": " Rock" 1099 | }, 1100 | { 1101 | "id": " 413", 1102 | "typeTwo": " Steel", 1103 | "name": " Wormadam", 1104 | "type": " Bug" 1105 | }, 1106 | { 1107 | "id": " 414", 1108 | "typeTwo": " Flying", 1109 | "name": " Mothim", 1110 | "type": " Bug" 1111 | }, 1112 | { 1113 | "id": " 415", 1114 | "typeTwo": " Flying", 1115 | "name": " Combee", 1116 | "type": " Bug" 1117 | }, 1118 | { 1119 | "id": " 416", 1120 | "typeTwo": " Flying", 1121 | "name": " Vespiquen", 1122 | "type": " Bug" 1123 | }, 1124 | { 1125 | "id": " 423", 1126 | "typeTwo": " Ground", 1127 | "name": " Gastrodon", 1128 | "type": " Water" 1129 | }, 1130 | { 1131 | "id": " 425", 1132 | "typeTwo": " Flying", 1133 | "name": " Drifloon", 1134 | "type": " Ghost" 1135 | }, 1136 | { 1137 | "id": " 426", 1138 | "typeTwo": " Flying", 1139 | "name": " Drifblim", 1140 | "type": " Ghost" 1141 | }, 1142 | { 1143 | "id": " 430", 1144 | "typeTwo": " Flying", 1145 | "name": " Honchkrow", 1146 | "type": " Dark" 1147 | }, 1148 | { 1149 | "id": " 434", 1150 | "typeTwo": " Dark", 1151 | "name": " Stunky", 1152 | "type": " Poison" 1153 | }, 1154 | { 1155 | "id": " 435", 1156 | "typeTwo": " Dark", 1157 | "name": " Skuntank", 1158 | "type": " Poison" 1159 | }, 1160 | { 1161 | "id": " 436", 1162 | "typeTwo": " Psychic", 1163 | "name": " Bronzor", 1164 | "type": " Steel" 1165 | }, 1166 | { 1167 | "id": " 437", 1168 | "typeTwo": " Psychic", 1169 | "name": " Bronzong", 1170 | "type": " Steel" 1171 | }, 1172 | { 1173 | "id": " 441", 1174 | "typeTwo": " Flying", 1175 | "name": " Chatot", 1176 | "type": " Normal" 1177 | }, 1178 | { 1179 | "id": " 442", 1180 | "typeTwo": " Dark", 1181 | "name": " Spiritomb", 1182 | "type": " Ghost" 1183 | }, 1184 | { 1185 | "id": " 443", 1186 | "typeTwo": " Ground", 1187 | "name": " Gible", 1188 | "type": " Dragon" 1189 | }, 1190 | { 1191 | "id": " 444", 1192 | "typeTwo": " Ground", 1193 | "name": " Gabite", 1194 | "type": " Dragon" 1195 | }, 1196 | { 1197 | "id": " 445", 1198 | "typeTwo": " Ground", 1199 | "name": " Garchomp", 1200 | "type": " Dragon" 1201 | }, 1202 | { 1203 | "id": " 448", 1204 | "typeTwo": " Steel", 1205 | "name": " Lucario", 1206 | "type": " Fighting" 1207 | }, 1208 | { 1209 | "id": " 451", 1210 | "typeTwo": " Bug", 1211 | "name": " Skorupi", 1212 | "type": " Poison" 1213 | }, 1214 | { 1215 | "id": " 452", 1216 | "typeTwo": " Dark", 1217 | "name": " Drapion", 1218 | "type": " Poison" 1219 | }, 1220 | { 1221 | "id": " 453", 1222 | "typeTwo": " Fighting", 1223 | "name": " Croagunk", 1224 | "type": " Poison" 1225 | }, 1226 | { 1227 | "id": " 454", 1228 | "typeTwo": " Fighting", 1229 | "name": " Toxicroak", 1230 | "type": " Poison" 1231 | }, 1232 | { 1233 | "id": " 458", 1234 | "typeTwo": " Flying", 1235 | "name": " Mantyke", 1236 | "type": " Water" 1237 | }, 1238 | { 1239 | "id": " 459", 1240 | "typeTwo": " Ice", 1241 | "name": " Snover", 1242 | "type": " Grass" 1243 | }, 1244 | { 1245 | "id": " 460", 1246 | "typeTwo": " Ice", 1247 | "name": " Abomasnow", 1248 | "type": " Grass" 1249 | }, 1250 | { 1251 | "id": " 461", 1252 | "typeTwo": " Ice", 1253 | "name": " Weavile", 1254 | "type": " Dark" 1255 | }, 1256 | { 1257 | "id": " 462", 1258 | "typeTwo": " Steel", 1259 | "name": " Magnezone", 1260 | "type": " Electric" 1261 | }, 1262 | { 1263 | "id": " 464", 1264 | "typeTwo": " Rock", 1265 | "name": " Rhyperior", 1266 | "type": " Ground" 1267 | }, 1268 | { 1269 | "id": " 468", 1270 | "typeTwo": " Flying", 1271 | "name": " Togekiss", 1272 | "type": " Normal" 1273 | }, 1274 | { 1275 | "id": " 469", 1276 | "typeTwo": " Flying", 1277 | "name": " Yanmega", 1278 | "type": " Bug" 1279 | }, 1280 | { 1281 | "id": " 472", 1282 | "typeTwo": " Flying", 1283 | "name": " Gliscor", 1284 | "type": " Ground" 1285 | }, 1286 | { 1287 | "id": " 473", 1288 | "typeTwo": " Ground", 1289 | "name": " Mamoswine", 1290 | "type": " Ice" 1291 | }, 1292 | { 1293 | "id": " 475", 1294 | "typeTwo": " Fighting", 1295 | "name": " Gallade", 1296 | "type": " Psychic" 1297 | }, 1298 | { 1299 | "id": " 476", 1300 | "typeTwo": " Steel", 1301 | "name": " Probopass", 1302 | "type": " Rock" 1303 | }, 1304 | { 1305 | "id": " 478", 1306 | "typeTwo": " Ghost", 1307 | "name": " Froslass", 1308 | "type": " Ice" 1309 | }, 1310 | { 1311 | "id": " 479", 1312 | "typeTwo": " Grass", 1313 | "name": " Rotom", 1314 | "type": " Electric" 1315 | }, 1316 | { 1317 | "id": " 483", 1318 | "typeTwo": " Dragon", 1319 | "name": " Dialga", 1320 | "type": " Steel" 1321 | }, 1322 | { 1323 | "id": " 484", 1324 | "typeTwo": " Dragon", 1325 | "name": " Palkia", 1326 | "type": " Water" 1327 | }, 1328 | { 1329 | "id": " 485", 1330 | "typeTwo": " Steel", 1331 | "name": " Heatran", 1332 | "type": " Fire" 1333 | }, 1334 | { 1335 | "id": " 487", 1336 | "typeTwo": " Dragon", 1337 | "name": " Giratina", 1338 | "type": " Ghost" 1339 | }, 1340 | { 1341 | "id": " 492", 1342 | "typeTwo": " Flying", 1343 | "name": " Shaymin", 1344 | "type": " Grass" 1345 | }, 1346 | { 1347 | "id": " 494", 1348 | "typeTwo": " Fire", 1349 | "name": " Victini", 1350 | "type": " Psychic" 1351 | }, 1352 | { 1353 | "id": " 499", 1354 | "typeTwo": " Fighting", 1355 | "name": " Pignite", 1356 | "type": " Fire" 1357 | }, 1358 | { 1359 | "id": " 500", 1360 | "typeTwo": " Fighting", 1361 | "name": " Emboar", 1362 | "type": " Fire" 1363 | }, 1364 | { 1365 | "id": " 519", 1366 | "typeTwo": " Flying", 1367 | "name": " Pidove", 1368 | "type": " Normal" 1369 | }, 1370 | { 1371 | "id": " 520", 1372 | "typeTwo": " Flying", 1373 | "name": " Tranquill", 1374 | "type": " Normal" 1375 | }, 1376 | { 1377 | "id": " 521", 1378 | "typeTwo": " Flying", 1379 | "name": " Unfezant", 1380 | "type": " Normal" 1381 | }, 1382 | { 1383 | "id": " 527", 1384 | "typeTwo": " Flying", 1385 | "name": " Woobat", 1386 | "type": " Psychic" 1387 | }, 1388 | { 1389 | "id": " 528", 1390 | "typeTwo": " Flying", 1391 | "name": " Swoobat", 1392 | "type": " Psychic" 1393 | }, 1394 | { 1395 | "id": " 530", 1396 | "typeTwo": " Steel", 1397 | "name": " Excadrill", 1398 | "type": " Ground" 1399 | }, 1400 | { 1401 | "id": " 536", 1402 | "typeTwo": " Ground", 1403 | "name": " Palpitoad", 1404 | "type": " Water" 1405 | }, 1406 | { 1407 | "id": " 537", 1408 | "typeTwo": " Ground", 1409 | "name": " Seismitoad", 1410 | "type": " Water" 1411 | }, 1412 | { 1413 | "id": " 540", 1414 | "typeTwo": " Grass", 1415 | "name": " Sewaddle", 1416 | "type": " Bug" 1417 | }, 1418 | { 1419 | "id": " 541", 1420 | "typeTwo": " Grass", 1421 | "name": " Swadloon", 1422 | "type": " Bug" 1423 | }, 1424 | { 1425 | "id": " 542", 1426 | "typeTwo": " Grass", 1427 | "name": " Leavanny", 1428 | "type": " Bug" 1429 | }, 1430 | { 1431 | "id": " 543", 1432 | "typeTwo": " Poison", 1433 | "name": " Venipede", 1434 | "type": " Bug" 1435 | }, 1436 | { 1437 | "id": " 544", 1438 | "typeTwo": " Poison", 1439 | "name": " Whirlipede", 1440 | "type": " Bug" 1441 | }, 1442 | { 1443 | "id": " 545", 1444 | "typeTwo": " Poison", 1445 | "name": " Scolipede", 1446 | "type": " Bug" 1447 | }, 1448 | { 1449 | "id": " 551", 1450 | "typeTwo": " Dark", 1451 | "name": " Sandile", 1452 | "type": " Ground" 1453 | }, 1454 | { 1455 | "id": " 552", 1456 | "typeTwo": " Dark", 1457 | "name": " Krokorok", 1458 | "type": " Ground" 1459 | }, 1460 | { 1461 | "id": " 553", 1462 | "typeTwo": " Dark", 1463 | "name": " Krookodile", 1464 | "type": " Ground" 1465 | }, 1466 | { 1467 | "id": " 555", 1468 | "typeTwo": " Psychic", 1469 | "name": " Darmanitan", 1470 | "type": " Fire" 1471 | }, 1472 | { 1473 | "id": " 557", 1474 | "typeTwo": " Rock", 1475 | "name": " Dwebble", 1476 | "type": " Bug" 1477 | }, 1478 | { 1479 | "id": " 558", 1480 | "typeTwo": " Rock", 1481 | "name": " Crustle", 1482 | "type": " Bug" 1483 | }, 1484 | { 1485 | "id": " 559", 1486 | "typeTwo": " Fighting", 1487 | "name": " Scraggy", 1488 | "type": " Dark" 1489 | }, 1490 | { 1491 | "id": " 560", 1492 | "typeTwo": " Fighting", 1493 | "name": " Scrafty", 1494 | "type": " Dark" 1495 | }, 1496 | { 1497 | "id": " 561", 1498 | "typeTwo": " Flying", 1499 | "name": " Sigilyph", 1500 | "type": " Psychic" 1501 | }, 1502 | { 1503 | "id": " 564", 1504 | "typeTwo": " Rock", 1505 | "name": " Tirtouga", 1506 | "type": " Water" 1507 | }, 1508 | { 1509 | "id": " 565", 1510 | "typeTwo": " Rock", 1511 | "name": " Carracosta", 1512 | "type": " Water" 1513 | }, 1514 | { 1515 | "id": " 566", 1516 | "typeTwo": " Flying", 1517 | "name": " Archen", 1518 | "type": " Rock" 1519 | }, 1520 | { 1521 | "id": " 567", 1522 | "typeTwo": " Flying", 1523 | "name": " Archeops", 1524 | "type": " Rock" 1525 | }, 1526 | { 1527 | "id": " 580", 1528 | "typeTwo": " Flying", 1529 | "name": " Ducklett", 1530 | "type": " Water" 1531 | }, 1532 | { 1533 | "id": " 581", 1534 | "typeTwo": " Flying", 1535 | "name": " Swanna", 1536 | "type": " Water" 1537 | }, 1538 | { 1539 | "id": " 585", 1540 | "typeTwo": " Grass", 1541 | "name": " Deerling", 1542 | "type": " Normal" 1543 | }, 1544 | { 1545 | "id": " 586", 1546 | "typeTwo": " Grass", 1547 | "name": " Sawsbuck", 1548 | "type": " Normal" 1549 | }, 1550 | { 1551 | "id": " 587", 1552 | "typeTwo": " Flying", 1553 | "name": " Emolga", 1554 | "type": " Electric" 1555 | }, 1556 | { 1557 | "id": " 589", 1558 | "typeTwo": " Steel", 1559 | "name": " Escavalier", 1560 | "type": " Bug" 1561 | }, 1562 | { 1563 | "id": " 590", 1564 | "typeTwo": " Poison", 1565 | "name": " Foongus", 1566 | "type": " Grass" 1567 | }, 1568 | { 1569 | "id": " 591", 1570 | "typeTwo": " Poison", 1571 | "name": " Amoonguss", 1572 | "type": " Grass" 1573 | }, 1574 | { 1575 | "id": " 592", 1576 | "typeTwo": " Ghost", 1577 | "name": " Frillish", 1578 | "type": " Water" 1579 | }, 1580 | { 1581 | "id": " 593", 1582 | "typeTwo": " Ghost", 1583 | "name": " Jellicent", 1584 | "type": " Water" 1585 | }, 1586 | { 1587 | "id": " 595", 1588 | "typeTwo": " Electric", 1589 | "name": " Joltik", 1590 | "type": " Bug" 1591 | }, 1592 | { 1593 | "id": " 596", 1594 | "typeTwo": " Electric", 1595 | "name": " Galvantula", 1596 | "type": " Bug" 1597 | }, 1598 | { 1599 | "id": " 597", 1600 | "typeTwo": " Steel", 1601 | "name": " Ferroseed", 1602 | "type": " Grass" 1603 | }, 1604 | { 1605 | "id": " 598", 1606 | "typeTwo": " Steel", 1607 | "name": " Ferrothorn", 1608 | "type": " Grass" 1609 | }, 1610 | { 1611 | "id": " 607", 1612 | "typeTwo": " Fire", 1613 | "name": " Litwick", 1614 | "type": " Ghost" 1615 | }, 1616 | { 1617 | "id": " 608", 1618 | "typeTwo": " Fire", 1619 | "name": " Lampent", 1620 | "type": " Ghost" 1621 | }, 1622 | { 1623 | "id": " 609", 1624 | "typeTwo": " Fire", 1625 | "name": " Chandelure", 1626 | "type": " Ghost" 1627 | }, 1628 | { 1629 | "id": " 618", 1630 | "typeTwo": " Electric", 1631 | "name": " Stunfisk", 1632 | "type": " Ground" 1633 | }, 1634 | { 1635 | "id": " 622", 1636 | "typeTwo": " Ghost", 1637 | "name": " Golett", 1638 | "type": " Ground" 1639 | }, 1640 | { 1641 | "id": " 623", 1642 | "typeTwo": " Ghost", 1643 | "name": " Golurk", 1644 | "type": " Ground" 1645 | }, 1646 | { 1647 | "id": " 624", 1648 | "typeTwo": " Steel", 1649 | "name": " Pawniard", 1650 | "type": " Dark" 1651 | }, 1652 | { 1653 | "id": " 625", 1654 | "typeTwo": " Steel", 1655 | "name": " Bisharp", 1656 | "type": " Dark" 1657 | }, 1658 | { 1659 | "id": " 627", 1660 | "typeTwo": " Flying", 1661 | "name": " Rufflet", 1662 | "type": " Normal" 1663 | }, 1664 | { 1665 | "id": " 628", 1666 | "typeTwo": " Flying", 1667 | "name": " Braviary", 1668 | "type": " Normal" 1669 | }, 1670 | { 1671 | "id": " 629", 1672 | "typeTwo": " Flying", 1673 | "name": " Vullaby", 1674 | "type": " Dark" 1675 | }, 1676 | { 1677 | "id": " 630", 1678 | "typeTwo": " Flying", 1679 | "name": " Mandibuzz", 1680 | "type": " Dark" 1681 | }, 1682 | { 1683 | "id": " 632", 1684 | "typeTwo": " Steel", 1685 | "name": " Durant", 1686 | "type": " Bug" 1687 | }, 1688 | { 1689 | "id": " 633", 1690 | "typeTwo": " Dragon", 1691 | "name": " Deino", 1692 | "type": " Dark" 1693 | }, 1694 | { 1695 | "id": " 634", 1696 | "typeTwo": " Dragon", 1697 | "name": " Zweilous", 1698 | "type": " Dark" 1699 | }, 1700 | { 1701 | "id": " 635", 1702 | "typeTwo": " Dragon", 1703 | "name": " Hydreigon", 1704 | "type": " Dark" 1705 | }, 1706 | { 1707 | "id": " 636", 1708 | "typeTwo": " Fire", 1709 | "name": " Larvesta", 1710 | "type": " Bug" 1711 | }, 1712 | { 1713 | "id": " 637", 1714 | "typeTwo": " Fire", 1715 | "name": " Volcarona", 1716 | "type": " Bug" 1717 | }, 1718 | { 1719 | "id": " 638", 1720 | "typeTwo": " Fighting", 1721 | "name": " Cobalion", 1722 | "type": " Steel" 1723 | }, 1724 | { 1725 | "id": " 639", 1726 | "typeTwo": " Fighting", 1727 | "name": " Terrakion", 1728 | "type": " Rock" 1729 | }, 1730 | { 1731 | "id": " 640", 1732 | "typeTwo": " Fighting", 1733 | "name": " Virizion", 1734 | "type": " Grass" 1735 | }, 1736 | { 1737 | "id": " 642", 1738 | "typeTwo": " Flying", 1739 | "name": " Thundurus", 1740 | "type": " Electric" 1741 | }, 1742 | { 1743 | "id": " 643", 1744 | "typeTwo": " Fire", 1745 | "name": " Reshiram", 1746 | "type": " Dragon" 1747 | }, 1748 | { 1749 | "id": " 644", 1750 | "typeTwo": " Electric", 1751 | "name": " Zekrom ", 1752 | "type": " Dragon" 1753 | }, 1754 | { 1755 | "id": " 645", 1756 | "typeTwo": " Flying", 1757 | "name": " Landorus", 1758 | "type": " Ground" 1759 | }, 1760 | { 1761 | "id": " 646", 1762 | "typeTwo": " Ice", 1763 | "name": " Kyurem", 1764 | "type": " Dragon" 1765 | }, 1766 | { 1767 | "id": " 647", 1768 | "typeTwo": " Fighting", 1769 | "name": " Keldeo", 1770 | "type": " Water" 1771 | }, 1772 | { 1773 | "id": " 648", 1774 | "typeTwo": " Fighting", 1775 | "name": " Meloetta", 1776 | "type": " Normal" 1777 | }, 1778 | { 1779 | "id": " 649", 1780 | "typeTwo": " Steel", 1781 | "name": " Genesect", 1782 | "type": " Bug" 1783 | } 1784 | ] 1785 | -------------------------------------------------------------------------------- /Chapter2/pokemonXml.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 001 5 | Poison 6 | Bulbasaur 7 | Grass 8 | 9 | 10 | 002 11 | Poison 12 | Ivysaur 13 | Grass 14 | 15 | 16 | 003 17 | Poison 18 | Venusaur 19 | Grass 20 | 21 | 22 | 006 23 | Flying 24 | Charizard 25 | Fire 26 | 27 | 28 | 012 29 | Flying 30 | Butterfree 31 | Bug 32 | 33 | 34 | 013 35 | Poison 36 | Weedle 37 | Bug 38 | 39 | 40 | 014 41 | Poison 42 | Kakuna 43 | Bug 44 | 45 | 46 | 015 47 | Poison 48 | Beedrill 49 | Bug 50 | 51 | 52 | 016 53 | Flying 54 | Pidgey 55 | Normal 56 | 57 | 58 | 017 59 | Flying 60 | Pidgeotto 61 | Normal 62 | 63 | 64 | 018 65 | Flying 66 | Pidgeot 67 | Normal 68 | 69 | 70 | -------------------------------------------------------------------------------- /Chapter3/BarchartAnimated.html: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /Chapter3/Line-chart.html: -------------------------------------------------------------------------------- 1 | 2 | 21 | 22 | 23 | 78 | -------------------------------------------------------------------------------- /Chapter3/MultiLine-chart.html: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | 21 | 107 | -------------------------------------------------------------------------------- /Chapter3/Pie-chart.html: -------------------------------------------------------------------------------- 1 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /Chapter3/Scatterplot.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 56 | 57 | -------------------------------------------------------------------------------- /Chapter3/SumJson.py: -------------------------------------------------------------------------------- 1 | import json 2 | import csv 3 | from pprint import pprint 4 | 5 | typePokemon = {} 6 | 7 | with open("pokemon.json") as f: 8 | data = json.loads(f.read()) 9 | 10 | for line in data: 11 | 12 | if line["type"] not in typePokemon: 13 | typePokemon[line["type"]] = 1 14 | else: 15 | typePokemon[line["type"]] = typePokemon.get(line["type"]) + 1 16 | 17 | with open("sumPokemon.csv", "w") as a: 18 | w = csv.writer(a) 19 | 20 | for key, value in sorted(typePokemon.items(), key=lambda x: x[1]): 21 | w.writerow([key,str(value)]) 22 | 23 | 24 | pprint(typePokemon) 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /Chapter3/bar-chart.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /Chapter3/line.csv: -------------------------------------------------------------------------------- 1 | date,usd 2 | 3/10/2013,1.0284 3 | 3/3/2013,1.0254 4 | 2/24/2013,1.014 5 | 2/17/2013,1.0035 6 | 2/10/2013,0.9979 7 | 2/3/2013,1.0023 8 | 1/27/2013,0.9973 9 | 1/20/2013,0.9864 10 | 1/13/2013,0.9859 11 | 1/6/2013,0.9907 12 | 12/30/2012,0.9934 13 | 12/23/2012,0.9877 14 | 12/16/2012,0.986 15 | 12/9/2012,0.992 16 | 12/2/2012,0.9931 17 | 11/25/2012,0.9971 18 | 11/18/2012,1.0011 19 | 11/11/2012,0.9967 20 | 11/4/2012,0.9981 21 | 10/28/2012,0.994 22 | 10/21/2012,0.9838 23 | 10/14/2012,0.9785 24 | 10/7/2012,0.9824 25 | 9/30/2012,0.9804 26 | 9/23/2012,0.9744 27 | 9/16/2012,0.974 28 | 9/9/2012,0.9847 29 | 9/2/2012,0.9895 30 | 8/26/2012,0.9903 31 | 8/19/2012,0.9902 32 | 8/12/2012,0.9962 33 | 8/5/2012,1.0029 34 | 7/29/2012,1.013 35 | 7/22/2012,1.0122 36 | 7/15/2012,1.0187 37 | 7/8/2012,1.0157 38 | 7/1/2012,1.0247 39 | 6/24/2012,1.0225 40 | 6/17/2012,1.0253 41 | 6/10/2012,1.0339 42 | 6/3/2012,1.0302 43 | 5/27/2012,1.0235 44 | 5/20/2012,1.0098 45 | 5/13/2012,0.9988 46 | 5/6/2012,0.9869 47 | 4/29/2012,0.9869 48 | 4/22/2012,0.9944 49 | 4/15/2012,0.9986 50 | 4/8/2012,0.9948 51 | 4/1/2012,0.9965 52 | 3/25/2012,0.9935 53 | 3/18/2012,0.9914 54 | 3/11/2012,0.9934 55 | 3/4/2012,0.9929 56 | 2/26/2012,0.9968 57 | 2/19/2012,0.9987 58 | 2/12/2012,0.9964 59 | 2/5/2012,0.9994 60 | 1/29/2012,1.007 61 | 1/22/2012,1.0156 62 | 1/15/2012,1.022 63 | 1/8/2012,1.0187 64 | 1/1/2012,1.0206 65 | 12/25/2011,1.0287 66 | 12/18/2011,1.0303 67 | 12/11/2011,1.0159 68 | 12/4/2011,1.0277 69 | 11/27/2011,1.0402 70 | 11/20/2011,1.021 71 | 11/13/2011,1.0161 72 | 11/6/2011,1.0084 73 | 10/30/2011,1.0018 74 | 10/23/2011,1.0135 75 | 10/16/2011,1.0241 76 | 10/9/2011,1.0461 77 | 10/2/2011,1.0326 78 | 9/25/2011,1.0036 79 | 9/18/2011,0.9893 80 | 9/11/2011,0.9892 81 | 9/4/2011,0.9794 82 | 8/28/2011,0.9869 83 | 8/21/2011,0.9858 84 | 8/14/2011,0.9869 85 | 8/7/2011,0.9651 86 | 7/31/2011,0.9486 87 | 7/24/2011,0.9507 88 | 7/17/2011,0.9612 89 | 7/10/2011,0.9611 90 | 7/3/2011,0.975 91 | 6/26/2011,0.9792 92 | 6/19/2011,0.9777 93 | 6/12/2011,0.9777 94 | 6/5/2011,0.9752 95 | 5/29/2011,0.9767 96 | 5/22/2011,0.971 97 | 5/15/2011,0.9635 98 | 5/8/2011,0.9558 99 | 5/1/2011,0.9508 100 | 4/24/2011,0.9562 101 | 4/17/2011,0.9592 102 | 4/10/2011,0.9607 103 | 4/3/2011,0.9726 104 | 3/27/2011,0.9798 105 | 3/20/2011,0.9814 106 | 3/13/2011,0.9723 107 | 3/6/2011,0.9738 108 | 2/27/2011,0.9843 109 | 2/20/2011,0.9862 110 | 2/13/2011,0.9909 111 | 2/6/2011,0.9931 112 | 1/30/2011,0.9957 113 | 1/23/2011,0.9919 114 | 1/16/2011,0.9908 115 | 1/9/2011,0.9952 116 | 1/2/2011,1.002 117 | 12/26/2010,1.0125 118 | 12/19/2010,1.0079 119 | 12/12/2010,1.0076 120 | 12/5/2010,1.0147 121 | 11/28/2010,1.0166 122 | 11/21/2010,1.0161 123 | 11/14/2010,1.0043 124 | 11/7/2010,1.0089 125 | 10/31/2010,1.0226 126 | 10/24/2010,1.0221 127 | 10/17/2010,1.0086 128 | 10/10/2010,1.016 129 | 10/3/2010,1.0263 130 | 9/26/2010,1.029 131 | 9/19/2010,1.0296 132 | 9/12/2010,1.0376 133 | 9/5/2010,1.0514 134 | 8/29/2010,1.0542 135 | 8/22/2010,1.0393 136 | 8/15/2010,1.0362 137 | 8/8/2010,1.0231 138 | 8/1/2010,1.033 139 | 7/25/2010,1.0454 140 | 7/18/2010,1.039 141 | 7/11/2010,1.0501 142 | 7/4/2010,1.0514 143 | 6/27/2010,1.0305 144 | 6/20/2010,1.0272 145 | 6/13/2010,1.0458 146 | 6/6/2010,1.0493 147 | 5/30/2010,1.0599 148 | 5/23/2010,1.0474 149 | 5/16/2010,1.0268 150 | 5/9/2010,1.0294 151 | 5/2/2010,1.0072 152 | 4/25/2010,1.0045 153 | 4/18/2010,1.0038 154 | 4/11/2010,1.004 155 | 4/4/2010,1.0162 156 | 3/28/2010,1.0213 157 | 3/21/2010,1.0155 158 | 3/14/2010,1.0248 159 | 3/7/2010,1.0368 160 | 2/28/2010,1.0497 161 | 2/21/2010,1.0455 162 | 2/14/2010,1.0625 163 | 2/7/2010,1.0664 164 | 1/31/2010,1.0624 165 | 1/24/2010,1.0401 166 | 1/17/2010,1.0305 167 | 1/10/2010,1.0382 168 | 1/3/2010,1.0487 169 | 12/27/2009,1.0555 170 | 12/20/2009,1.0631 171 | 12/13/2009,1.0563 172 | 12/6/2009,1.0538 173 | 11/29/2009,1.0604 174 | 11/22/2009,1.0572 175 | 11/15/2009,1.0562 176 | 11/8/2009,1.0729 177 | 11/1/2009,1.0683 178 | 10/25/2009,1.0437 179 | 10/18/2009,1.0343 180 | 10/11/2009,1.0608 181 | 10/4/2009,1.0833 182 | 9/27/2009,1.0777 183 | 9/20/2009,1.0734 184 | 9/13/2009,1.0794 185 | 9/6/2009,1.0964 186 | 8/30/2009,1.0859 187 | 8/23/2009,1.0959 188 | 8/16/2009,1.0901 189 | 8/9/2009,1.0748 190 | 8/2/2009,1.0827 191 | 7/26/2009,1.0999 192 | 7/19/2009,1.135 193 | 7/12/2009,1.1622 194 | 7/5/2009,1.1562 195 | 6/28/2009,1.1483 196 | 6/21/2009,1.1296 197 | 6/14/2009,1.1123 198 | 6/7/2009,1.0975 199 | 5/31/2009,1.1131 200 | 5/24/2009,1.1497 201 | 5/17/2009,1.1646 202 | 5/10/2009,1.1707 203 | 5/3/2009,1.2035 204 | 4/26/2009,1.2253 205 | 4/19/2009,1.2156 206 | 4/12/2009,1.2319 207 | 4/5/2009,1.2472 208 | 3/29/2009,1.233 209 | 3/22/2009,1.2572 210 | 3/15/2009,1.2832 211 | 3/8/2009,1.2838 212 | 3/1/2009,1.2545 213 | 2/22/2009,1.2513 214 | 2/15/2009,1.2327 215 | 2/8/2009,1.2322 216 | 2/1/2009,1.2257 217 | 1/25/2009,1.2506 218 | 1/18/2009,1.224 219 | 1/11/2009,1.1926 220 | 1/4/2009,1.217 221 | 12/28/2008,1.2165 222 | 12/21/2008,1.2201 223 | 12/14/2008,1.2547 224 | 12/7/2008,1.2556 225 | 11/30/2008,1.2422 226 | 11/23/2008,1.2493 227 | 11/16/2008,1.2091 228 | 11/9/2008,1.1846 229 | 11/2/2008,1.2496 230 | 10/26/2008,1.2293 231 | 10/19/2008,1.172 232 | 10/12/2008,1.1227 233 | 10/5/2008,1.0588 234 | 9/28/2008,1.0374 235 | 9/21/2008,1.062 236 | 9/14/2008,1.0661 237 | 9/7/2008,1.0653 238 | 8/31/2008,1.0507 239 | 8/24/2008,1.0558 240 | 8/17/2008,1.0645 241 | 8/10/2008,1.0449 242 | 8/3/2008,1.0232 243 | 7/27/2008,1.0096 244 | 7/20/2008,1.0048 245 | 7/13/2008,1.0147 246 | 7/6/2008,1.0159 247 | 6/29/2008,1.0128 248 | 6/22/2008,1.0204 249 | 6/15/2008,1.023 250 | 6/8/2008,1.008 251 | 6/1/2008,0.9909 252 | 5/25/2008,0.9907 253 | 5/18/2008,1.0028 254 | 5/11/2008,1.0109 255 | 5/4/2008,1.014 256 | 4/27/2008,1.0105 257 | 4/20/2008,1.0133 258 | 4/13/2008,1.0157 259 | 4/6/2008,1.0168 260 | 3/30/2008,1.0197 261 | 3/23/2008,1.0053 262 | -------------------------------------------------------------------------------- /Chapter3/line.tsv: -------------------------------------------------------------------------------- 1 | date close 2 | 1-May-12 582.13 3 | 30-Apr-12 583.98 4 | 27-Apr-12 603.00 5 | 26-Apr-12 607.70 6 | 25-Apr-12 610.00 7 | 24-Apr-12 560.28 8 | 23-Apr-12 571.70 9 | 20-Apr-12 572.98 10 | 19-Apr-12 587.44 11 | 18-Apr-12 608.34 12 | 17-Apr-12 609.70 13 | 16-Apr-12 580.13 14 | 13-Apr-12 605.23 15 | 12-Apr-12 622.77 16 | 11-Apr-12 626.20 17 | 10-Apr-12 628.44 18 | 9-Apr-12 636.23 19 | 5-Apr-12 633.68 20 | 4-Apr-12 624.31 21 | 3-Apr-12 629.32 22 | 2-Apr-12 618.63 23 | 30-Mar-12 599.55 24 | 29-Mar-12 609.86 25 | 28-Mar-12 617.62 26 | 27-Mar-12 614.48 27 | 26-Mar-12 606.98 28 | 23-Mar-12 596.05 29 | 22-Mar-12 599.34 30 | 21-Mar-12 602.50 31 | 20-Mar-12 605.96 32 | 19-Mar-12 601.10 33 | 16-Mar-12 585.57 34 | 15-Mar-12 585.56 35 | 14-Mar-12 589.58 36 | 13-Mar-12 568.10 37 | 12-Mar-12 552.00 38 | 9-Mar-12 545.17 39 | 8-Mar-12 541.99 40 | 7-Mar-12 530.69 41 | 6-Mar-12 530.26 42 | 5-Mar-12 533.16 43 | 2-Mar-12 545.18 44 | 1-Mar-12 544.47 45 | 29-Feb-12 542.44 46 | 28-Feb-12 535.41 47 | 27-Feb-12 525.76 48 | 24-Feb-12 522.41 49 | 23-Feb-12 516.39 50 | 22-Feb-12 513.04 51 | 21-Feb-12 514.85 52 | 17-Feb-12 502.12 53 | 16-Feb-12 502.21 54 | 15-Feb-12 497.67 55 | 14-Feb-12 509.46 56 | 13-Feb-12 502.60 57 | 10-Feb-12 493.42 58 | 9-Feb-12 493.17 59 | 8-Feb-12 476.68 60 | 7-Feb-12 468.83 61 | 6-Feb-12 463.97 62 | 3-Feb-12 459.68 63 | 2-Feb-12 455.12 64 | 1-Feb-12 456.19 65 | 31-Jan-12 456.48 66 | 30-Jan-12 453.01 67 | 27-Jan-12 447.28 68 | 26-Jan-12 444.63 69 | 25-Jan-12 446.66 70 | 24-Jan-12 420.41 71 | 23-Jan-12 427.41 72 | 20-Jan-12 420.30 73 | 19-Jan-12 427.75 74 | 18-Jan-12 429.11 75 | 17-Jan-12 424.70 76 | 13-Jan-12 419.81 77 | 12-Jan-12 421.39 78 | 11-Jan-12 422.55 79 | 10-Jan-12 423.24 80 | 9-Jan-12 421.73 81 | 6-Jan-12 422.40 82 | 5-Jan-12 418.03 83 | 4-Jan-12 413.44 84 | 3-Jan-12 411.23 85 | 30-Dec-11 405.00 86 | 29-Dec-11 405.12 87 | 28-Dec-11 402.64 88 | 27-Dec-11 406.53 89 | 23-Dec-11 403.43 90 | 22-Dec-11 398.55 91 | 21-Dec-11 396.44 92 | 20-Dec-11 395.95 93 | 19-Dec-11 382.21 94 | 16-Dec-11 381.02 95 | 15-Dec-11 378.94 96 | 14-Dec-11 380.19 97 | 13-Dec-11 388.81 98 | 12-Dec-11 391.84 99 | 9-Dec-11 393.62 100 | 8-Dec-11 390.66 101 | 7-Dec-11 389.09 102 | 6-Dec-11 390.95 103 | 5-Dec-11 393.01 104 | 2-Dec-11 389.70 105 | 1-Dec-11 387.93 106 | 30-Nov-11 382.20 107 | 29-Nov-11 373.20 108 | 28-Nov-11 376.12 109 | 25-Nov-11 363.57 110 | 23-Nov-11 366.99 111 | 22-Nov-11 376.51 112 | 21-Nov-11 369.01 113 | 18-Nov-11 374.94 114 | 17-Nov-11 377.41 115 | 16-Nov-11 384.77 116 | 15-Nov-11 388.83 117 | 14-Nov-11 379.26 118 | 11-Nov-11 384.62 119 | 10-Nov-11 385.22 120 | 9-Nov-11 395.28 121 | 8-Nov-11 406.23 122 | 7-Nov-11 399.73 123 | 4-Nov-11 400.24 124 | 3-Nov-11 403.07 125 | 2-Nov-11 397.41 126 | 1-Nov-11 396.51 127 | 31-Oct-11 404.78 128 | 28-Oct-11 404.95 129 | 27-Oct-11 404.69 130 | 26-Oct-11 400.60 131 | 25-Oct-11 397.77 132 | 24-Oct-11 405.77 133 | 21-Oct-11 392.87 134 | 20-Oct-11 395.31 135 | 19-Oct-11 398.62 136 | 18-Oct-11 422.24 137 | 17-Oct-11 419.99 138 | 14-Oct-11 422.00 139 | 13-Oct-11 408.43 140 | 12-Oct-11 402.19 141 | 11-Oct-11 400.29 142 | 10-Oct-11 388.81 143 | 7-Oct-11 369.80 144 | 6-Oct-11 377.37 145 | 5-Oct-11 378.25 146 | 4-Oct-11 372.50 147 | 3-Oct-11 374.60 148 | 30-Sep-11 381.32 149 | 29-Sep-11 390.57 150 | 28-Sep-11 397.01 151 | 27-Sep-11 399.26 152 | 26-Sep-11 403.17 153 | 23-Sep-11 404.30 154 | 22-Sep-11 401.82 155 | 21-Sep-11 412.14 156 | 20-Sep-11 413.45 157 | 19-Sep-11 411.63 158 | 16-Sep-11 400.50 159 | 15-Sep-11 392.96 160 | 14-Sep-11 389.30 161 | 13-Sep-11 384.62 162 | 12-Sep-11 379.94 163 | 9-Sep-11 377.48 164 | 8-Sep-11 384.14 165 | 7-Sep-11 383.93 166 | 6-Sep-11 379.74 167 | 2-Sep-11 374.05 168 | 1-Sep-11 381.03 169 | 31-Aug-11 384.83 170 | 30-Aug-11 389.99 171 | 29-Aug-11 389.97 172 | 26-Aug-11 383.58 173 | 25-Aug-11 373.72 174 | 24-Aug-11 376.18 175 | 23-Aug-11 373.60 176 | 22-Aug-11 356.44 177 | 19-Aug-11 356.03 178 | 18-Aug-11 366.05 179 | 17-Aug-11 380.44 180 | 16-Aug-11 380.48 181 | 15-Aug-11 383.41 182 | 12-Aug-11 376.99 183 | 11-Aug-11 373.70 184 | 10-Aug-11 363.69 185 | 9-Aug-11 374.01 186 | 8-Aug-11 353.21 187 | 5-Aug-11 373.62 188 | 4-Aug-11 377.37 189 | 3-Aug-11 392.57 190 | 2-Aug-11 388.91 191 | 1-Aug-11 396.75 192 | 29-Jul-11 390.48 193 | 28-Jul-11 391.82 194 | 27-Jul-11 392.59 195 | 26-Jul-11 403.41 196 | 25-Jul-11 398.50 197 | 22-Jul-11 393.30 198 | 21-Jul-11 387.29 199 | 20-Jul-11 386.90 200 | 19-Jul-11 376.85 201 | 18-Jul-11 373.80 202 | 15-Jul-11 364.92 203 | 14-Jul-11 357.77 204 | 13-Jul-11 358.02 205 | 12-Jul-11 353.75 206 | 11-Jul-11 354.00 207 | 8-Jul-11 359.71 208 | 7-Jul-11 357.20 209 | 6-Jul-11 351.76 210 | 5-Jul-11 349.43 211 | 1-Jul-11 343.26 212 | 30-Jun-11 335.67 213 | 29-Jun-11 334.04 214 | 28-Jun-11 335.26 215 | 27-Jun-11 332.04 216 | 24-Jun-11 326.35 217 | 23-Jun-11 331.23 218 | 22-Jun-11 322.61 219 | 21-Jun-11 325.30 220 | 20-Jun-11 315.32 221 | 17-Jun-11 320.26 222 | 16-Jun-11 325.16 223 | 15-Jun-11 326.75 224 | 14-Jun-11 332.44 225 | 13-Jun-11 326.60 226 | 10-Jun-11 325.90 227 | 9-Jun-11 331.49 228 | 8-Jun-11 332.24 229 | 7-Jun-11 332.04 230 | 6-Jun-11 338.04 231 | 3-Jun-11 343.44 232 | 2-Jun-11 346.10 233 | 1-Jun-11 345.51 234 | 31-May-11 347.83 235 | 27-May-11 337.41 236 | 26-May-11 335.00 237 | 25-May-11 336.78 238 | 24-May-11 332.19 239 | 23-May-11 334.40 240 | 20-May-11 335.22 241 | 19-May-11 340.53 242 | 18-May-11 339.87 243 | 17-May-11 336.14 244 | 16-May-11 333.30 245 | 13-May-11 340.50 246 | 12-May-11 346.57 247 | 11-May-11 347.23 248 | 10-May-11 349.45 249 | 9-May-11 347.60 250 | 6-May-11 346.66 251 | 5-May-11 346.75 252 | 4-May-11 349.57 253 | 3-May-11 348.20 254 | 2-May-11 346.28 255 | 29-Apr-11 350.13 256 | 28-Apr-11 346.75 257 | 27-Apr-11 350.15 258 | 26-Apr-11 350.42 259 | 25-Apr-11 353.01 260 | 21-Apr-11 350.70 261 | 20-Apr-11 342.41 262 | 19-Apr-11 337.86 263 | 18-Apr-11 331.85 264 | 15-Apr-11 327.46 265 | 14-Apr-11 332.42 266 | 13-Apr-11 336.13 267 | 12-Apr-11 332.40 268 | 11-Apr-11 330.80 269 | 8-Apr-11 335.06 270 | 7-Apr-11 338.08 271 | 6-Apr-11 338.04 272 | 5-Apr-11 338.89 273 | 4-Apr-11 341.19 274 | 1-Apr-11 344.56 275 | 31-Mar-11 348.51 276 | 30-Mar-11 348.63 277 | 29-Mar-11 350.96 278 | 28-Mar-11 350.44 279 | 25-Mar-11 351.54 280 | 24-Mar-11 344.97 281 | 23-Mar-11 339.19 282 | 22-Mar-11 341.20 283 | 21-Mar-11 339.30 284 | 18-Mar-11 330.67 285 | 17-Mar-11 334.64 286 | 16-Mar-11 330.01 287 | 15-Mar-11 345.43 288 | 14-Mar-11 353.56 289 | 11-Mar-11 351.99 290 | 10-Mar-11 346.67 291 | 9-Mar-11 352.47 292 | 8-Mar-11 355.76 293 | 7-Mar-11 355.36 294 | 4-Mar-11 360.00 295 | 3-Mar-11 359.56 296 | 2-Mar-11 352.12 297 | 1-Mar-11 349.31 298 | 28-Feb-11 353.21 299 | 25-Feb-11 348.16 300 | 24-Feb-11 342.88 301 | 23-Feb-11 342.62 302 | 22-Feb-11 338.61 303 | 18-Feb-11 350.56 304 | 17-Feb-11 358.30 305 | 16-Feb-11 363.13 306 | 15-Feb-11 359.90 307 | 14-Feb-11 359.18 308 | 11-Feb-11 356.85 309 | 10-Feb-11 354.54 310 | 9-Feb-11 358.16 311 | 8-Feb-11 355.20 312 | 7-Feb-11 351.88 313 | 4-Feb-11 346.50 314 | 3-Feb-11 343.44 315 | 2-Feb-11 344.32 316 | 1-Feb-11 345.03 317 | 31-Jan-11 339.32 318 | 28-Jan-11 336.10 319 | 27-Jan-11 343.21 320 | 26-Jan-11 343.85 321 | 25-Jan-11 341.40 322 | 24-Jan-11 337.45 323 | 21-Jan-11 326.72 324 | 20-Jan-11 332.68 325 | 19-Jan-11 338.84 326 | 18-Jan-11 340.65 327 | 14-Jan-11 348.48 328 | 13-Jan-11 345.68 329 | 12-Jan-11 344.42 330 | 11-Jan-11 341.64 331 | 10-Jan-11 342.46 332 | 7-Jan-11 336.12 333 | 6-Jan-11 333.73 334 | 5-Jan-11 334.00 335 | 4-Jan-11 331.29 336 | 3-Jan-11 329.57 337 | 31-Dec-10 322.56 338 | 30-Dec-10 323.66 339 | 29-Dec-10 325.29 340 | 28-Dec-10 325.47 341 | 27-Dec-10 324.68 342 | 23-Dec-10 323.60 343 | 22-Dec-10 325.16 344 | 21-Dec-10 324.20 345 | 20-Dec-10 322.21 346 | 17-Dec-10 320.61 347 | 16-Dec-10 321.25 348 | 15-Dec-10 320.36 349 | 14-Dec-10 320.29 350 | 13-Dec-10 321.67 351 | 10-Dec-10 320.56 352 | 9-Dec-10 319.76 353 | 8-Dec-10 321.01 354 | 7-Dec-10 318.21 355 | 6-Dec-10 320.15 356 | 3-Dec-10 317.44 357 | 2-Dec-10 318.15 358 | 1-Dec-10 316.40 359 | 30-Nov-10 311.15 360 | 29-Nov-10 316.87 361 | 26-Nov-10 315.00 362 | 24-Nov-10 314.80 363 | 23-Nov-10 308.73 364 | 22-Nov-10 313.36 365 | 19-Nov-10 306.73 366 | 18-Nov-10 308.43 367 | 17-Nov-10 300.50 368 | 16-Nov-10 301.59 369 | 15-Nov-10 307.04 370 | 12-Nov-10 308.03 371 | 11-Nov-10 316.66 372 | 10-Nov-10 318.03 373 | 9-Nov-10 316.08 374 | 8-Nov-10 318.62 375 | 5-Nov-10 317.13 376 | 4-Nov-10 318.27 377 | 3-Nov-10 312.80 378 | 2-Nov-10 309.36 379 | 1-Nov-10 304.18 380 | 29-Oct-10 300.98 381 | 28-Oct-10 305.24 382 | 27-Oct-10 307.83 383 | 26-Oct-10 308.05 384 | 25-Oct-10 308.84 385 | 22-Oct-10 307.47 386 | 21-Oct-10 309.52 387 | 20-Oct-10 310.53 388 | 19-Oct-10 309.49 389 | 18-Oct-10 318.00 390 | 15-Oct-10 314.74 391 | 14-Oct-10 302.31 392 | 13-Oct-10 300.14 393 | 12-Oct-10 298.54 394 | 11-Oct-10 295.36 395 | 8-Oct-10 294.07 396 | 7-Oct-10 289.22 397 | 6-Oct-10 289.19 398 | 5-Oct-10 288.94 399 | 4-Oct-10 278.64 400 | 1-Oct-10 282.52 401 | 30-Sep-10 283.75 402 | 29-Sep-10 287.37 403 | 28-Sep-10 286.86 404 | 27-Sep-10 291.16 405 | 24-Sep-10 292.32 406 | 23-Sep-10 288.92 407 | 22-Sep-10 287.75 408 | 21-Sep-10 283.77 409 | 20-Sep-10 283.23 410 | 17-Sep-10 275.37 411 | 16-Sep-10 276.57 412 | 15-Sep-10 270.22 413 | 14-Sep-10 268.06 414 | 13-Sep-10 267.04 415 | 10-Sep-10 263.41 416 | 9-Sep-10 263.07 417 | 8-Sep-10 262.92 418 | 7-Sep-10 257.81 419 | 6-Sep-10 258.77 420 | 3-Sep-10 258.77 421 | 2-Sep-10 252.17 422 | 1-Sep-10 250.33 423 | 31-Aug-10 243.10 424 | 30-Aug-10 242.50 425 | 27-Aug-10 241.62 426 | 26-Aug-10 240.28 427 | 25-Aug-10 242.89 428 | 24-Aug-10 239.93 429 | 23-Aug-10 245.80 430 | 20-Aug-10 249.64 431 | 19-Aug-10 249.88 432 | 18-Aug-10 253.07 433 | 17-Aug-10 251.97 434 | 16-Aug-10 247.64 435 | 13-Aug-10 249.10 436 | 12-Aug-10 251.79 437 | 11-Aug-10 250.19 438 | 10-Aug-10 259.41 439 | 9-Aug-10 261.75 440 | 6-Aug-10 260.09 441 | 5-Aug-10 261.70 442 | 4-Aug-10 262.98 443 | 3-Aug-10 261.93 444 | 2-Aug-10 261.85 445 | 30-Jul-10 257.25 446 | 29-Jul-10 258.11 447 | 28-Jul-10 260.96 448 | 27-Jul-10 264.08 449 | 26-Jul-10 259.28 450 | 23-Jul-10 259.94 451 | 22-Jul-10 259.02 452 | 21-Jul-10 254.24 453 | 20-Jul-10 251.89 454 | 19-Jul-10 245.58 455 | 16-Jul-10 249.90 456 | 15-Jul-10 251.45 457 | 14-Jul-10 252.73 458 | 13-Jul-10 251.80 459 | 12-Jul-10 257.28 460 | 9-Jul-10 259.62 461 | 8-Jul-10 258.09 462 | 7-Jul-10 258.66 463 | 6-Jul-10 248.63 464 | 5-Jul-10 246.94 465 | 2-Jul-10 246.94 466 | 1-Jul-10 248.48 467 | 30-Jun-10 251.53 468 | 29-Jun-10 256.17 469 | 28-Jun-10 268.30 470 | 25-Jun-10 266.70 471 | 24-Jun-10 269.00 472 | 23-Jun-10 270.97 473 | 22-Jun-10 273.85 474 | 21-Jun-10 270.17 475 | 18-Jun-10 274.07 476 | 17-Jun-10 271.87 477 | 16-Jun-10 267.25 478 | 15-Jun-10 259.69 479 | 14-Jun-10 254.28 480 | 11-Jun-10 253.51 481 | 10-Jun-10 250.51 482 | 9-Jun-10 243.20 483 | 8-Jun-10 249.33 484 | 7-Jun-10 250.94 485 | 4-Jun-10 255.96 486 | 3-Jun-10 263.12 487 | 2-Jun-10 263.95 488 | 1-Jun-10 260.83 489 | 31-May-10 256.88 490 | 28-May-10 256.88 491 | 27-May-10 253.35 492 | 26-May-10 244.11 493 | 25-May-10 245.22 494 | 24-May-10 246.76 495 | 21-May-10 242.32 496 | 20-May-10 237.76 497 | 19-May-10 248.34 498 | 18-May-10 252.36 499 | 17-May-10 254.22 500 | 14-May-10 253.82 501 | 13-May-10 258.36 502 | 12-May-10 262.09 503 | 11-May-10 256.52 504 | 10-May-10 253.99 505 | 7-May-10 235.86 506 | 6-May-10 246.25 507 | 5-May-10 255.98 508 | 4-May-10 258.68 509 | 3-May-10 266.35 510 | 30-Apr-10 261.09 511 | 29-Apr-10 268.64 512 | 28-Apr-10 261.60 513 | 27-Apr-10 262.04 514 | 26-Apr-10 269.50 515 | 23-Apr-10 270.83 516 | 22-Apr-10 266.47 517 | 21-Apr-10 259.22 518 | 20-Apr-10 244.59 519 | 19-Apr-10 247.07 520 | 16-Apr-10 247.40 521 | 15-Apr-10 248.92 522 | 14-Apr-10 245.69 523 | 13-Apr-10 242.43 524 | 12-Apr-10 242.29 525 | 9-Apr-10 241.79 526 | 8-Apr-10 239.95 527 | 7-Apr-10 240.60 528 | 6-Apr-10 239.54 529 | 5-Apr-10 238.49 530 | 2-Apr-10 235.97 531 | 1-Apr-10 235.97 532 | 31-Mar-10 235.00 533 | 30-Mar-10 235.84 534 | 29-Mar-10 232.39 535 | 26-Mar-10 230.90 536 | 25-Mar-10 226.65 537 | 24-Mar-10 229.37 538 | 23-Mar-10 228.36 539 | 22-Mar-10 224.75 540 | 19-Mar-10 222.25 541 | 18-Mar-10 224.65 542 | 17-Mar-10 224.12 543 | 16-Mar-10 224.45 544 | 15-Mar-10 223.84 545 | 12-Mar-10 226.60 546 | 11-Mar-10 225.50 547 | 10-Mar-10 224.84 548 | 9-Mar-10 223.02 549 | 8-Mar-10 219.08 550 | 5-Mar-10 218.95 551 | 4-Mar-10 210.71 552 | 3-Mar-10 209.33 553 | 2-Mar-10 208.85 554 | 1-Mar-10 208.99 555 | 26-Feb-10 204.62 556 | 25-Feb-10 202.00 557 | 24-Feb-10 200.66 558 | 23-Feb-10 197.06 559 | 22-Feb-10 200.42 560 | 19-Feb-10 201.67 561 | 18-Feb-10 202.93 562 | 17-Feb-10 202.55 563 | 16-Feb-10 203.40 564 | 15-Feb-10 200.38 565 | 12-Feb-10 200.38 566 | 11-Feb-10 198.67 567 | 10-Feb-10 195.12 568 | 9-Feb-10 196.19 569 | 8-Feb-10 194.12 570 | 5-Feb-10 195.46 571 | 4-Feb-10 192.05 572 | 3-Feb-10 199.23 573 | 2-Feb-10 195.86 574 | 1-Feb-10 194.73 575 | 29-Jan-10 192.06 576 | 28-Jan-10 199.29 577 | 27-Jan-10 207.88 578 | 26-Jan-10 205.94 579 | 25-Jan-10 203.08 580 | 22-Jan-10 197.75 581 | 21-Jan-10 208.07 582 | 20-Jan-10 211.72 583 | 19-Jan-10 215.04 584 | 18-Jan-10 205.93 585 | 15-Jan-10 205.93 586 | 14-Jan-10 209.43 587 | 13-Jan-10 210.65 588 | 12-Jan-10 207.72 589 | 11-Jan-10 210.11 590 | 8-Jan-10 211.98 591 | 7-Jan-10 210.58 592 | 6-Jan-10 210.97 593 | 5-Jan-10 214.38 594 | 4-Jan-10 214.01 595 | 1-Jan-10 210.73 -------------------------------------------------------------------------------- /Chapter3/multiLine.csv: -------------------------------------------------------------------------------- 1 | date,USD/CAD,USD/EUR,USD/GBP 2 | 03/10/2013,1.0284,0.7675,0.6651 3 | 03/03/2013,1.0254,0.763,0.6609 4 | 2/24/2013,1.014,0.7521,0.6512 5 | 2/17/2013,1.0035,0.7468,0.6402 6 | 02/10/2013,0.9979,0.7402,0.6361 7 | 02/03/2013,1.0023,0.7388,0.6342 8 | 1/27/2013,0.9973,0.7488,0.6315 9 | 1/20/2013,0.9864,0.7498,0.6241 10 | 1/13/2013,0.9859,0.7604,0.6217 11 | 01/06/2013,0.9907,0.7601,0.6183 12 | 12/30/2012,0.9934,0.7571,0.6193 13 | 12/23/2012,0.9877,0.7577,0.6166 14 | 12/16/2012,0.986,0.7678,0.6208 15 | 12/09/2012,0.992,0.7684,0.6225 16 | 12/02/2012,0.9931,0.7711,0.6241 17 | 11/25/2012,0.9971,0.779,0.6273 18 | 11/18/2012,1.0011,0.7856,0.6298 19 | 11/11/2012,0.9967,0.7825,0.6259 20 | 11/04/2012,0.9981,0.7739,0.6218 21 | 10/28/2012,0.994,0.77,0.6233 22 | 10/21/2012,0.9838,0.7676,0.6219 23 | 10/14/2012,0.9785,0.7723,0.6228 24 | 10/07/2012,0.9824,0.7729,0.6194 25 | 9/30/2012,0.9804,0.7746,0.6171 26 | 9/23/2012,0.9744,0.7664,0.6161 27 | 9/16/2012,0.974,0.7744,0.6213 28 | 09/09/2012,0.9847,0.7915,0.6283 29 | 09/02/2012,0.9895,0.7976,0.632 30 | 8/26/2012,0.9903,0.8032,0.6336 31 | 8/19/2012,0.9902,0.8116,0.6372 32 | 08/12/2012,0.9962,0.8095,0.6394 33 | 08/05/2012,1.0029,0.8135,0.6391 34 | 7/29/2012,1.013,0.8206,0.6409 35 | 7/22/2012,1.0122,0.8167,0.6397 36 | 7/15/2012,1.0187,0.8158,0.6448 37 | 07/08/2012,1.0157,0.7995,0.6405 38 | 07/01/2012,1.0247,0.7975,0.6407 39 | 6/24/2012,1.0225,0.792,0.6382 40 | 6/17/2012,1.0253,0.7954,0.6427 41 | 06/10/2012,1.0339,0.8005,0.6481 42 | 06/03/2012,1.0302,0.8022,0.6434 43 | 5/27/2012,1.0235,0.7901,0.6353 44 | 5/20/2012,1.0098,0.7819,0.6269 45 | 5/13/2012,0.9988,0.7701,0.6198 46 | 05/06/2012,0.9869,0.7584,0.6169 47 | 4/29/2012,0.9869,0.7571,0.6185 48 | 4/22/2012,0.9944,0.7617,0.6259 49 | 4/15/2012,0.9986,0.7628,0.6293 50 | 04/08/2012,0.9948,0.7571,0.6276 51 | 04/01/2012,0.9965,0.7509,0.6274 52 | 3/25/2012,0.9935,0.7564,0.6306 53 | 3/18/2012,0.9914,0.7628,0.6365 54 | 03/11/2012,0.9934,0.7588,0.6338 55 | 03/04/2012,0.9929,0.7483,0.6295 56 | 2/26/2012,0.9968,0.7526,0.6328 57 | 2/19/2012,0.9987,0.7604,0.6345 58 | 02/12/2012,0.9964,0.7578,0.6324 59 | 02/05/2012,0.9994,0.76,0.6339 60 | 1/29/2012,1.007,0.766,0.6398 61 | 1/22/2012,1.0156,0.781,0.6489 62 | 1/15/2012,1.022,0.785,0.6497 63 | 01/08/2012,1.0187,0.7754,0.6438 64 | 01/01/2012,1.0206,0.7688,0.6428 65 | 12/25/2011,1.0287,0.7661,0.6406 66 | 12/18/2011,1.0303,0.7615,0.6427 67 | 12/11/2011,1.0159,0.7467,0.6392 68 | 12/04/2011,1.0277,0.7479,0.6415 69 | 11/27/2011,1.0402,0.7459,0.6411 70 | 11/20/2011,1.021,0.7364,0.6303 71 | 11/13/2011,1.0161,0.7289,0.6243 72 | 11/06/2011,1.0084,0.7217,0.6239 73 | 10/30/2011,1.0018,0.7146,0.6241 74 | 10/23/2011,1.0135,0.724,0.6324 75 | 10/16/2011,1.0241,0.7314,0.6374 76 | 10/09/2011,1.0461,0.7494,0.6453 77 | 10/02/2011,1.0326,0.7397,0.6421 78 | 9/25/2011,1.0036,0.7343,0.6412 79 | 9/18/2011,0.9893,0.7289,0.6323 80 | 09/11/2011,0.9892,0.7147,0.6239 81 | 09/04/2011,0.9794,0.6954,0.6138 82 | 8/28/2011,0.9869,0.6934,0.609 83 | 8/21/2011,0.9858,0.6961,0.6089 84 | 8/14/2011,0.9869,0.7012,0.6137 85 | 08/07/2011,0.9651,0.7004,0.6113 86 | 7/31/2011,0.9486,0.6949,0.6114 87 | 7/24/2011,0.9507,0.7028,0.618 88 | 7/17/2011,0.9612,0.7075,0.6233 89 | 07/10/2011,0.9611,0.6943,0.6233 90 | 07/03/2011,0.975,0.6958,0.6244 91 | 6/26/2011,0.9792,0.7,0.621 92 | 6/19/2011,0.9777,0.6988,0.6156 93 | 06/12/2011,0.9777,0.6868,0.611 94 | 06/05/2011,0.9752,0.6933,0.6084 95 | 5/29/2011,0.9767,0.7067,0.6139 96 | 5/22/2011,0.971,0.7044,0.6168 97 | 5/15/2011,0.9635,0.7004,0.6126 98 | 05/08/2011,0.9558,0.6805,0.605 99 | 05/01/2011,0.9508,0.6803,0.603 100 | 4/24/2011,0.9562,0.6919,0.6099 101 | 4/17/2011,0.9592,0.6916,0.6124 102 | 04/10/2011,0.9607,0.6991,0.6149 103 | 04/03/2011,0.9726,0.7076,0.6231 104 | 3/27/2011,0.9798,0.7063,0.6168 105 | 3/20/2011,0.9814,0.7142,0.6204 106 | 3/13/2011,0.9723,0.7187,0.6185 107 | 03/06/2011,0.9738,0.7216,0.6157 108 | 2/27/2011,0.9843,0.7288,0.6179 109 | 2/20/2011,0.9862,0.737,0.6205 110 | 2/13/2011,0.9909,0.7351,0.6219 111 | 02/06/2011,0.9931,0.7309,0.6226 112 | 1/30/2011,0.9957,0.7324,0.6285 113 | 1/23/2011,0.9919,0.7437,0.6273 114 | 1/16/2011,0.9908,0.7632,0.6374 115 | 01/09/2011,0.9952,0.7585,0.6436 116 | 01/02/2011,1.002,0.7561,0.6464 117 | 12/26/2010,1.0125,0.7612,0.6463 118 | 12/19/2010,1.0079,0.7535,0.6373 119 | 12/12/2010,1.0076,0.7523,0.634 120 | 12/05/2010,1.0147,0.7576,0.6401 121 | 11/28/2010,1.0166,0.7436,0.6322 122 | 11/21/2010,1.0161,0.734,0.6246 123 | 11/14/2010,1.0043,0.7236,0.6204 124 | 11/07/2010,1.0089,0.7124,0.6206 125 | 10/31/2010,1.0226,0.7187,0.631 126 | 10/24/2010,1.0221,0.718,0.633 127 | 10/17/2010,1.0086,0.7158,0.6272 128 | 10/10/2010,1.016,0.7219,0.6295 129 | 10/03/2010,1.0263,0.7351,0.6322 130 | 9/26/2010,1.029,0.7536,0.638 131 | 9/19/2010,1.0296,0.7724,0.6438 132 | 09/12/2010,1.0376,0.7833,0.6488 133 | 09/05/2010,1.0514,0.7821,0.6472 134 | 8/29/2010,1.0542,0.7873,0.6449 135 | 8/22/2010,1.0393,0.7813,0.6414 136 | 8/15/2010,1.0362,0.7686,0.6351 137 | 08/08/2010,1.0231,0.7586,0.63 138 | 08/01/2010,1.033,0.769,0.6422 139 | 7/25/2010,1.0454,0.7753,0.6535 140 | 7/18/2010,1.039,0.784,0.6576 141 | 07/11/2010,1.0501,0.7929,0.6602 142 | 07/04/2010,1.0514,0.808,0.6628 143 | 6/27/2010,1.0305,0.8105,0.6709 144 | 6/20/2010,1.0272,0.8138,0.6779 145 | 6/13/2010,1.0458,0.8319,0.6885 146 | 06/06/2010,1.0493,0.8204,0.687 147 | 5/30/2010,1.0599,0.8098,0.692 148 | 5/23/2010,1.0474,0.8061,0.6931 149 | 5/16/2010,1.0268,0.7913,0.6774 150 | 05/09/2010,1.0294,0.7717,0.6645 151 | 05/02/2010,1.0072,0.7523,0.6527 152 | 4/25/2010,1.0045,0.7457,0.651 153 | 4/18/2010,1.0038,0.7373,0.6489 154 | 04/11/2010,1.004,0.7446,0.655 155 | 04/04/2010,1.0162,0.7415,0.6616 156 | 3/28/2010,1.0213,0.7443,0.6687 157 | 3/21/2010,1.0155,0.7313,0.6596 158 | 3/14/2010,1.0248,0.7317,0.6631 159 | 03/07/2010,1.0368,0.7347,0.6633 160 | 2/28/2010,1.0497,0.7361,0.6505 161 | 2/21/2010,1.0455,0.7341,0.6402 162 | 2/14/2010,1.0625,0.7304,0.6389 163 | 02/07/2010,1.0664,0.7227,0.6303 164 | 1/31/2010,1.0624,0.7123,0.62 165 | 1/24/2010,1.0401,0.7025,0.6152 166 | 1/17/2010,1.0305,0.6914,0.6175 167 | 01/10/2010,1.0382,0.696,0.6232 168 | 01/03/2010,1.0487,0.696,0.6234 169 | 12/27/2009,1.0555,0.6973,0.6237 170 | 12/20/2009,1.0631,0.6897,0.616 171 | 12/13/2009,1.0563,0.6778,0.6121 172 | 12/06/2009,1.0538,0.6659,0.6043 173 | 11/29/2009,1.0604,0.6679,0.6042 174 | 11/22/2009,1.0572,0.6707,0.5994 175 | 11/15/2009,1.0562,0.6697,0.6002 176 | 11/08/2009,1.0729,0.6759,0.6062 177 | 11/01/2009,1.0683,0.6736,0.6099 178 | 10/25/2009,1.0437,0.6681,0.6088 179 | 10/18/2009,1.0343,0.6735,0.6235 180 | 10/11/2009,1.0608,0.6806,0.6271 181 | 10/04/2009,1.0833,0.6845,0.6273 182 | 9/27/2009,1.0777,0.6794,0.6176 183 | 9/20/2009,1.0734,0.6821,0.6065 184 | 9/13/2009,1.0794,0.691,0.6051 185 | 09/06/2009,1.0964,0.7001,0.6139 186 | 8/30/2009,1.0859,0.6989,0.6116 187 | 8/23/2009,1.0959,0.7039,0.6066 188 | 8/16/2009,1.0901,0.7042,0.6038 189 | 08/09/2009,1.0748,0.6982,0.5943 190 | 08/02/2009,1.0827,0.7052,0.6059 191 | 7/26/2009,1.0999,0.7046,0.6082 192 | 7/19/2009,1.135,0.7126,0.6131 193 | 07/12/2009,1.1622,0.7169,0.6167 194 | 07/05/2009,1.1562,0.7119,0.6077 195 | 6/28/2009,1.1483,0.7151,0.6081 196 | 6/21/2009,1.1296,0.7184,0.6098 197 | 6/14/2009,1.1123,0.7142,0.615 198 | 06/07/2009,1.0975,0.7068,0.6149 199 | 5/31/2009,1.1131,0.7143,0.6252 200 | 5/24/2009,1.1497,0.7292,0.6427 201 | 5/17/2009,1.1646,0.7353,0.658 202 | 05/10/2009,1.1707,0.7471,0.6643 203 | 05/03/2009,1.2035,0.757,0.6783 204 | 4/26/2009,1.2253,0.7659,0.6826 205 | 4/19/2009,1.2156,0.7584,0.6743 206 | 04/12/2009,1.2319,0.7518,0.6788 207 | 04/05/2009,1.2472,0.7505,0.6906 208 | 3/29/2009,1.233,0.7397,0.6891 209 | 3/22/2009,1.2572,0.7554,0.704 210 | 3/15/2009,1.2832,0.7833,0.7181 211 | 03/08/2009,1.2838,0.7929,0.7068 212 | 03/01/2009,1.2545,0.7836,0.695 213 | 2/22/2009,1.2513,0.7866,0.6993 214 | 2/15/2009,1.2327,0.7745,0.6871 215 | 02/08/2009,1.2322,0.7776,0.6895 216 | 02/01/2009,1.2257,0.7676,0.7073 217 | 1/25/2009,1.2506,0.7664,0.7088 218 | 1/18/2009,1.224,0.7525,0.6762 219 | 01/11/2009,1.1926,0.7331,0.6715 220 | 01/04/2009,1.217,0.7129,0.6864 221 | 12/28/2008,1.2165,0.7146,0.6767 222 | 12/21/2008,1.2201,0.7204,0.6593 223 | 12/14/2008,1.2547,0.7671,0.6739 224 | 12/07/2008,1.2556,0.7879,0.671 225 | 11/30/2008,1.2422,0.7813,0.6567 226 | 11/23/2008,1.2493,0.7944,0.6715 227 | 11/16/2008,1.2091,0.7896,0.6562 228 | 11/09/2008,1.1846,0.782,0.6295 229 | 11/02/2008,1.2496,0.7871,0.6252 230 | 10/26/2008,1.2293,0.7681,0.6042 231 | 10/19/2008,1.172,0.7402,0.5782 232 | 10/12/2008,1.1227,0.7354,0.576 233 | 10/05/2008,1.0588,0.7076,0.5579 234 | 9/28/2008,1.0374,0.6837,0.5418 235 | 9/21/2008,1.062,0.6994,0.5538 236 | 9/14/2008,1.0661,0.7067,0.5656 237 | 09/07/2008,1.0653,0.6908,0.5602 238 | 8/31/2008,1.0507,0.6791,0.5439 239 | 8/24/2008,1.0558,0.6777,0.5365 240 | 8/17/2008,1.0645,0.6723,0.5292 241 | 08/10/2008,1.0449,0.6499,0.5126 242 | 08/03/2008,1.0232,0.6397,0.5042 243 | 7/27/2008,1.0096,0.6337,0.5013 244 | 7/20/2008,1.0048,0.6294,0.5007 245 | 7/13/2008,1.0147,0.6348,0.5053 246 | 07/06/2008,1.0159,0.634,0.5025 247 | 6/29/2008,1.0128,0.639,0.5056 248 | 6/22/2008,1.0204,0.6448,0.5096 249 | 6/15/2008,1.023,0.6433,0.5105 250 | 06/08/2008,1.008,0.6426,0.5087 251 | 06/01/2008,0.9909,0.6385,0.5053 252 | 5/25/2008,0.9907,0.638,0.5082 253 | 5/18/2008,1.0028,0.6453,0.5126 254 | 05/11/2008,1.0109,0.6471,0.5094 255 | 05/04/2008,1.014,0.6429,0.505 256 | 4/27/2008,1.0105,0.6328,0.5034 257 | 4/20/2008,1.0133,0.6314,0.5053 258 | 4/13/2008,1.0157,0.6343,0.5054 259 | 04/06/2008,1.0168,0.6363,0.5027 260 | 3/30/2008,1.0197,0.6397,0.5013 261 | 3/23/2008,1.0053,0.6404,0.5004 -------------------------------------------------------------------------------- /Chapter3/pokemon.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": " 001", 4 | "typeTwo": " Poison", 5 | "name": " Bulbasaur", 6 | "type": " Grass" 7 | }, 8 | { 9 | "id": " 002", 10 | "typeTwo": " Poison", 11 | "name": " Ivysaur", 12 | "type": " Grass" 13 | }, 14 | { 15 | "id": " 003", 16 | "typeTwo": " Poison", 17 | "name": " Venusaur", 18 | "type": " Grass" 19 | }, 20 | { 21 | "id": " 006", 22 | "typeTwo": " Flying", 23 | "name": " Charizard", 24 | "type": " Fire" 25 | }, 26 | { 27 | "id": " 012", 28 | "typeTwo": " Flying", 29 | "name": " Butterfree", 30 | "type": " Bug" 31 | }, 32 | { 33 | "id": " 013", 34 | "typeTwo": " Poison", 35 | "name": " Weedle", 36 | "type": " Bug" 37 | }, 38 | { 39 | "id": " 014", 40 | "typeTwo": " Poison", 41 | "name": " Kakuna", 42 | "type": " Bug" 43 | }, 44 | { 45 | "id": " 015", 46 | "typeTwo": " Poison", 47 | "name": " Beedrill", 48 | "type": " Bug" 49 | }, 50 | { 51 | "id": " 016", 52 | "typeTwo": " Flying", 53 | "name": " Pidgey", 54 | "type": " Normal" 55 | }, 56 | { 57 | "id": " 017", 58 | "typeTwo": " Flying", 59 | "name": " Pidgeotto", 60 | "type": " Normal" 61 | }, 62 | { 63 | "id": " 018", 64 | "typeTwo": " Flying", 65 | "name": " Pidgeot", 66 | "type": " Normal" 67 | }, 68 | { 69 | "id": " 021", 70 | "typeTwo": " Flying", 71 | "name": " Spearow", 72 | "type": " Normal" 73 | }, 74 | { 75 | "id": " 022", 76 | "typeTwo": " Flying", 77 | "name": " Fearow", 78 | "type": " Normal" 79 | }, 80 | { 81 | "id": " 031", 82 | "typeTwo": " Ground", 83 | "name": " Nidoqueen", 84 | "type": " Poison" 85 | }, 86 | { 87 | "id": " 034", 88 | "typeTwo": " Ground", 89 | "name": " Nidoking", 90 | "type": " Poison" 91 | }, 92 | { 93 | "id": " 041", 94 | "typeTwo": " Flying", 95 | "name": " Zubat", 96 | "type": " Poison" 97 | }, 98 | { 99 | "id": " 042", 100 | "typeTwo": " Flying", 101 | "name": " Golbat", 102 | "type": " Poison" 103 | }, 104 | { 105 | "id": " 043", 106 | "typeTwo": " Poison", 107 | "name": " Oddish", 108 | "type": " Grass" 109 | }, 110 | { 111 | "id": " 044", 112 | "typeTwo": " Poison", 113 | "name": " Gloom", 114 | "type": " Grass" 115 | }, 116 | { 117 | "id": " 045", 118 | "typeTwo": " Poison", 119 | "name": " Vileplume", 120 | "type": " Grass" 121 | }, 122 | { 123 | "id": " 046", 124 | "typeTwo": " Grass", 125 | "name": " Paras", 126 | "type": " Bug" 127 | }, 128 | { 129 | "id": " 047", 130 | "typeTwo": " Grass", 131 | "name": " Parasect", 132 | "type": " Bug" 133 | }, 134 | { 135 | "id": " 048", 136 | "typeTwo": " Poison", 137 | "name": " Venonat", 138 | "type": " Bug" 139 | }, 140 | { 141 | "id": " 049", 142 | "typeTwo": " Poison", 143 | "name": " Venomoth", 144 | "type": " Bug" 145 | }, 146 | { 147 | "id": " 062", 148 | "typeTwo": " Fighting", 149 | "name": " Poliwrath", 150 | "type": " Water" 151 | }, 152 | { 153 | "id": " 069", 154 | "typeTwo": " Poison", 155 | "name": " Bellsprout", 156 | "type": " Grass" 157 | }, 158 | { 159 | "id": " 070", 160 | "typeTwo": " Poison", 161 | "name": " Weepinbell", 162 | "type": " Grass" 163 | }, 164 | { 165 | "id": " 071", 166 | "typeTwo": " Poison", 167 | "name": " Victreebel", 168 | "type": " Grass" 169 | }, 170 | { 171 | "id": " 072", 172 | "typeTwo": " Poison", 173 | "name": " Tentacool", 174 | "type": " Water" 175 | }, 176 | { 177 | "id": " 073", 178 | "typeTwo": " Poison", 179 | "name": " Tentacruel", 180 | "type": " Water" 181 | }, 182 | { 183 | "id": " 074", 184 | "typeTwo": " Ground", 185 | "name": " Geodude", 186 | "type": " Rock" 187 | }, 188 | { 189 | "id": " 075", 190 | "typeTwo": " Ground", 191 | "name": " Graveler", 192 | "type": " Rock" 193 | }, 194 | { 195 | "id": " 076", 196 | "typeTwo": " Ground", 197 | "name": " Golem", 198 | "type": " Rock" 199 | }, 200 | { 201 | "id": " 079", 202 | "typeTwo": " Psychic", 203 | "name": " Slowpoke", 204 | "type": " Water" 205 | }, 206 | { 207 | "id": " 080", 208 | "typeTwo": " Psychic", 209 | "name": " Slowbro", 210 | "type": " Water" 211 | }, 212 | { 213 | "id": " 081", 214 | "typeTwo": " Steel", 215 | "name": " Magnemite", 216 | "type": " Electric" 217 | }, 218 | { 219 | "id": " 082", 220 | "typeTwo": " Steel", 221 | "name": " Magneton", 222 | "type": " Electric" 223 | }, 224 | { 225 | "id": " 083", 226 | "typeTwo": " Flying", 227 | "name": " Farfetch'd", 228 | "type": " Normal" 229 | }, 230 | { 231 | "id": " 084", 232 | "typeTwo": " Flying", 233 | "name": " Doduo", 234 | "type": " Normal" 235 | }, 236 | { 237 | "id": " 085", 238 | "typeTwo": " Flying", 239 | "name": " Dodrio", 240 | "type": " Normal" 241 | }, 242 | { 243 | "id": " 087", 244 | "typeTwo": " Ice", 245 | "name": " Dewgong", 246 | "type": " Water" 247 | }, 248 | { 249 | "id": " 091", 250 | "typeTwo": " Ice", 251 | "name": " Cloyster", 252 | "type": " Water" 253 | }, 254 | { 255 | "id": " 092", 256 | "typeTwo": " Poison", 257 | "name": " Gastly", 258 | "type": " Ghost" 259 | }, 260 | { 261 | "id": " 093", 262 | "typeTwo": " Poison", 263 | "name": " Haunter", 264 | "type": " Ghost" 265 | }, 266 | { 267 | "id": " 094", 268 | "typeTwo": " Poison", 269 | "name": " Gengar", 270 | "type": " Ghost" 271 | }, 272 | { 273 | "id": " 095", 274 | "typeTwo": " Ground", 275 | "name": " Onix", 276 | "type": " Rock" 277 | }, 278 | { 279 | "id": " 102", 280 | "typeTwo": " Psychic", 281 | "name": " Exeggcute", 282 | "type": " Grass" 283 | }, 284 | { 285 | "id": " 103", 286 | "typeTwo": " Psychic", 287 | "name": " Exeggutor", 288 | "type": " Grass" 289 | }, 290 | { 291 | "id": " 111", 292 | "typeTwo": " Rock", 293 | "name": " Rhyhorn", 294 | "type": " Ground" 295 | }, 296 | { 297 | "id": " 112", 298 | "typeTwo": " Rock", 299 | "name": " Rhydon", 300 | "type": " Ground" 301 | }, 302 | { 303 | "id": " 121", 304 | "typeTwo": " Psychic", 305 | "name": " Starmie", 306 | "type": " Water" 307 | }, 308 | { 309 | "id": " 123", 310 | "typeTwo": " Flying", 311 | "name": " Scyther", 312 | "type": " Bug" 313 | }, 314 | { 315 | "id": " 124", 316 | "typeTwo": " Psychic", 317 | "name": " Jynx", 318 | "type": " Ice" 319 | }, 320 | { 321 | "id": " 130", 322 | "typeTwo": " Flying", 323 | "name": " Gyarados", 324 | "type": " Water" 325 | }, 326 | { 327 | "id": " 131", 328 | "typeTwo": " Ice", 329 | "name": " Lapras", 330 | "type": " Water" 331 | }, 332 | { 333 | "id": " 138", 334 | "typeTwo": " Water", 335 | "name": " Omanyte", 336 | "type": " Rock" 337 | }, 338 | { 339 | "id": " 139", 340 | "typeTwo": " Water", 341 | "name": " Omastar", 342 | "type": " Rock" 343 | }, 344 | { 345 | "id": " 140", 346 | "typeTwo": " Water", 347 | "name": " Kabuto", 348 | "type": " Rock" 349 | }, 350 | { 351 | "id": " 141", 352 | "typeTwo": " Water", 353 | "name": " Kabutops", 354 | "type": " Rock" 355 | }, 356 | { 357 | "id": " 142", 358 | "typeTwo": " Flying", 359 | "name": " Aerodactyl", 360 | "type": " Rock" 361 | }, 362 | { 363 | "id": " 144", 364 | "typeTwo": " Flying", 365 | "name": " Articuno", 366 | "type": " Ice" 367 | }, 368 | { 369 | "id": " 145", 370 | "typeTwo": " Flying", 371 | "name": " Zapdos", 372 | "type": " Electric" 373 | }, 374 | { 375 | "id": " 146", 376 | "typeTwo": " Flying", 377 | "name": " Moltres", 378 | "type": " Fire" 379 | }, 380 | { 381 | "id": " 149", 382 | "typeTwo": " Flying", 383 | "name": " Dragonite", 384 | "type": " Dragon" 385 | }, 386 | { 387 | "id": " 163", 388 | "typeTwo": " Flying", 389 | "name": " Hoothoot", 390 | "type": " Normal" 391 | }, 392 | { 393 | "id": " 164", 394 | "typeTwo": " Flying", 395 | "name": " Noctowl", 396 | "type": " Normal" 397 | }, 398 | { 399 | "id": " 165", 400 | "typeTwo": " Flying", 401 | "name": " Ledyba", 402 | "type": " Bug" 403 | }, 404 | { 405 | "id": " 166", 406 | "typeTwo": " Flying", 407 | "name": " Ledian", 408 | "type": " Bug" 409 | }, 410 | { 411 | "id": " 167", 412 | "typeTwo": " Poison", 413 | "name": " Spinarak", 414 | "type": " Bug" 415 | }, 416 | { 417 | "id": " 168", 418 | "typeTwo": " Poison", 419 | "name": " Ariados", 420 | "type": " Bug" 421 | }, 422 | { 423 | "id": " 169", 424 | "typeTwo": " Flying", 425 | "name": " Crobat", 426 | "type": " Poison" 427 | }, 428 | { 429 | "id": " 170", 430 | "typeTwo": " Electric", 431 | "name": " Chinchou", 432 | "type": " Water" 433 | }, 434 | { 435 | "id": " 171", 436 | "typeTwo": " Electric", 437 | "name": " Lanturn", 438 | "type": " Water" 439 | }, 440 | { 441 | "id": " 176", 442 | "typeTwo": " Flying", 443 | "name": " Togetic", 444 | "type": " Normal" 445 | }, 446 | { 447 | "id": " 177", 448 | "typeTwo": " Flying", 449 | "name": " Natu", 450 | "type": " Psychic" 451 | }, 452 | { 453 | "id": " 178", 454 | "typeTwo": " Flying", 455 | "name": " Xatu", 456 | "type": " Psychic" 457 | }, 458 | { 459 | "id": " 187", 460 | "typeTwo": " Flying", 461 | "name": " Hoppip", 462 | "type": " Grass" 463 | }, 464 | { 465 | "id": " 188", 466 | "typeTwo": " Flying", 467 | "name": " Skiploom", 468 | "type": " Grass" 469 | }, 470 | { 471 | "id": " 189", 472 | "typeTwo": " Flying", 473 | "name": " Jumpluff", 474 | "type": " Grass" 475 | }, 476 | { 477 | "id": " 193", 478 | "typeTwo": " Flying", 479 | "name": " Yanma", 480 | "type": " Bug" 481 | }, 482 | { 483 | "id": " 194", 484 | "typeTwo": " Ground", 485 | "name": " Wooper", 486 | "type": " Water" 487 | }, 488 | { 489 | "id": " 195", 490 | "typeTwo": " Ground", 491 | "name": " Quagsire", 492 | "type": " Water" 493 | }, 494 | { 495 | "id": " 198", 496 | "typeTwo": " Flying", 497 | "name": " Murkrow", 498 | "type": " Dark" 499 | }, 500 | { 501 | "id": " 199", 502 | "typeTwo": " Psychic", 503 | "name": " Slowking", 504 | "type": " Water" 505 | }, 506 | { 507 | "id": " 203", 508 | "typeTwo": " Psychic", 509 | "name": " Girafarig", 510 | "type": " Normal" 511 | }, 512 | { 513 | "id": " 205", 514 | "typeTwo": " Steel", 515 | "name": " Forretress", 516 | "type": " Bug" 517 | }, 518 | { 519 | "id": " 207", 520 | "typeTwo": " Flying", 521 | "name": " Gligar", 522 | "type": " Ground" 523 | }, 524 | { 525 | "id": " 208", 526 | "typeTwo": " Ground", 527 | "name": " Steelix", 528 | "type": " Steel" 529 | }, 530 | { 531 | "id": " 211", 532 | "typeTwo": " Poison", 533 | "name": " Qwilfish", 534 | "type": " Water" 535 | }, 536 | { 537 | "id": " 212", 538 | "typeTwo": " Steel", 539 | "name": " Scizor", 540 | "type": " Bug" 541 | }, 542 | { 543 | "id": " 213", 544 | "typeTwo": " Rock", 545 | "name": " Shuckle", 546 | "type": " Bug" 547 | }, 548 | { 549 | "id": " 214", 550 | "typeTwo": " Fighting", 551 | "name": " Heracross", 552 | "type": " Bug" 553 | }, 554 | { 555 | "id": " 215", 556 | "typeTwo": " Ice", 557 | "name": " Sneasel", 558 | "type": " Dark" 559 | }, 560 | { 561 | "id": " 219", 562 | "typeTwo": " Rock", 563 | "name": " Magcargo", 564 | "type": " Fire" 565 | }, 566 | { 567 | "id": " 220", 568 | "typeTwo": " Ground", 569 | "name": " Swinub", 570 | "type": " Ice" 571 | }, 572 | { 573 | "id": " 221", 574 | "typeTwo": " Ground", 575 | "name": " Piloswine", 576 | "type": " Ice" 577 | }, 578 | { 579 | "id": " 222", 580 | "typeTwo": " Rock", 581 | "name": " Corsola", 582 | "type": " Water" 583 | }, 584 | { 585 | "id": " 225", 586 | "typeTwo": " Flying", 587 | "name": " Delibird", 588 | "type": " Ice" 589 | }, 590 | { 591 | "id": " 226", 592 | "typeTwo": " Flying", 593 | "name": " Mantine", 594 | "type": " Water" 595 | }, 596 | { 597 | "id": " 227", 598 | "typeTwo": " Flying", 599 | "name": " Skarmory", 600 | "type": " Steel" 601 | }, 602 | { 603 | "id": " 228", 604 | "typeTwo": " Fire", 605 | "name": " Houndour", 606 | "type": " Dark" 607 | }, 608 | { 609 | "id": " 229", 610 | "typeTwo": " Fire", 611 | "name": " Houndoom", 612 | "type": " Dark" 613 | }, 614 | { 615 | "id": " 230", 616 | "typeTwo": " Dragon", 617 | "name": " Kingdra", 618 | "type": " Water" 619 | }, 620 | { 621 | "id": " 238", 622 | "typeTwo": " Psychic", 623 | "name": " Smoochum", 624 | "type": " Ice" 625 | }, 626 | { 627 | "id": " 246", 628 | "typeTwo": " Ground", 629 | "name": " Larvitar", 630 | "type": " Rock" 631 | }, 632 | { 633 | "id": " 247", 634 | "typeTwo": " Ground", 635 | "name": " Pupitar", 636 | "type": " Rock" 637 | }, 638 | { 639 | "id": " 248", 640 | "typeTwo": " Dark", 641 | "name": " Tyranitar", 642 | "type": " Rock" 643 | }, 644 | { 645 | "id": " 249", 646 | "typeTwo": " Flying", 647 | "name": " Lugia", 648 | "type": " Psychic" 649 | }, 650 | { 651 | "id": " 250", 652 | "typeTwo": " Flying", 653 | "name": " Ho-Oh", 654 | "type": " Fire" 655 | }, 656 | { 657 | "id": " 251", 658 | "typeTwo": " Grass", 659 | "name": " Celebi", 660 | "type": " Psychic" 661 | }, 662 | { 663 | "id": " 256", 664 | "typeTwo": " Fighting", 665 | "name": " Combusken", 666 | "type": " Fire" 667 | }, 668 | { 669 | "id": " 257", 670 | "typeTwo": " Fighting", 671 | "name": " Blaziken", 672 | "type": " Fire" 673 | }, 674 | { 675 | "id": " 259", 676 | "typeTwo": " Ground", 677 | "name": " Marshtomp", 678 | "type": " Water" 679 | }, 680 | { 681 | "id": " 260", 682 | "typeTwo": " Ground", 683 | "name": " Swampert", 684 | "type": " Water" 685 | }, 686 | { 687 | "id": " 267", 688 | "typeTwo": " Flying", 689 | "name": " Beautifly", 690 | "type": " Bug" 691 | }, 692 | { 693 | "id": " 269", 694 | "typeTwo": " Poison", 695 | "name": " Dustox", 696 | "type": " Bug" 697 | }, 698 | { 699 | "id": " 270", 700 | "typeTwo": " Grass", 701 | "name": " Lotad", 702 | "type": " Water" 703 | }, 704 | { 705 | "id": " 271", 706 | "typeTwo": " Grass", 707 | "name": " Lombre", 708 | "type": " Water" 709 | }, 710 | { 711 | "id": " 272", 712 | "typeTwo": " Grass", 713 | "name": " Ludicolo", 714 | "type": " Water" 715 | }, 716 | { 717 | "id": " 274", 718 | "typeTwo": " Dark", 719 | "name": " Nuzleaf", 720 | "type": " Grass" 721 | }, 722 | { 723 | "id": " 275", 724 | "typeTwo": " Dark", 725 | "name": " Shiftry", 726 | "type": " Grass" 727 | }, 728 | { 729 | "id": " 276", 730 | "typeTwo": " Flying", 731 | "name": " Taillow", 732 | "type": " Normal" 733 | }, 734 | { 735 | "id": " 277", 736 | "typeTwo": " Flying", 737 | "name": " Swellow", 738 | "type": " Normal" 739 | }, 740 | { 741 | "id": " 278", 742 | "typeTwo": " Flying", 743 | "name": " Wingull", 744 | "type": " Water" 745 | }, 746 | { 747 | "id": " 279", 748 | "typeTwo": " Flying", 749 | "name": " Pelipper", 750 | "type": " Water" 751 | }, 752 | { 753 | "id": " 283", 754 | "typeTwo": " Water", 755 | "name": " Surskit", 756 | "type": " Bug" 757 | }, 758 | { 759 | "id": " 284", 760 | "typeTwo": " Flying", 761 | "name": " Masquerain", 762 | "type": " Bug" 763 | }, 764 | { 765 | "id": " 286", 766 | "typeTwo": " Fighting", 767 | "name": " Breloom", 768 | "type": " Grass" 769 | }, 770 | { 771 | "id": " 290", 772 | "typeTwo": " Ground", 773 | "name": " Nincada", 774 | "type": " Bug" 775 | }, 776 | { 777 | "id": " 291", 778 | "typeTwo": " Flying", 779 | "name": " Ninjask", 780 | "type": " Bug" 781 | }, 782 | { 783 | "id": " 292", 784 | "typeTwo": " Ghost", 785 | "name": " Shedinja", 786 | "type": " Bug" 787 | }, 788 | { 789 | "id": " 302", 790 | "typeTwo": " Ghost", 791 | "name": " Sableye", 792 | "type": " Dark" 793 | }, 794 | { 795 | "id": " 304", 796 | "typeTwo": " Rock", 797 | "name": " Aron", 798 | "type": " Steel" 799 | }, 800 | { 801 | "id": " 305", 802 | "typeTwo": " Rock", 803 | "name": " Lairon", 804 | "type": " Steel" 805 | }, 806 | { 807 | "id": " 306", 808 | "typeTwo": " Rock", 809 | "name": " Aggron", 810 | "type": " Steel" 811 | }, 812 | { 813 | "id": " 307", 814 | "typeTwo": " Psychic", 815 | "name": " Meditite", 816 | "type": " Fighting" 817 | }, 818 | { 819 | "id": " 308", 820 | "typeTwo": " Psychic", 821 | "name": " Medicham", 822 | "type": " Fighting" 823 | }, 824 | { 825 | "id": " 315", 826 | "typeTwo": " Poison", 827 | "name": " Roselia", 828 | "type": " Grass" 829 | }, 830 | { 831 | "id": " 318", 832 | "typeTwo": " Dark", 833 | "name": " Carvanha", 834 | "type": " Water" 835 | }, 836 | { 837 | "id": " 319", 838 | "typeTwo": " Dark", 839 | "name": " Sharpedo", 840 | "type": " Water" 841 | }, 842 | { 843 | "id": " 322", 844 | "typeTwo": " Ground", 845 | "name": " Numel", 846 | "type": " Fire" 847 | }, 848 | { 849 | "id": " 323", 850 | "typeTwo": " Ground", 851 | "name": " Camerupt", 852 | "type": " Fire" 853 | }, 854 | { 855 | "id": " 329", 856 | "typeTwo": " Dragon", 857 | "name": " Vibrava", 858 | "type": " Ground" 859 | }, 860 | { 861 | "id": " 330", 862 | "typeTwo": " Dragon", 863 | "name": " Flygon", 864 | "type": " Ground" 865 | }, 866 | { 867 | "id": " 332", 868 | "typeTwo": " Dark", 869 | "name": " Cacturne", 870 | "type": " Grass" 871 | }, 872 | { 873 | "id": " 333", 874 | "typeTwo": " Flying", 875 | "name": " Swablu", 876 | "type": " Normal" 877 | }, 878 | { 879 | "id": " 334", 880 | "typeTwo": " Flying", 881 | "name": " Altaria", 882 | "type": " Dragon" 883 | }, 884 | { 885 | "id": " 337", 886 | "typeTwo": " Psychic", 887 | "name": " Lunatone", 888 | "type": " Rock" 889 | }, 890 | { 891 | "id": " 338", 892 | "typeTwo": " Psychic", 893 | "name": " Solrock", 894 | "type": " Rock" 895 | }, 896 | { 897 | "id": " 339", 898 | "typeTwo": " Ground", 899 | "name": " Barboach", 900 | "type": " Water" 901 | }, 902 | { 903 | "id": " 340", 904 | "typeTwo": " Ground", 905 | "name": " Whiscash", 906 | "type": " Water" 907 | }, 908 | { 909 | "id": " 342", 910 | "typeTwo": " Dark", 911 | "name": " Crawdaunt", 912 | "type": " Water" 913 | }, 914 | { 915 | "id": " 343", 916 | "typeTwo": " Psychic", 917 | "name": " Baltoy", 918 | "type": " Ground" 919 | }, 920 | { 921 | "id": " 344", 922 | "typeTwo": " Psychic", 923 | "name": " Claydol", 924 | "type": " Ground" 925 | }, 926 | { 927 | "id": " 345", 928 | "typeTwo": " Grass", 929 | "name": " Lileep", 930 | "type": " Rock" 931 | }, 932 | { 933 | "id": " 346", 934 | "typeTwo": " Grass", 935 | "name": " Cradily", 936 | "type": " Rock" 937 | }, 938 | { 939 | "id": " 347", 940 | "typeTwo": " Bug", 941 | "name": " Anorith", 942 | "type": " Rock" 943 | }, 944 | { 945 | "id": " 348", 946 | "typeTwo": " Bug", 947 | "name": " Armaldo", 948 | "type": " Rock" 949 | }, 950 | { 951 | "id": " 357", 952 | "typeTwo": " Flying", 953 | "name": " Tropius", 954 | "type": " Grass" 955 | }, 956 | { 957 | "id": " 363", 958 | "typeTwo": " Water", 959 | "name": " Spheal", 960 | "type": " Ice" 961 | }, 962 | { 963 | "id": " 364", 964 | "typeTwo": " Water", 965 | "name": " Sealeo", 966 | "type": " Ice" 967 | }, 968 | { 969 | "id": " 365", 970 | "typeTwo": " Water", 971 | "name": " Walrein", 972 | "type": " Ice" 973 | }, 974 | { 975 | "id": " 369", 976 | "typeTwo": " Rock", 977 | "name": " Relicanth", 978 | "type": " Water" 979 | }, 980 | { 981 | "id": " 373", 982 | "typeTwo": " Flying", 983 | "name": " Salamence", 984 | "type": " Dragon" 985 | }, 986 | { 987 | "id": " 374", 988 | "typeTwo": " Psychic", 989 | "name": " Beldum", 990 | "type": " Steel" 991 | }, 992 | { 993 | "id": " 375", 994 | "typeTwo": " Psychic", 995 | "name": " Metang", 996 | "type": " Steel" 997 | }, 998 | { 999 | "id": " 376", 1000 | "typeTwo": " Psychic", 1001 | "name": " Metagross", 1002 | "type": " Steel" 1003 | }, 1004 | { 1005 | "id": " 380", 1006 | "typeTwo": " Psychic", 1007 | "name": " Latias", 1008 | "type": " Dragon" 1009 | }, 1010 | { 1011 | "id": " 381", 1012 | "typeTwo": " Psychic", 1013 | "name": " Latios", 1014 | "type": " Dragon" 1015 | }, 1016 | { 1017 | "id": " 384", 1018 | "typeTwo": " Flying", 1019 | "name": " Rayquaza", 1020 | "type": " Dragon" 1021 | }, 1022 | { 1023 | "id": " 385", 1024 | "typeTwo": " Psychic", 1025 | "name": " Jirachi", 1026 | "type": " Steel" 1027 | }, 1028 | { 1029 | "id": " 389", 1030 | "typeTwo": " Ground", 1031 | "name": " Torterra", 1032 | "type": " Grass" 1033 | }, 1034 | { 1035 | "id": " 391", 1036 | "typeTwo": " Fighting", 1037 | "name": " Monferno", 1038 | "type": " Fire" 1039 | }, 1040 | { 1041 | "id": " 392", 1042 | "typeTwo": " Fighting", 1043 | "name": " Infernape", 1044 | "type": " Fire" 1045 | }, 1046 | { 1047 | "id": " 395", 1048 | "typeTwo": " Steel", 1049 | "name": " Empoleon", 1050 | "type": " Water" 1051 | }, 1052 | { 1053 | "id": " 396", 1054 | "typeTwo": " Flying", 1055 | "name": " Starly", 1056 | "type": " Normal" 1057 | }, 1058 | { 1059 | "id": " 397", 1060 | "typeTwo": " Flying", 1061 | "name": " Staravia", 1062 | "type": " Normal" 1063 | }, 1064 | { 1065 | "id": " 398", 1066 | "typeTwo": " Flying", 1067 | "name": " Staraptor", 1068 | "type": " Normal" 1069 | }, 1070 | { 1071 | "id": " 400", 1072 | "typeTwo": " Water", 1073 | "name": " Bibarel", 1074 | "type": " Normal" 1075 | }, 1076 | { 1077 | "id": " 406", 1078 | "typeTwo": " Poison", 1079 | "name": " Budew", 1080 | "type": " Grass" 1081 | }, 1082 | { 1083 | "id": " 407", 1084 | "typeTwo": " Poison", 1085 | "name": " Roserade", 1086 | "type": " Grass" 1087 | }, 1088 | { 1089 | "id": " 410", 1090 | "typeTwo": " Steel", 1091 | "name": " Shieldon", 1092 | "type": " Rock" 1093 | }, 1094 | { 1095 | "id": " 411", 1096 | "typeTwo": " Steel", 1097 | "name": " Bastiodon", 1098 | "type": " Rock" 1099 | }, 1100 | { 1101 | "id": " 413", 1102 | "typeTwo": " Steel", 1103 | "name": " Wormadam", 1104 | "type": " Bug" 1105 | }, 1106 | { 1107 | "id": " 414", 1108 | "typeTwo": " Flying", 1109 | "name": " Mothim", 1110 | "type": " Bug" 1111 | }, 1112 | { 1113 | "id": " 415", 1114 | "typeTwo": " Flying", 1115 | "name": " Combee", 1116 | "type": " Bug" 1117 | }, 1118 | { 1119 | "id": " 416", 1120 | "typeTwo": " Flying", 1121 | "name": " Vespiquen", 1122 | "type": " Bug" 1123 | }, 1124 | { 1125 | "id": " 423", 1126 | "typeTwo": " Ground", 1127 | "name": " Gastrodon", 1128 | "type": " Water" 1129 | }, 1130 | { 1131 | "id": " 425", 1132 | "typeTwo": " Flying", 1133 | "name": " Drifloon", 1134 | "type": " Ghost" 1135 | }, 1136 | { 1137 | "id": " 426", 1138 | "typeTwo": " Flying", 1139 | "name": " Drifblim", 1140 | "type": " Ghost" 1141 | }, 1142 | { 1143 | "id": " 430", 1144 | "typeTwo": " Flying", 1145 | "name": " Honchkrow", 1146 | "type": " Dark" 1147 | }, 1148 | { 1149 | "id": " 434", 1150 | "typeTwo": " Dark", 1151 | "name": " Stunky", 1152 | "type": " Poison" 1153 | }, 1154 | { 1155 | "id": " 435", 1156 | "typeTwo": " Dark", 1157 | "name": " Skuntank", 1158 | "type": " Poison" 1159 | }, 1160 | { 1161 | "id": " 436", 1162 | "typeTwo": " Psychic", 1163 | "name": " Bronzor", 1164 | "type": " Steel" 1165 | }, 1166 | { 1167 | "id": " 437", 1168 | "typeTwo": " Psychic", 1169 | "name": " Bronzong", 1170 | "type": " Steel" 1171 | }, 1172 | { 1173 | "id": " 441", 1174 | "typeTwo": " Flying", 1175 | "name": " Chatot", 1176 | "type": " Normal" 1177 | }, 1178 | { 1179 | "id": " 442", 1180 | "typeTwo": " Dark", 1181 | "name": " Spiritomb", 1182 | "type": " Ghost" 1183 | }, 1184 | { 1185 | "id": " 443", 1186 | "typeTwo": " Ground", 1187 | "name": " Gible", 1188 | "type": " Dragon" 1189 | }, 1190 | { 1191 | "id": " 444", 1192 | "typeTwo": " Ground", 1193 | "name": " Gabite", 1194 | "type": " Dragon" 1195 | }, 1196 | { 1197 | "id": " 445", 1198 | "typeTwo": " Ground", 1199 | "name": " Garchomp", 1200 | "type": " Dragon" 1201 | }, 1202 | { 1203 | "id": " 448", 1204 | "typeTwo": " Steel", 1205 | "name": " Lucario", 1206 | "type": " Fighting" 1207 | }, 1208 | { 1209 | "id": " 451", 1210 | "typeTwo": " Bug", 1211 | "name": " Skorupi", 1212 | "type": " Poison" 1213 | }, 1214 | { 1215 | "id": " 452", 1216 | "typeTwo": " Dark", 1217 | "name": " Drapion", 1218 | "type": " Poison" 1219 | }, 1220 | { 1221 | "id": " 453", 1222 | "typeTwo": " Fighting", 1223 | "name": " Croagunk", 1224 | "type": " Poison" 1225 | }, 1226 | { 1227 | "id": " 454", 1228 | "typeTwo": " Fighting", 1229 | "name": " Toxicroak", 1230 | "type": " Poison" 1231 | }, 1232 | { 1233 | "id": " 458", 1234 | "typeTwo": " Flying", 1235 | "name": " Mantyke", 1236 | "type": " Water" 1237 | }, 1238 | { 1239 | "id": " 459", 1240 | "typeTwo": " Ice", 1241 | "name": " Snover", 1242 | "type": " Grass" 1243 | }, 1244 | { 1245 | "id": " 460", 1246 | "typeTwo": " Ice", 1247 | "name": " Abomasnow", 1248 | "type": " Grass" 1249 | }, 1250 | { 1251 | "id": " 461", 1252 | "typeTwo": " Ice", 1253 | "name": " Weavile", 1254 | "type": " Dark" 1255 | }, 1256 | { 1257 | "id": " 462", 1258 | "typeTwo": " Steel", 1259 | "name": " Magnezone", 1260 | "type": " Electric" 1261 | }, 1262 | { 1263 | "id": " 464", 1264 | "typeTwo": " Rock", 1265 | "name": " Rhyperior", 1266 | "type": " Ground" 1267 | }, 1268 | { 1269 | "id": " 468", 1270 | "typeTwo": " Flying", 1271 | "name": " Togekiss", 1272 | "type": " Normal" 1273 | }, 1274 | { 1275 | "id": " 469", 1276 | "typeTwo": " Flying", 1277 | "name": " Yanmega", 1278 | "type": " Bug" 1279 | }, 1280 | { 1281 | "id": " 472", 1282 | "typeTwo": " Flying", 1283 | "name": " Gliscor", 1284 | "type": " Ground" 1285 | }, 1286 | { 1287 | "id": " 473", 1288 | "typeTwo": " Ground", 1289 | "name": " Mamoswine", 1290 | "type": " Ice" 1291 | }, 1292 | { 1293 | "id": " 475", 1294 | "typeTwo": " Fighting", 1295 | "name": " Gallade", 1296 | "type": " Psychic" 1297 | }, 1298 | { 1299 | "id": " 476", 1300 | "typeTwo": " Steel", 1301 | "name": " Probopass", 1302 | "type": " Rock" 1303 | }, 1304 | { 1305 | "id": " 478", 1306 | "typeTwo": " Ghost", 1307 | "name": " Froslass", 1308 | "type": " Ice" 1309 | }, 1310 | { 1311 | "id": " 479", 1312 | "typeTwo": " Grass", 1313 | "name": " Rotom", 1314 | "type": " Electric" 1315 | }, 1316 | { 1317 | "id": " 483", 1318 | "typeTwo": " Dragon", 1319 | "name": " Dialga", 1320 | "type": " Steel" 1321 | }, 1322 | { 1323 | "id": " 484", 1324 | "typeTwo": " Dragon", 1325 | "name": " Palkia", 1326 | "type": " Water" 1327 | }, 1328 | { 1329 | "id": " 485", 1330 | "typeTwo": " Steel", 1331 | "name": " Heatran", 1332 | "type": " Fire" 1333 | }, 1334 | { 1335 | "id": " 487", 1336 | "typeTwo": " Dragon", 1337 | "name": " Giratina", 1338 | "type": " Ghost" 1339 | }, 1340 | { 1341 | "id": " 492", 1342 | "typeTwo": " Flying", 1343 | "name": " Shaymin", 1344 | "type": " Grass" 1345 | }, 1346 | { 1347 | "id": " 494", 1348 | "typeTwo": " Fire", 1349 | "name": " Victini", 1350 | "type": " Psychic" 1351 | }, 1352 | { 1353 | "id": " 499", 1354 | "typeTwo": " Fighting", 1355 | "name": " Pignite", 1356 | "type": " Fire" 1357 | }, 1358 | { 1359 | "id": " 500", 1360 | "typeTwo": " Fighting", 1361 | "name": " Emboar", 1362 | "type": " Fire" 1363 | }, 1364 | { 1365 | "id": " 519", 1366 | "typeTwo": " Flying", 1367 | "name": " Pidove", 1368 | "type": " Normal" 1369 | }, 1370 | { 1371 | "id": " 520", 1372 | "typeTwo": " Flying", 1373 | "name": " Tranquill", 1374 | "type": " Normal" 1375 | }, 1376 | { 1377 | "id": " 521", 1378 | "typeTwo": " Flying", 1379 | "name": " Unfezant", 1380 | "type": " Normal" 1381 | }, 1382 | { 1383 | "id": " 527", 1384 | "typeTwo": " Flying", 1385 | "name": " Woobat", 1386 | "type": " Psychic" 1387 | }, 1388 | { 1389 | "id": " 528", 1390 | "typeTwo": " Flying", 1391 | "name": " Swoobat", 1392 | "type": " Psychic" 1393 | }, 1394 | { 1395 | "id": " 530", 1396 | "typeTwo": " Steel", 1397 | "name": " Excadrill", 1398 | "type": " Ground" 1399 | }, 1400 | { 1401 | "id": " 536", 1402 | "typeTwo": " Ground", 1403 | "name": " Palpitoad", 1404 | "type": " Water" 1405 | }, 1406 | { 1407 | "id": " 537", 1408 | "typeTwo": " Ground", 1409 | "name": " Seismitoad", 1410 | "type": " Water" 1411 | }, 1412 | { 1413 | "id": " 540", 1414 | "typeTwo": " Grass", 1415 | "name": " Sewaddle", 1416 | "type": " Bug" 1417 | }, 1418 | { 1419 | "id": " 541", 1420 | "typeTwo": " Grass", 1421 | "name": " Swadloon", 1422 | "type": " Bug" 1423 | }, 1424 | { 1425 | "id": " 542", 1426 | "typeTwo": " Grass", 1427 | "name": " Leavanny", 1428 | "type": " Bug" 1429 | }, 1430 | { 1431 | "id": " 543", 1432 | "typeTwo": " Poison", 1433 | "name": " Venipede", 1434 | "type": " Bug" 1435 | }, 1436 | { 1437 | "id": " 544", 1438 | "typeTwo": " Poison", 1439 | "name": " Whirlipede", 1440 | "type": " Bug" 1441 | }, 1442 | { 1443 | "id": " 545", 1444 | "typeTwo": " Poison", 1445 | "name": " Scolipede", 1446 | "type": " Bug" 1447 | }, 1448 | { 1449 | "id": " 551", 1450 | "typeTwo": " Dark", 1451 | "name": " Sandile", 1452 | "type": " Ground" 1453 | }, 1454 | { 1455 | "id": " 552", 1456 | "typeTwo": " Dark", 1457 | "name": " Krokorok", 1458 | "type": " Ground" 1459 | }, 1460 | { 1461 | "id": " 553", 1462 | "typeTwo": " Dark", 1463 | "name": " Krookodile", 1464 | "type": " Ground" 1465 | }, 1466 | { 1467 | "id": " 555", 1468 | "typeTwo": " Psychic", 1469 | "name": " Darmanitan", 1470 | "type": " Fire" 1471 | }, 1472 | { 1473 | "id": " 557", 1474 | "typeTwo": " Rock", 1475 | "name": " Dwebble", 1476 | "type": " Bug" 1477 | }, 1478 | { 1479 | "id": " 558", 1480 | "typeTwo": " Rock", 1481 | "name": " Crustle", 1482 | "type": " Bug" 1483 | }, 1484 | { 1485 | "id": " 559", 1486 | "typeTwo": " Fighting", 1487 | "name": " Scraggy", 1488 | "type": " Dark" 1489 | }, 1490 | { 1491 | "id": " 560", 1492 | "typeTwo": " Fighting", 1493 | "name": " Scrafty", 1494 | "type": " Dark" 1495 | }, 1496 | { 1497 | "id": " 561", 1498 | "typeTwo": " Flying", 1499 | "name": " Sigilyph", 1500 | "type": " Psychic" 1501 | }, 1502 | { 1503 | "id": " 564", 1504 | "typeTwo": " Rock", 1505 | "name": " Tirtouga", 1506 | "type": " Water" 1507 | }, 1508 | { 1509 | "id": " 565", 1510 | "typeTwo": " Rock", 1511 | "name": " Carracosta", 1512 | "type": " Water" 1513 | }, 1514 | { 1515 | "id": " 566", 1516 | "typeTwo": " Flying", 1517 | "name": " Archen", 1518 | "type": " Rock" 1519 | }, 1520 | { 1521 | "id": " 567", 1522 | "typeTwo": " Flying", 1523 | "name": " Archeops", 1524 | "type": " Rock" 1525 | }, 1526 | { 1527 | "id": " 580", 1528 | "typeTwo": " Flying", 1529 | "name": " Ducklett", 1530 | "type": " Water" 1531 | }, 1532 | { 1533 | "id": " 581", 1534 | "typeTwo": " Flying", 1535 | "name": " Swanna", 1536 | "type": " Water" 1537 | }, 1538 | { 1539 | "id": " 585", 1540 | "typeTwo": " Grass", 1541 | "name": " Deerling", 1542 | "type": " Normal" 1543 | }, 1544 | { 1545 | "id": " 586", 1546 | "typeTwo": " Grass", 1547 | "name": " Sawsbuck", 1548 | "type": " Normal" 1549 | }, 1550 | { 1551 | "id": " 587", 1552 | "typeTwo": " Flying", 1553 | "name": " Emolga", 1554 | "type": " Electric" 1555 | }, 1556 | { 1557 | "id": " 589", 1558 | "typeTwo": " Steel", 1559 | "name": " Escavalier", 1560 | "type": " Bug" 1561 | }, 1562 | { 1563 | "id": " 590", 1564 | "typeTwo": " Poison", 1565 | "name": " Foongus", 1566 | "type": " Grass" 1567 | }, 1568 | { 1569 | "id": " 591", 1570 | "typeTwo": " Poison", 1571 | "name": " Amoonguss", 1572 | "type": " Grass" 1573 | }, 1574 | { 1575 | "id": " 592", 1576 | "typeTwo": " Ghost", 1577 | "name": " Frillish", 1578 | "type": " Water" 1579 | }, 1580 | { 1581 | "id": " 593", 1582 | "typeTwo": " Ghost", 1583 | "name": " Jellicent", 1584 | "type": " Water" 1585 | }, 1586 | { 1587 | "id": " 595", 1588 | "typeTwo": " Electric", 1589 | "name": " Joltik", 1590 | "type": " Bug" 1591 | }, 1592 | { 1593 | "id": " 596", 1594 | "typeTwo": " Electric", 1595 | "name": " Galvantula", 1596 | "type": " Bug" 1597 | }, 1598 | { 1599 | "id": " 597", 1600 | "typeTwo": " Steel", 1601 | "name": " Ferroseed", 1602 | "type": " Grass" 1603 | }, 1604 | { 1605 | "id": " 598", 1606 | "typeTwo": " Steel", 1607 | "name": " Ferrothorn", 1608 | "type": " Grass" 1609 | }, 1610 | { 1611 | "id": " 607", 1612 | "typeTwo": " Fire", 1613 | "name": " Litwick", 1614 | "type": " Ghost" 1615 | }, 1616 | { 1617 | "id": " 608", 1618 | "typeTwo": " Fire", 1619 | "name": " Lampent", 1620 | "type": " Ghost" 1621 | }, 1622 | { 1623 | "id": " 609", 1624 | "typeTwo": " Fire", 1625 | "name": " Chandelure", 1626 | "type": " Ghost" 1627 | }, 1628 | { 1629 | "id": " 618", 1630 | "typeTwo": " Electric", 1631 | "name": " Stunfisk", 1632 | "type": " Ground" 1633 | }, 1634 | { 1635 | "id": " 622", 1636 | "typeTwo": " Ghost", 1637 | "name": " Golett", 1638 | "type": " Ground" 1639 | }, 1640 | { 1641 | "id": " 623", 1642 | "typeTwo": " Ghost", 1643 | "name": " Golurk", 1644 | "type": " Ground" 1645 | }, 1646 | { 1647 | "id": " 624", 1648 | "typeTwo": " Steel", 1649 | "name": " Pawniard", 1650 | "type": " Dark" 1651 | }, 1652 | { 1653 | "id": " 625", 1654 | "typeTwo": " Steel", 1655 | "name": " Bisharp", 1656 | "type": " Dark" 1657 | }, 1658 | { 1659 | "id": " 627", 1660 | "typeTwo": " Flying", 1661 | "name": " Rufflet", 1662 | "type": " Normal" 1663 | }, 1664 | { 1665 | "id": " 628", 1666 | "typeTwo": " Flying", 1667 | "name": " Braviary", 1668 | "type": " Normal" 1669 | }, 1670 | { 1671 | "id": " 629", 1672 | "typeTwo": " Flying", 1673 | "name": " Vullaby", 1674 | "type": " Dark" 1675 | }, 1676 | { 1677 | "id": " 630", 1678 | "typeTwo": " Flying", 1679 | "name": " Mandibuzz", 1680 | "type": " Dark" 1681 | }, 1682 | { 1683 | "id": " 632", 1684 | "typeTwo": " Steel", 1685 | "name": " Durant", 1686 | "type": " Bug" 1687 | }, 1688 | { 1689 | "id": " 633", 1690 | "typeTwo": " Dragon", 1691 | "name": " Deino", 1692 | "type": " Dark" 1693 | }, 1694 | { 1695 | "id": " 634", 1696 | "typeTwo": " Dragon", 1697 | "name": " Zweilous", 1698 | "type": " Dark" 1699 | }, 1700 | { 1701 | "id": " 635", 1702 | "typeTwo": " Dragon", 1703 | "name": " Hydreigon", 1704 | "type": " Dark" 1705 | }, 1706 | { 1707 | "id": " 636", 1708 | "typeTwo": " Fire", 1709 | "name": " Larvesta", 1710 | "type": " Bug" 1711 | }, 1712 | { 1713 | "id": " 637", 1714 | "typeTwo": " Fire", 1715 | "name": " Volcarona", 1716 | "type": " Bug" 1717 | }, 1718 | { 1719 | "id": " 638", 1720 | "typeTwo": " Fighting", 1721 | "name": " Cobalion", 1722 | "type": " Steel" 1723 | }, 1724 | { 1725 | "id": " 639", 1726 | "typeTwo": " Fighting", 1727 | "name": " Terrakion", 1728 | "type": " Rock" 1729 | }, 1730 | { 1731 | "id": " 640", 1732 | "typeTwo": " Fighting", 1733 | "name": " Virizion", 1734 | "type": " Grass" 1735 | }, 1736 | { 1737 | "id": " 642", 1738 | "typeTwo": " Flying", 1739 | "name": " Thundurus", 1740 | "type": " Electric" 1741 | }, 1742 | { 1743 | "id": " 643", 1744 | "typeTwo": " Fire", 1745 | "name": " Reshiram", 1746 | "type": " Dragon" 1747 | }, 1748 | { 1749 | "id": " 644", 1750 | "typeTwo": " Electric", 1751 | "name": " Zekrom ", 1752 | "type": " Dragon" 1753 | }, 1754 | { 1755 | "id": " 645", 1756 | "typeTwo": " Flying", 1757 | "name": " Landorus", 1758 | "type": " Ground" 1759 | }, 1760 | { 1761 | "id": " 646", 1762 | "typeTwo": " Ice", 1763 | "name": " Kyurem", 1764 | "type": " Dragon" 1765 | }, 1766 | { 1767 | "id": " 647", 1768 | "typeTwo": " Fighting", 1769 | "name": " Keldeo", 1770 | "type": " Water" 1771 | }, 1772 | { 1773 | "id": " 648", 1774 | "typeTwo": " Fighting", 1775 | "name": " Meloetta", 1776 | "type": " Normal" 1777 | }, 1778 | { 1779 | "id": " 649", 1780 | "typeTwo": " Steel", 1781 | "name": " Genesect", 1782 | "type": " Bug" 1783 | } 1784 | ] 1785 | -------------------------------------------------------------------------------- /Chapter3/pokemonByType.csv: -------------------------------------------------------------------------------- 1 | type,amount 2 | Bug,45 3 | Dark,16 4 | Dragon,12 5 | Electric,7 6 | Fighting,3 7 | Fire,14 8 | Ghost,10 9 | Grass,31 10 | Ground,17 11 | Ice,11 12 | Normal,29 13 | Poison,11 14 | Psychic,9 15 | Rock,24 16 | Steel,13 17 | Water,45 18 | -------------------------------------------------------------------------------- /Chapter3/pokemonByType.tsv: -------------------------------------------------------------------------------- 1 | type amount 2 | Dark 16 3 | Bug 45 4 | Dragon 12 5 | Electric 7 6 | Fighting 3 7 | Fire 14 8 | Ghost 10 9 | Grass 31 10 | Ground 17 11 | Ice 11 12 | Normal 29 13 | Poison 11 14 | Psychic 9 15 | Rock 24 16 | Steel 13 17 | Water 45 18 | -------------------------------------------------------------------------------- /Chapter4/NaiveBayes.py: -------------------------------------------------------------------------------- 1 | import csv 2 | 3 | def list_words(text): 4 | words = [] 5 | words_tmp = text.lower().split() 6 | for p in words_tmp: 7 | if p not in words and len(p) > 2: 8 | words.append(p) 9 | 10 | return words 11 | 12 | def training(texts): 13 | c_words ={} 14 | c_categories ={} 15 | c_texts = 0 16 | c_tot_words =0 17 | 18 | 19 | for t in texts: 20 | c_texts = c_texts + 1 21 | if t[1] not in c_categories: 22 | c_categories[t[1]] = 1 23 | else: 24 | c_categories[t[1]]= c_categories[t[1]] + 1 25 | 26 | 27 | 28 | for t in texts: 29 | words = list_words(t[0]) 30 | 31 | for p in words: 32 | if p not in c_words: 33 | c_tot_words = c_tot_words +1 34 | c_words[p] = {} 35 | for c in c_categories: 36 | c_words[p][c] = 0 37 | c_words[p][t[1]] = c_words[p][t[1]] + 1 38 | 39 | return (c_words, c_categories, c_texts, c_tot_words) 40 | 41 | 42 | def classifier(subject_line, c_words, c_categories, c_texts, c_tot_words): 43 | category ="" 44 | category_prob = 0 45 | 46 | for c in c_categories: 47 | 48 | prob_c = float(c_categories[c])/float(c_texts) 49 | words = list_words(subject_line) 50 | prob_total_c = prob_c 51 | for p in words: 52 | 53 | if p in c_words: 54 | prob_p= float(c_words[p][c])/float(c_tot_words) 55 | prob_cond = prob_p/prob_c 56 | prob =(prob_cond * prob_p)/ prob_c 57 | prob_total_c = prob_total_c * prob 58 | 59 | if category_prob < prob_total_c: 60 | category = c 61 | category_prob = prob_total_c 62 | return (category, category_prob) 63 | 64 | 65 | if __name__ == "__main__": 66 | 67 | with open('training.csv') as f: 68 | subjects = dict(csv.reader(f, delimiter=',')) 69 | p,c,t,tp = training(subjects.items()) 70 | 71 | #First Test 72 | clase = classifier("Available on Term Life - Free",p,c,t,tp) 73 | print("Result: {0} ".format(clase)) 74 | 75 | 76 | #Second Test 77 | with open("test.csv") as f: 78 | correct = 0 79 | tests = csv.reader(f) 80 | for subject in tests: 81 | clase = classifier(subject[0],p,c,t,tp) 82 | if clase[0] == subject[1]: 83 | correct += 1 84 | print("Efficiency {0} of 10".format(correct)) 85 | 86 | -------------------------------------------------------------------------------- /Chapter4/SubjectsExtraction.py: -------------------------------------------------------------------------------- 1 | import os 2 | import numpy as np 3 | #files = os.listdir(r"C:\spam") 4 | files = os.listdir(r"C:\easy_ham") 5 | 6 | with open("dataSpam.out","w") as out: 7 | 8 | n = 0 9 | for fname in files: 10 | with open("C:\\easy_ham\\" + fname) as f: 11 | 12 | data = f.readlines() 13 | 14 | for line in data: 15 | if line.startswith("Subject:"): 16 | print(line) 17 | n +=1 18 | print(n) 19 | out.write("{0}, nospam \n".format(line[8:-1])) 20 | print(fname) 21 | -------------------------------------------------------------------------------- /Chapter4/dataSpam.out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hmcuesta/PDA_Book/52acc58b5a737d974990f9ec6d938013a240a64a/Chapter4/dataSpam.out -------------------------------------------------------------------------------- /Chapter4/test.csv: -------------------------------------------------------------------------------- 1 | Interesting article on free software licences,nospam 2 | Some Friends Indeed Do More Harm Than Good,nospam 3 | Meetings the Hottest Place to Meet Women With Big Bucks,nospam 4 | Watchin Espn..Jus seen this new Nike Commerical with a Puppet Lebron,nospam 5 | FREE Cell Phone + $50 Cash Back,spam 6 | Reports You Need To Make Cash,spam 7 | Lowest Rates Available on Term Life - Free Quote,spam 8 | Interest Rates at Forty Yr. Lows, spam 9 | Cd Package: 300 Million Email Addresses + 1.5 Mil Fax Numbers $99.95,spam 10 | Get $100 Free - Beat the House at Royal Vegas,spam -------------------------------------------------------------------------------- /Chapter4/training.csv: -------------------------------------------------------------------------------- 1 | Interesting article on free software licences,nospam 2 | Some Friends Indeed Do More Harm Than Good,nospam 3 | Meetings the Hottest Place to Meet Women With Big Bucks,nospam 4 | Watchin Espn..Jus seen this new Nike Commerical with a Puppet Lebron,nospam 5 | FREE Cell Phone + $50 Cash Back,spam 6 | Reports You Need To Make Cash,spam 7 | Lowest Rates Available on Term Life - Free Quote,spam 8 | Interest Rates at Forty Yr. Lows, spam 9 | Cd Package: 300 Million Email Addresses + 1.5 Mil Fax Numbers $99.95,spam 10 | Get $100 Free - Beat the House at Royal Vegas,spam -------------------------------------------------------------------------------- /Chapter5/DTW_Implementation.py: -------------------------------------------------------------------------------- 1 | from PIL import Image 2 | from numpy import array 3 | import mlpy 4 | from collections import OrderedDict 5 | 6 | 7 | data = {} 8 | 9 | for fn in range(1,658): 10 | img = Image.open("ImgFolder\\{0}.jpg".format(fn)) 11 | arr = array(img) 12 | list = [] 13 | for n in arr: list.append(n[0][0]) 14 | for n in arr: list.append(n[0][1]) 15 | for n in arr: list.append(n[0][2]) 16 | data[fn] = list 17 | 18 | reference = data[31] 19 | 20 | result ={} 21 | 22 | for x, y in data.items(): 23 | dist = mlpy.dtw_std(reference, y, dist_only=True) 24 | result[x] = dist 25 | 26 | 27 | sortedRes = OrderedDict(sorted(result.items(), key=lambda x: x[1])) 28 | for a,b in sortedRes.items(): 29 | print("{0}-{1}".format(a,b)) 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /Chapter6/RandomWalk.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Random walk 6 | 7 | 22 | 23 | 24 | 104 | 105 | -------------------------------------------------------------------------------- /Chapter7/Gold.csv: -------------------------------------------------------------------------------- 1 | date,price 2 | 1/31/2003,367.5 3 | 2/28/2003,347.5 4 | 3/31/2003,334.9 5 | 4/30/2003,336.8 6 | 5/30/2003,361.4 7 | 6/30/2003,346.0 8 | 7/31/2003,354.8 9 | 8/29/2003,375.6 10 | 9/30/2003,388.0 11 | 10/31/2003,386.3 12 | 11/28/2003,398.4 13 | 12/31/2003,416.3 14 | 1/30/2004,399.8 15 | 2/27/2004,395.9 16 | 3/31/2004,423.7 17 | 4/30/2004,388.5 18 | 5/31/2004,393.3 19 | 6/30/2004,395.8 20 | 7/30/2004,391.4 21 | 8/31/2004,407.3 22 | 9/30/2004,415.7 23 | 10/29/2004,425.6 24 | 11/30/2004,453.4 25 | 12/31/2004,435.6 26 | 1/31/2005,422.2 27 | 2/28/2005,435.5 28 | 3/31/2005,427.5 29 | 4/29/2005,435.7 30 | 5/31/2005,414.5 31 | 6/30/2005,437.1 32 | 7/29/2005,429.0 33 | 8/31/2005,433.3 34 | 9/30/2005,473.3 35 | 10/31/2005,470.8 36 | 11/30/2005,495.7 37 | 12/30/2005,513.0 38 | 1/31/2006,568.8 39 | 2/28/2006,556.0 40 | 3/31/2006,582.0 41 | 4/28/2006,644.0 42 | 5/31/2006,653.0 43 | 6/30/2006,613.5 44 | 7/31/2006,632.5 45 | 8/31/2006,623.5 46 | 9/29/2006,599.3 47 | 10/31/2006,603.8 48 | 11/30/2006,646.7 49 | 12/29/2006,632.0 50 | 1/31/2007,650.5 51 | 2/28/2007,664.2 52 | 3/30/2007,661.8 53 | 4/30/2007,677.0 54 | 5/31/2007,659.1 55 | 6/29/2007,650.5 56 | 7/31/2007,665.5 57 | 8/31/2007,672.0 58 | 9/28/2007,743.0 59 | 10/31/2007,789.5 60 | 11/30/2007,783.5 61 | 12/31/2007,833.8 62 | 1/31/2008,923.3 63 | 2/29/2008,971.5 64 | 3/31/2008,933.5 65 | 4/30/2008,871.0 66 | 5/30/2008,885.8 67 | 6/30/2008,930.3 68 | 7/31/2008,918.0 69 | 8/29/2008,833.0 70 | 9/30/2008,884.5 71 | 10/31/2008,730.8 72 | 11/28/2008,814.5 73 | 12/31/2008,869.8 74 | 1/30/2009,919.5 75 | 2/27/2009,952.0 76 | 3/31/2009,916.5 77 | 4/30/2009,883.3 78 | 5/29/2009,975.5 79 | 6/30/2009,934.5 80 | 7/31/2009,939.0 81 | 8/31/2009,955.5 82 | 9/30/2009,995.8 83 | 10/30/2009,1040.0 84 | 11/30/2009,1175.8 85 | 12/31/2009,1087.5 86 | 1/29/2010,1078.5 87 | 2/26/2010,1108.3 88 | 3/31/2010,1115.5 89 | 4/30/2010,1179.3 90 | 5/31/2010,1207.5 91 | 6/30/2010,1244.0 92 | 7/30/2010,1169.0 93 | 8/31/2010,1246.0 94 | 9/30/2010,1307.0 95 | 10/29/2010,1346.8 96 | 11/30/2010,1383.5 97 | 12/31/2010,1405.5 98 | 1/31/2011,1327.0 99 | 2/28/2011,1411.0 100 | 3/31/2011,1439.0 101 | 4/29/2011,1535.5 102 | 5/31/2011,1536.5 103 | 6/30/2011,1505.5 104 | 7/29/2011,1628.5 105 | 8/31/2011,1813.5 106 | 9/30/2011,1620.0 107 | 10/31/2011,1722.0 108 | 11/30/2011,1746.0 109 | 12/30/2011,1531.0 110 | 1/31/2012,1744.0 111 | 2/29/2012,1770.0 112 | 3/30/2012,1662.5 113 | 4/30/2012,1651.3 114 | 5/31/2012,1558.0 115 | 6/29/2012,1598.5 116 | 7/31/2012,1622.0 117 | 8/31/2012,1648.5 118 | 9/28/2012,1776.0 119 | 10/31/2012,1719.0 120 | 11/30/2012,1726.0 121 | 12/31/2012,1657.5 122 | 1/31/2013,1664.8 123 | 2/28/2013,1588.5 124 | 3/29/2013,1598.3 125 | 4/30/2013,1469.0 126 | 5/31/2013,1394.5 127 | -------------------------------------------------------------------------------- /Chapter7/KRR.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import mlpy 3 | from mlpy import KernelRidge 4 | import matplotlib.pyplot as plt 5 | 6 | np.random.seed(10) 7 | 8 | targetValues = np.genfromtxt("Gold.csv", 9 | skip_header=1, 10 | dtype=None, 11 | delimiter=',', 12 | usecols=(1)) 13 | 14 | trainingPoints = np.arange(125).reshape(-1, 1) 15 | testPoints = np.arange(126).reshape(-1, 1) 16 | 17 | #training kernel matrix 18 | knl = mlpy.kernel_gaussian(trainingPoints, trainingPoints, sigma=1) 19 | #testing kernel matrix 20 | knlTest = mlpy.kernel_gaussian(testPoints, trainingPoints, sigma=1) 21 | 22 | knlRidge = KernelRidge(lmb=0.01, kernel=None) 23 | knlRidge.learn(knl, targetValues) 24 | resultPoints = knlRidge.pred(knlTest) 25 | 26 | print(resultPoints) 27 | 28 | fig = plt.figure(1) 29 | plot1 = plt.plot(trainingPoints, targetValues, 'o') 30 | plot2 = plt.plot(testPoints, resultPoints) 31 | plt.show() 32 | 33 | -------------------------------------------------------------------------------- /Chapter7/matplotlibExample.py.txt: -------------------------------------------------------------------------------- 1 | import matplotlib.pyplot as plt 2 | import numpy as np 3 | 4 | x = np.linspace(10, 50, 100) 5 | 6 | y = np.cos(x)/x 7 | 8 | plt.step(x, y, 'co') 9 | plt.show() 10 | -------------------------------------------------------------------------------- /Chapter7/smoothFunction.py.txt: -------------------------------------------------------------------------------- 1 | 2 | def smooth(x,window_len=125,window='hamming'): 3 | if x.ndim != 1: 4 | raise Exception(ValueError, "smooth only accepts 1 dimension arrays.") 5 | if x.size < window_len: 6 | raise Exception(ValueError, "Input vector needs to be bigger than window size.") 7 | if window_len<3: 8 | return x 9 | if not window in ['flat', 'hanning', 'hamming', 'bartlett', 'blackman']: 10 | raise Exception(ValueError, "Window is on of 'flat', 'hanning', 'hamming', 'bartlett', 'blackman'") 11 | s=np.r_[2*x[0]-x[window_len-1::-1],x,2*x[-1]-x[-1:-window_len:-1]] 12 | if window == 'flat': #moving average 13 | w=np.ones(window_len,'d') 14 | else: 15 | w=eval('np.'+window+'(window_len)') 16 | y=np.convolve(w/w.sum(),s,mode='same') 17 | return y[window_len:-window_len+1] 18 | -------------------------------------------------------------------------------- /Chapter7/smoothKRR.py: -------------------------------------------------------------------------------- 1 | import matplotlib.pyplot as plt 2 | import numpy as np 3 | import dateutil.parser as dparser 4 | from pylab import * 5 | import mlpy 6 | 7 | def smooth(x,window_len): 8 | 9 | s=np.r_[2*x[0]-x[window_len-1::-1],x,2*x[-1]-x[-1:-window_len:-1]] 10 | w = np.hamming(window_len) 11 | 12 | y=np.convolve(w/w.sum(),s,mode='same') 13 | return y[window_len:-window_len+1] 14 | 15 | 16 | 17 | y = np.genfromtxt("Gold.csv", 18 | skip_header=1, 19 | dtype=None, 20 | delimiter=',', 21 | usecols=(1)) 22 | 23 | 24 | targetValues = smooth(y, len(y)) 25 | 26 | 27 | np.random.seed(10) 28 | 29 | trainingPoints = np.arange(125).reshape(-1, 1) 30 | testPoints = np.arange(126).reshape(-1, 1) 31 | 32 | 33 | knl = mlpy.kernel_gaussian(trainingPoints, trainingPoints, sigma=1) 34 | knlTest = mlpy.kernel_gaussian(testPoints, trainingPoints, sigma=1) 35 | 36 | knlRidge = mlpy.KernelRidge(lmb=0.01, kernel=None) 37 | knlRidge.learn(knl, targetValues) 38 | resultPoints = knlRidge.pred(knlTest) 39 | 40 | print(resultPoints) 41 | 42 | 43 | plt.step(trainingPoints, targetValues, 'o') 44 | plt.step(testPoints, resultPoints) 45 | plt.show() 46 | 47 | -------------------------------------------------------------------------------- /Chapter7/smoothTS.py: -------------------------------------------------------------------------------- 1 | import matplotlib.pyplot as plt 2 | import numpy as np 3 | import dateutil.parser as dparser 4 | from pylab import * 5 | 6 | def smooth(x,window_len): 7 | 8 | s=np.r_[2*x[0]-x[window_len-1::-1],x,2*x[-1]-x[-1:-window_len:-1]] 9 | w = np.hamming(window_len) 10 | 11 | y=np.convolve(w/w.sum(),s,mode='same') 12 | return y[window_len:-window_len+1] 13 | 14 | 15 | x = np.genfromtxt("Gold.csv", dtype='object', delimiter=',', skip_header=1, 16 | usecols=(0), converters = {0: dparser.parse}) 17 | 18 | y = np.genfromtxt("Gold.csv", 19 | skip_header=1, 20 | dtype=None, 21 | delimiter=',', 22 | usecols=(1)) 23 | 24 | y2 = smooth(y, len(y)) 25 | 26 | print(y2) 27 | 28 | plt.step(x, y2) 29 | plt.step(x, y, 'co') 30 | plt.show() 31 | -------------------------------------------------------------------------------- /Chapter8/PCA-SVM.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import mlpy 3 | import matplotlib.pyplot as plt 4 | import matplotlib.cm as cm 5 | 6 | wine = np.loadtxt('wine.data', delimiter=',') 7 | x, y = wine[:, 1:4], wine[:, 0].astype(np.int) 8 | print(x.shape) 9 | print(y.shape) 10 | 11 | pca = mlpy.PCA() 12 | pca.learn(x) 13 | z = pca.transform(x, k=2) 14 | print(z.shape) 15 | 16 | 17 | fig1 = plt.figure(1) 18 | title = plt.title("PCA on wine dataset") 19 | plot = plt.scatter(z[:, 0], z[:, 1], c=y,s=90, cmap = cm.Reds) 20 | labx = plt.xlabel("First component") 21 | laby = plt.ylabel("Second component") 22 | plt.show() 23 | 24 | 25 | svm = mlpy.LibSvm(kernel_type='rbf', gamma=20 ) 26 | svm.learn(z, y) 27 | 28 | 29 | xmin, xmax = z[:,0].min()-0.1, z[:,0].max()+0.1 30 | ymin, ymax = z[:,1].min()-0.1, z[:,1].max()+0.1 31 | xx, yy = np.meshgrid(np.arange(xmin, xmax, 0.01), np.arange(ymin, ymax, 0.01)) 32 | grid = np.c_[xx.ravel(), yy.ravel()] 33 | 34 | 35 | result = svm.pred(grid) 36 | 37 | fig2 = plt.figure(2) 38 | title = plt.title("SVM (linear kernel) on PCA") 39 | plot1 = plt.pcolormesh(xx, yy, result.reshape(xx.shape), cmap = cm.Greys_r) 40 | plot2 = plt.scatter(z[:, 0], z[:, 1], c=y, s=90, cmap = cm.Reds) 41 | labx = plt.xlabel("First component") 42 | laby = plt.ylabel("Second component") 43 | limx = plt.xlim(xmin, xmax) 44 | limy = plt.ylim(ymin, ymax) 45 | plt.show() 46 | -------------------------------------------------------------------------------- /Chapter8/PlotWineFeatures.py: -------------------------------------------------------------------------------- 1 | import matplotlib 2 | import matplotlib.pyplot as plt 3 | 4 | def getData(): 5 | lists = [line.strip().split(",") for line in open('wine.data', 'r').readlines()] 6 | return [list( l[1:14]) for l in lists], [l[0] for l in lists] 7 | 8 | matrix, labels = getData() 9 | 10 | xaxis1 = []; yaxis1 = [] 11 | xaxis2 = []; yaxis2 = [] 12 | xaxis3 = []; yaxis3 = [] 13 | x = 0 14 | y = 1 15 | 16 | for n, elem in enumerate(matrix): 17 | if int(labels[n]) == 1: 18 | xaxis1.append(matrix[n][x]) 19 | yaxis1.append(matrix[n][y]) 20 | elif int(labels[n]) == 2: 21 | xaxis2.append(matrix[n][x]) 22 | yaxis2.append(matrix[n][y]) 23 | elif int(labels[n]) == 3: 24 | xaxis3.append(matrix[n][x]) 25 | yaxis3.append(matrix[n][y]) 26 | 27 | fig = plt.figure() 28 | ax = fig.add_subplot(111) 29 | type1 = ax.scatter(xaxis1, yaxis1, s=80, c='white') 30 | type2 = ax.scatter(xaxis2, yaxis2, s=80, c='red') 31 | type3 = ax.scatter(xaxis3, yaxis3, s=80, c='darkred') 32 | 33 | ax.set_title('Wine Features', fontsize=14) 34 | ax.set_xlabel('X axis') 35 | ax.set_ylabel('Y axis') 36 | ax.legend([type1, type2, type3], ["Class 1", "Class 2", "Class 3"], loc=1) 37 | 38 | ax.grid(True,linestyle='-',color='0.80') 39 | 40 | plt.show() 41 | -------------------------------------------------------------------------------- /Chapter8/wine.data: -------------------------------------------------------------------------------- 1 | 1,14.23,1.71,2.43,15.6,127,2.8,3.06,.28,2.29,5.64,1.04,3.92,1065 2 | 1,13.2,1.78,2.14,11.2,100,2.65,2.76,.26,1.28,4.38,1.05,3.4,1050 3 | 1,13.16,2.36,2.67,18.6,101,2.8,3.24,.3,2.81,5.68,1.03,3.17,1185 4 | 1,14.37,1.95,2.5,16.8,113,3.85,3.49,.24,2.18,7.8,.86,3.45,1480 5 | 1,13.24,2.59,2.87,21,118,2.8,2.69,.39,1.82,4.32,1.04,2.93,735 6 | 1,14.2,1.76,2.45,15.2,112,3.27,3.39,.34,1.97,6.75,1.05,2.85,1450 7 | 1,14.39,1.87,2.45,14.6,96,2.5,2.52,.3,1.98,5.25,1.02,3.58,1290 8 | 1,14.06,2.15,2.61,17.6,121,2.6,2.51,.31,1.25,5.05,1.06,3.58,1295 9 | 1,14.83,1.64,2.17,14,97,2.8,2.98,.29,1.98,5.2,1.08,2.85,1045 10 | 1,13.86,1.35,2.27,16,98,2.98,3.15,.22,1.85,7.22,1.01,3.55,1045 11 | 1,14.1,2.16,2.3,18,105,2.95,3.32,.22,2.38,5.75,1.25,3.17,1510 12 | 1,14.12,1.48,2.32,16.8,95,2.2,2.43,.26,1.57,5,1.17,2.82,1280 13 | 1,13.75,1.73,2.41,16,89,2.6,2.76,.29,1.81,5.6,1.15,2.9,1320 14 | 1,14.75,1.73,2.39,11.4,91,3.1,3.69,.43,2.81,5.4,1.25,2.73,1150 15 | 1,14.38,1.87,2.38,12,102,3.3,3.64,.29,2.96,7.5,1.2,3,1547 16 | 1,13.63,1.81,2.7,17.2,112,2.85,2.91,.3,1.46,7.3,1.28,2.88,1310 17 | 1,14.3,1.92,2.72,20,120,2.8,3.14,.33,1.97,6.2,1.07,2.65,1280 18 | 1,13.83,1.57,2.62,20,115,2.95,3.4,.4,1.72,6.6,1.13,2.57,1130 19 | 1,14.19,1.59,2.48,16.5,108,3.3,3.93,.32,1.86,8.7,1.23,2.82,1680 20 | 1,13.64,3.1,2.56,15.2,116,2.7,3.03,.17,1.66,5.1,.96,3.36,845 21 | 1,14.06,1.63,2.28,16,126,3,3.17,.24,2.1,5.65,1.09,3.71,780 22 | 1,12.93,3.8,2.65,18.6,102,2.41,2.41,.25,1.98,4.5,1.03,3.52,770 23 | 1,13.71,1.86,2.36,16.6,101,2.61,2.88,.27,1.69,3.8,1.11,4,1035 24 | 1,12.85,1.6,2.52,17.8,95,2.48,2.37,.26,1.46,3.93,1.09,3.63,1015 25 | 1,13.5,1.81,2.61,20,96,2.53,2.61,.28,1.66,3.52,1.12,3.82,845 26 | 1,13.05,2.05,3.22,25,124,2.63,2.68,.47,1.92,3.58,1.13,3.2,830 27 | 1,13.39,1.77,2.62,16.1,93,2.85,2.94,.34,1.45,4.8,.92,3.22,1195 28 | 1,13.3,1.72,2.14,17,94,2.4,2.19,.27,1.35,3.95,1.02,2.77,1285 29 | 1,13.87,1.9,2.8,19.4,107,2.95,2.97,.37,1.76,4.5,1.25,3.4,915 30 | 1,14.02,1.68,2.21,16,96,2.65,2.33,.26,1.98,4.7,1.04,3.59,1035 31 | 1,13.73,1.5,2.7,22.5,101,3,3.25,.29,2.38,5.7,1.19,2.71,1285 32 | 1,13.58,1.66,2.36,19.1,106,2.86,3.19,.22,1.95,6.9,1.09,2.88,1515 33 | 1,13.68,1.83,2.36,17.2,104,2.42,2.69,.42,1.97,3.84,1.23,2.87,990 34 | 1,13.76,1.53,2.7,19.5,132,2.95,2.74,.5,1.35,5.4,1.25,3,1235 35 | 1,13.51,1.8,2.65,19,110,2.35,2.53,.29,1.54,4.2,1.1,2.87,1095 36 | 1,13.48,1.81,2.41,20.5,100,2.7,2.98,.26,1.86,5.1,1.04,3.47,920 37 | 1,13.28,1.64,2.84,15.5,110,2.6,2.68,.34,1.36,4.6,1.09,2.78,880 38 | 1,13.05,1.65,2.55,18,98,2.45,2.43,.29,1.44,4.25,1.12,2.51,1105 39 | 1,13.07,1.5,2.1,15.5,98,2.4,2.64,.28,1.37,3.7,1.18,2.69,1020 40 | 1,14.22,3.99,2.51,13.2,128,3,3.04,.2,2.08,5.1,.89,3.53,760 41 | 1,13.56,1.71,2.31,16.2,117,3.15,3.29,.34,2.34,6.13,.95,3.38,795 42 | 1,13.41,3.84,2.12,18.8,90,2.45,2.68,.27,1.48,4.28,.91,3,1035 43 | 1,13.88,1.89,2.59,15,101,3.25,3.56,.17,1.7,5.43,.88,3.56,1095 44 | 1,13.24,3.98,2.29,17.5,103,2.64,2.63,.32,1.66,4.36,.82,3,680 45 | 1,13.05,1.77,2.1,17,107,3,3,.28,2.03,5.04,.88,3.35,885 46 | 1,14.21,4.04,2.44,18.9,111,2.85,2.65,.3,1.25,5.24,.87,3.33,1080 47 | 1,14.38,3.59,2.28,16,102,3.25,3.17,.27,2.19,4.9,1.04,3.44,1065 48 | 1,13.9,1.68,2.12,16,101,3.1,3.39,.21,2.14,6.1,.91,3.33,985 49 | 1,14.1,2.02,2.4,18.8,103,2.75,2.92,.32,2.38,6.2,1.07,2.75,1060 50 | 1,13.94,1.73,2.27,17.4,108,2.88,3.54,.32,2.08,8.90,1.12,3.1,1260 51 | 1,13.05,1.73,2.04,12.4,92,2.72,3.27,.17,2.91,7.2,1.12,2.91,1150 52 | 1,13.83,1.65,2.6,17.2,94,2.45,2.99,.22,2.29,5.6,1.24,3.37,1265 53 | 1,13.82,1.75,2.42,14,111,3.88,3.74,.32,1.87,7.05,1.01,3.26,1190 54 | 1,13.77,1.9,2.68,17.1,115,3,2.79,.39,1.68,6.3,1.13,2.93,1375 55 | 1,13.74,1.67,2.25,16.4,118,2.6,2.9,.21,1.62,5.85,.92,3.2,1060 56 | 1,13.56,1.73,2.46,20.5,116,2.96,2.78,.2,2.45,6.25,.98,3.03,1120 57 | 1,14.22,1.7,2.3,16.3,118,3.2,3,.26,2.03,6.38,.94,3.31,970 58 | 1,13.29,1.97,2.68,16.8,102,3,3.23,.31,1.66,6,1.07,2.84,1270 59 | 1,13.72,1.43,2.5,16.7,108,3.4,3.67,.19,2.04,6.8,.89,2.87,1285 60 | 2,12.37,.94,1.36,10.6,88,1.98,.57,.28,.42,1.95,1.05,1.82,520 61 | 2,12.33,1.1,2.28,16,101,2.05,1.09,.63,.41,3.27,1.25,1.67,680 62 | 2,12.64,1.36,2.02,16.8,100,2.02,1.41,.53,.62,5.75,.98,1.59,450 63 | 2,13.67,1.25,1.92,18,94,2.1,1.79,.32,.73,3.8,1.23,2.46,630 64 | 2,12.37,1.13,2.16,19,87,3.5,3.1,.19,1.87,4.45,1.22,2.87,420 65 | 2,12.17,1.45,2.53,19,104,1.89,1.75,.45,1.03,2.95,1.45,2.23,355 66 | 2,12.37,1.21,2.56,18.1,98,2.42,2.65,.37,2.08,4.6,1.19,2.3,678 67 | 2,13.11,1.01,1.7,15,78,2.98,3.18,.26,2.28,5.3,1.12,3.18,502 68 | 2,12.37,1.17,1.92,19.6,78,2.11,2,.27,1.04,4.68,1.12,3.48,510 69 | 2,13.34,.94,2.36,17,110,2.53,1.3,.55,.42,3.17,1.02,1.93,750 70 | 2,12.21,1.19,1.75,16.8,151,1.85,1.28,.14,2.5,2.85,1.28,3.07,718 71 | 2,12.29,1.61,2.21,20.4,103,1.1,1.02,.37,1.46,3.05,.906,1.82,870 72 | 2,13.86,1.51,2.67,25,86,2.95,2.86,.21,1.87,3.38,1.36,3.16,410 73 | 2,13.49,1.66,2.24,24,87,1.88,1.84,.27,1.03,3.74,.98,2.78,472 74 | 2,12.99,1.67,2.6,30,139,3.3,2.89,.21,1.96,3.35,1.31,3.5,985 75 | 2,11.96,1.09,2.3,21,101,3.38,2.14,.13,1.65,3.21,.99,3.13,886 76 | 2,11.66,1.88,1.92,16,97,1.61,1.57,.34,1.15,3.8,1.23,2.14,428 77 | 2,13.03,.9,1.71,16,86,1.95,2.03,.24,1.46,4.6,1.19,2.48,392 78 | 2,11.84,2.89,2.23,18,112,1.72,1.32,.43,.95,2.65,.96,2.52,500 79 | 2,12.33,.99,1.95,14.8,136,1.9,1.85,.35,2.76,3.4,1.06,2.31,750 80 | 2,12.7,3.87,2.4,23,101,2.83,2.55,.43,1.95,2.57,1.19,3.13,463 81 | 2,12,.92,2,19,86,2.42,2.26,.3,1.43,2.5,1.38,3.12,278 82 | 2,12.72,1.81,2.2,18.8,86,2.2,2.53,.26,1.77,3.9,1.16,3.14,714 83 | 2,12.08,1.13,2.51,24,78,2,1.58,.4,1.4,2.2,1.31,2.72,630 84 | 2,13.05,3.86,2.32,22.5,85,1.65,1.59,.61,1.62,4.8,.84,2.01,515 85 | 2,11.84,.89,2.58,18,94,2.2,2.21,.22,2.35,3.05,.79,3.08,520 86 | 2,12.67,.98,2.24,18,99,2.2,1.94,.3,1.46,2.62,1.23,3.16,450 87 | 2,12.16,1.61,2.31,22.8,90,1.78,1.69,.43,1.56,2.45,1.33,2.26,495 88 | 2,11.65,1.67,2.62,26,88,1.92,1.61,.4,1.34,2.6,1.36,3.21,562 89 | 2,11.64,2.06,2.46,21.6,84,1.95,1.69,.48,1.35,2.8,1,2.75,680 90 | 2,12.08,1.33,2.3,23.6,70,2.2,1.59,.42,1.38,1.74,1.07,3.21,625 91 | 2,12.08,1.83,2.32,18.5,81,1.6,1.5,.52,1.64,2.4,1.08,2.27,480 92 | 2,12,1.51,2.42,22,86,1.45,1.25,.5,1.63,3.6,1.05,2.65,450 93 | 2,12.69,1.53,2.26,20.7,80,1.38,1.46,.58,1.62,3.05,.96,2.06,495 94 | 2,12.29,2.83,2.22,18,88,2.45,2.25,.25,1.99,2.15,1.15,3.3,290 95 | 2,11.62,1.99,2.28,18,98,3.02,2.26,.17,1.35,3.25,1.16,2.96,345 96 | 2,12.47,1.52,2.2,19,162,2.5,2.27,.32,3.28,2.6,1.16,2.63,937 97 | 2,11.81,2.12,2.74,21.5,134,1.6,.99,.14,1.56,2.5,.95,2.26,625 98 | 2,12.29,1.41,1.98,16,85,2.55,2.5,.29,1.77,2.9,1.23,2.74,428 99 | 2,12.37,1.07,2.1,18.5,88,3.52,3.75,.24,1.95,4.5,1.04,2.77,660 100 | 2,12.29,3.17,2.21,18,88,2.85,2.99,.45,2.81,2.3,1.42,2.83,406 101 | 2,12.08,2.08,1.7,17.5,97,2.23,2.17,.26,1.4,3.3,1.27,2.96,710 102 | 2,12.6,1.34,1.9,18.5,88,1.45,1.36,.29,1.35,2.45,1.04,2.77,562 103 | 2,12.34,2.45,2.46,21,98,2.56,2.11,.34,1.31,2.8,.8,3.38,438 104 | 2,11.82,1.72,1.88,19.5,86,2.5,1.64,.37,1.42,2.06,.94,2.44,415 105 | 2,12.51,1.73,1.98,20.5,85,2.2,1.92,.32,1.48,2.94,1.04,3.57,672 106 | 2,12.42,2.55,2.27,22,90,1.68,1.84,.66,1.42,2.7,.86,3.3,315 107 | 2,12.25,1.73,2.12,19,80,1.65,2.03,.37,1.63,3.4,1,3.17,510 108 | 2,12.72,1.75,2.28,22.5,84,1.38,1.76,.48,1.63,3.3,.88,2.42,488 109 | 2,12.22,1.29,1.94,19,92,2.36,2.04,.39,2.08,2.7,.86,3.02,312 110 | 2,11.61,1.35,2.7,20,94,2.74,2.92,.29,2.49,2.65,.96,3.26,680 111 | 2,11.46,3.74,1.82,19.5,107,3.18,2.58,.24,3.58,2.9,.75,2.81,562 112 | 2,12.52,2.43,2.17,21,88,2.55,2.27,.26,1.22,2,.9,2.78,325 113 | 2,11.76,2.68,2.92,20,103,1.75,2.03,.6,1.05,3.8,1.23,2.5,607 114 | 2,11.41,.74,2.5,21,88,2.48,2.01,.42,1.44,3.08,1.1,2.31,434 115 | 2,12.08,1.39,2.5,22.5,84,2.56,2.29,.43,1.04,2.9,.93,3.19,385 116 | 2,11.03,1.51,2.2,21.5,85,2.46,2.17,.52,2.01,1.9,1.71,2.87,407 117 | 2,11.82,1.47,1.99,20.8,86,1.98,1.6,.3,1.53,1.95,.95,3.33,495 118 | 2,12.42,1.61,2.19,22.5,108,2,2.09,.34,1.61,2.06,1.06,2.96,345 119 | 2,12.77,3.43,1.98,16,80,1.63,1.25,.43,.83,3.4,.7,2.12,372 120 | 2,12,3.43,2,19,87,2,1.64,.37,1.87,1.28,.93,3.05,564 121 | 2,11.45,2.4,2.42,20,96,2.9,2.79,.32,1.83,3.25,.8,3.39,625 122 | 2,11.56,2.05,3.23,28.5,119,3.18,5.08,.47,1.87,6,.93,3.69,465 123 | 2,12.42,4.43,2.73,26.5,102,2.2,2.13,.43,1.71,2.08,.92,3.12,365 124 | 2,13.05,5.8,2.13,21.5,86,2.62,2.65,.3,2.01,2.6,.73,3.1,380 125 | 2,11.87,4.31,2.39,21,82,2.86,3.03,.21,2.91,2.8,.75,3.64,380 126 | 2,12.07,2.16,2.17,21,85,2.6,2.65,.37,1.35,2.76,.86,3.28,378 127 | 2,12.43,1.53,2.29,21.5,86,2.74,3.15,.39,1.77,3.94,.69,2.84,352 128 | 2,11.79,2.13,2.78,28.5,92,2.13,2.24,.58,1.76,3,.97,2.44,466 129 | 2,12.37,1.63,2.3,24.5,88,2.22,2.45,.4,1.9,2.12,.89,2.78,342 130 | 2,12.04,4.3,2.38,22,80,2.1,1.75,.42,1.35,2.6,.79,2.57,580 131 | 3,12.86,1.35,2.32,18,122,1.51,1.25,.21,.94,4.1,.76,1.29,630 132 | 3,12.88,2.99,2.4,20,104,1.3,1.22,.24,.83,5.4,.74,1.42,530 133 | 3,12.81,2.31,2.4,24,98,1.15,1.09,.27,.83,5.7,.66,1.36,560 134 | 3,12.7,3.55,2.36,21.5,106,1.7,1.2,.17,.84,5,.78,1.29,600 135 | 3,12.51,1.24,2.25,17.5,85,2,.58,.6,1.25,5.45,.75,1.51,650 136 | 3,12.6,2.46,2.2,18.5,94,1.62,.66,.63,.94,7.1,.73,1.58,695 137 | 3,12.25,4.72,2.54,21,89,1.38,.47,.53,.8,3.85,.75,1.27,720 138 | 3,12.53,5.51,2.64,25,96,1.79,.6,.63,1.1,5,.82,1.69,515 139 | 3,13.49,3.59,2.19,19.5,88,1.62,.48,.58,.88,5.7,.81,1.82,580 140 | 3,12.84,2.96,2.61,24,101,2.32,.6,.53,.81,4.92,.89,2.15,590 141 | 3,12.93,2.81,2.7,21,96,1.54,.5,.53,.75,4.6,.77,2.31,600 142 | 3,13.36,2.56,2.35,20,89,1.4,.5,.37,.64,5.6,.7,2.47,780 143 | 3,13.52,3.17,2.72,23.5,97,1.55,.52,.5,.55,4.35,.89,2.06,520 144 | 3,13.62,4.95,2.35,20,92,2,.8,.47,1.02,4.4,.91,2.05,550 145 | 3,12.25,3.88,2.2,18.5,112,1.38,.78,.29,1.14,8.21,.65,2,855 146 | 3,13.16,3.57,2.15,21,102,1.5,.55,.43,1.3,4,.6,1.68,830 147 | 3,13.88,5.04,2.23,20,80,.98,.34,.4,.68,4.9,.58,1.33,415 148 | 3,12.87,4.61,2.48,21.5,86,1.7,.65,.47,.86,7.65,.54,1.86,625 149 | 3,13.32,3.24,2.38,21.5,92,1.93,.76,.45,1.25,8.42,.55,1.62,650 150 | 3,13.08,3.9,2.36,21.5,113,1.41,1.39,.34,1.14,9.40,.57,1.33,550 151 | 3,13.5,3.12,2.62,24,123,1.4,1.57,.22,1.25,8.60,.59,1.3,500 152 | 3,12.79,2.67,2.48,22,112,1.48,1.36,.24,1.26,10.8,.48,1.47,480 153 | 3,13.11,1.9,2.75,25.5,116,2.2,1.28,.26,1.56,7.1,.61,1.33,425 154 | 3,13.23,3.3,2.28,18.5,98,1.8,.83,.61,1.87,10.52,.56,1.51,675 155 | 3,12.58,1.29,2.1,20,103,1.48,.58,.53,1.4,7.6,.58,1.55,640 156 | 3,13.17,5.19,2.32,22,93,1.74,.63,.61,1.55,7.9,.6,1.48,725 157 | 3,13.84,4.12,2.38,19.5,89,1.8,.83,.48,1.56,9.01,.57,1.64,480 158 | 3,12.45,3.03,2.64,27,97,1.9,.58,.63,1.14,7.5,.67,1.73,880 159 | 3,14.34,1.68,2.7,25,98,2.8,1.31,.53,2.7,13,.57,1.96,660 160 | 3,13.48,1.67,2.64,22.5,89,2.6,1.1,.52,2.29,11.75,.57,1.78,620 161 | 3,12.36,3.83,2.38,21,88,2.3,.92,.5,1.04,7.65,.56,1.58,520 162 | 3,13.69,3.26,2.54,20,107,1.83,.56,.5,.8,5.88,.96,1.82,680 163 | 3,12.85,3.27,2.58,22,106,1.65,.6,.6,.96,5.58,.87,2.11,570 164 | 3,12.96,3.45,2.35,18.5,106,1.39,.7,.4,.94,5.28,.68,1.75,675 165 | 3,13.78,2.76,2.3,22,90,1.35,.68,.41,1.03,9.58,.7,1.68,615 166 | 3,13.73,4.36,2.26,22.5,88,1.28,.47,.52,1.15,6.62,.78,1.75,520 167 | 3,13.45,3.7,2.6,23,111,1.7,.92,.43,1.46,10.68,.85,1.56,695 168 | 3,12.82,3.37,2.3,19.5,88,1.48,.66,.4,.97,10.26,.72,1.75,685 169 | 3,13.58,2.58,2.69,24.5,105,1.55,.84,.39,1.54,8.66,.74,1.8,750 170 | 3,13.4,4.6,2.86,25,112,1.98,.96,.27,1.11,8.5,.67,1.92,630 171 | 3,12.2,3.03,2.32,19,96,1.25,.49,.4,.73,5.5,.66,1.83,510 172 | 3,12.77,2.39,2.28,19.5,86,1.39,.51,.48,.64,9.899999,.57,1.63,470 173 | 3,14.16,2.51,2.48,20,91,1.68,.7,.44,1.24,9.7,.62,1.71,660 174 | 3,13.71,5.65,2.45,20.5,95,1.68,.61,.52,1.06,7.7,.64,1.74,740 175 | 3,13.4,3.91,2.48,23,102,1.8,.75,.43,1.41,7.3,.7,1.56,750 176 | 3,13.27,4.28,2.26,20,120,1.59,.69,.43,1.35,10.2,.59,1.56,835 177 | 3,13.17,2.59,2.37,20,120,1.65,.68,.53,1.46,9.3,.6,1.62,840 178 | 3,14.13,4.1,2.74,24.5,96,2.05,.76,.56,1.35,9.2,.61,1.6,560 179 | -------------------------------------------------------------------------------- /Chapter9/CellularSIRSmodel.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 183 | 184 |
185 |

Status

186 | 187 |
188 | 189 | 190 | 191 | -------------------------------------------------------------------------------- /Chapter9/Ode4SIRmodel.py: -------------------------------------------------------------------------------- 1 | import scipy 2 | import scipy.integrate 3 | import pylab as plt 4 | 5 | beta = 0.003 6 | gamma = 0.1 7 | 8 | def SIR_model(X, t=0): 9 | 10 | y = scipy.array([- beta*X[0]*X[1] 11 | , beta*X[0]*X[1] - gamma*X[1] 12 | , gamma*X[1] ]) 13 | return y 14 | 15 | if __name__ == "__main__": 16 | 17 | t = scipy.linspace(0, 60, num = 100) 18 | 19 | X0 = scipy.array([225, 1,0]) 20 | X = scipy.integrate.odeint(SIR_model,X0,t) 21 | print(X) 22 | 23 | plt.plot(range(0, 100), X[:,0], 'o', color = "green") 24 | plt.plot(range(0, 100), X[:,1], 'x', color = "red") 25 | plt.plot(range(0, 100), X[:,2], '*', color = "blue") 26 | plt.show() 27 | -------------------------------------------------------------------------------- /Chapter9/PltRecordCAData.py: -------------------------------------------------------------------------------- 1 | import pylab as plt 2 | import numpy as np 3 | 4 | #data = np.array([215,10,0,205,20,0,191,34,0,155,70,0,108,100,17,75,120,30,47,115,63,30,90,105,19,62,144,14,41,170,11,22,192,10,10,205,10,5,210,10,1,214,10,0,215,10,0,215,10,0,215,10,0,215,10,0,215,10,0,215,10,0,215,10,0,215,10,0,215]) 5 | data = np.array([215,10,0,153,72,0,54,171,0,2,223,0,0,225,0,0,178,47,0,72,153,0,6,219,0,0,225,47,0,178,153,0,72,219,0,6,225,0,0]) 6 | 7 | result = data.reshape(-1,3) 8 | 9 | print(len(result[:,1])) 10 | print(len(range(0,16))) 11 | 12 | length = len(result) 13 | 14 | 15 | plt.plot(range(0,length), result[:,0], marker = 'o', lw = 3, color = "green") 16 | plt.plot(range(0,length), result[:,1], marker = 'x', linestyle = '--',lw = 3, color = "red") 17 | plt.plot(range(0,length), result[:,2], marker = '*', linestyle = ':',lw = 3, color = "blue") 18 | plt.show() 19 | 20 | 21 | #Suseptibles: 35 Infected: 153 Recovered: 37 Times: 4 22 | 23 | 24 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | PDA_Book 2 | ======== 3 | 4 | Practical Data Analysis Book - Code Examples 5 | 6 | Transform, model, and visualize your data through hands-on projects, developed in open source tools 7 | 8 | Overview 9 | 10 | Explore how to analyze your data in various innovative ways and turn them into insight 11 | Learn to use the D3.js visualization tool for exploratory data analysis 12 | Understand how to work with graphs and social data analysis 13 | Discover how to perform advanced query techniques and run MapReduce on MongoDB 14 | In Detail 15 | 16 | Plenty of small businesses face big amounts of data but lack the internal skills to support quantitative analysis. Understanding how to harness the power of data analysis using the latest open source technology can lead them to providing better customer service, the visualization of customer needs, or even the ability to obtain fresh insights about the performance of previous products. Practical Data Analysis is a book ideal for home and small business users who want to slice and dice the data they have on hand with minimum hassle. 17 | 18 | Practical Data Analysis is a hands-on guide to understanding the nature of your data and turn it into insight. It will introduce you to the use of machine learning techniques, social networks analytics, and econometrics to help your clients get insights about the pool of data they have at hand. Performing data preparation and processing over several kinds of data such as text, images, graphs, documents, and time series will also be covered. 19 | 20 | Practical Data Analysis presents a detailed exploration of the current work in data analysis through self-contained projects. First you will explore the basics of data preparation and transformation through OpenRefine. Then you will get started with exploratory data analysis using the D3js visualization framework. You will also be introduced to some of the machine learning techniques such as, classification, regression, and clusterization through practical projects such as spam classification, predicting gold prices, and finding clusters in your Facebook friends' network. You will learn how to solve problems in text classification, simulation, time series forecast, social media, and MapReduce through detailed projects. Finally you will work with large amounts of Twitter data using MapReduce to perform a sentiment analysis implemented in Python and MongoDB. 21 | 22 | Practical Data Analysis contains a combination of carefully selected algorithms and data scrubbing that enables you to turn your data into insight. 23 | 24 | What you will learn from this book 25 | 26 | Work with data to get meaningful results from your data analysis projects 27 | Visualize your data to find trends and correlations 28 | Build your own image similarity search engine 29 | Learn how to forecast numerical values from time series data 30 | Create an interactive visualization for your social media graph 31 | Explore the MapReduce framework in MongoDB 32 | Create interactive simulations with D3js 33 | Approach 34 | 35 | Practical Data Analysis is a practical, step-by-step guide to empower small businesses to manage and analyze your data and extract valuable information from the data 36 | 37 | Who this book is written for 38 | 39 | This book is for developers, small business users, and analysts who want to implement data analysis and visualization for their company in a practical way. You need no prior experience with data analysis or data processing; however, basic knowledge of programming, statistics, and linear algebra is assumed. 40 | --------------------------------------------------------------------------------