id
int64
0
25.6k
text
stringlengths
0
4.59k
16,600
delete the ufnqmbuf part of the filename to make it an actual mph qspqfsujft file spark will use this to configure its loggingnowopen this file in text editor of some sort on windowsyou might need to right-click there and select open with and then wordpad in the filelocate mph sppu$bufhpsz */' let' change this to ...
16,601
have little file available that will do the trick let' go to iuuq nfejbtvoephtpgudpnxjovujmtfyf downloading xjovujmtfyf will give you copy of little snippet of an executablewhich can be used to trick spark into thinking that you actually have hadoopnowsince we're going to be running our scripts locally on our d...
16,602
now let' open this xjovujmt folder and create cjo folder inside itnow in this cjo folderi want you to paste the xjovujmtfyf file we downloaded so you should have =xjovujmt=cjo and then xjovujmtfyfthis next step is only required on some systemsbut just to be safeopen command prompt on windows you can do that by going ...
16,603
now we need to set some environment variables for things to work 'll show you how to do that on windows on windows you'll need to open up the start menu and go to windows system control panel to open up control panelin control panelclick on system and security
16,604
thenclick on systemthen click on advanced system settings from the list on the left-hand side
16,605
from hereclick on environment variables
16,606
we will get these options
16,607
nowthis is very windows-specific way of setting environment variables on other operating systemsyou'll use different processesso you'll have to look at how to install spark on them herewe're going to set up some new user variables click on the first new button for new user variable and call it " ,@) &as shown belowall ...
16,608
so farso good the last thing we need to do is to modify our path you should have path environment variable hereclick on the path environment variablethen on edit and add new path this is going to be  " ,@) &=cjoand ' going to add another one+" "@) &=cjo
16,609
basicallythis makes all the binary executables of spark available to windowswherever you're running it from click on ok on this menu and on the previous two menus we have finally everything set up spark introduction let' get started with high-level overview of apache spark and see what it' all aboutwhat it' good forand...
16,610
it' scalable how is spark scalablewelllet' get little bit more specific here in how it all works the way it works isyou write driver programwhich is just little script that looks just like any other python script reallyand it uses the spark library to actually write your script with within that libraryyou define what' ...
16,611
within clusteryou might have individual executor tasks that are running these might be running on different computersor they might be running on different cores of the same computer they each have their own individual cache and their own individual tasks that they run the driver programthe spark context and the cluster...
16,612
it' young spark is very hot technologyand is relatively youngso it' still very much emerging and changing quicklybut lot of big people are using it amazonfor examplehas claimed they're using itebaynasa' jet propulsional laboratoriesgroupontripadvisoryahooand manymany others have too ' sure there' lot of companies using...
16,613
spark streamingspark streaming is library that lets you actually process data in real time data can be flowing into server continuouslysayfrom weblogsand spark streaming can help you process that data in real time as you goforever spark sqlthis lets you actually treat data as sql databaseand actually issue sql queries ...
16,614
howeveri will say that if you were to do some spark programming in the real worldthere' good chance people are using scala don' worry about it too muchthoughbecause in spark the python and scala code ends up looking very similar because it' all around the same rdd concept the syntax is very slightly differentbut it' no...
16,615
as mentionedthe most fundamental piece of spark is called the resilient distributed datasetan rddand this is going to be the object that you use to actually load and transform and get the answers you want out of the data that you're trying to process it' very important thing to understand the final letter in rdd stands...
16,616
creating rdds let' look at some little code snippets of actually creating rddsand think it will all start to make little bit more sense creating an rdd using python list the following is very simple exampleovnt qbsbmmfmj[ if just want to make an rdd out of plain old python listi can call the qbsbmmfmj[ function in spar...
16,617
remember when we talked about etl and elt earlier in the bookthis is good example of where you might actually be loading raw data into system and doing the transform on the system itself that you used to query your data you can take raw text files that haven' been processed at all and use the power of spark to actually...
16,618
transformations let' talk about transformations first transformations are exactly what they sound like it' way of taking an rdd and transforming every row in that rdd to new valuebased on function you provide let' look at some of those functionsmap(and flatmap()nbq and gmbunbq are the functions you'll see the most ofte...
16,619
tjohnbq here' little example of how you might use the map function in your worksee tdqbsbmmfmj[ seenbq mbnceby let' say created an rdd just from the list can then call seenbq with lambda function of that takes in each rowthat iseach value of that rddcalls it xand then it applies the function multiplied by to square ...
16,620
upq upq will give you the first few entries in that rdd if you just want to get little peek into what' in there for debugging purposes sfevdf the more powerful action is sfevdf which will actually let you combine values together for the same common key value you can also use rdds in the context of key-value data the sf...
16,621
some mllib capabilities sowhat are some of the things mllib can dowellone is feature extraction one thing you can do at scale is term frequency and inverse document frequency stuffand that' useful for creatingfor examplesearch indexes we will actually go through an example of that later in the the keyagainis that it ca...
16,622
the vector data type remember when we were doing movie similarities and movie recommendations earlier in the bookan example of vector might be list of all the movies that given user rated there are two types of vectorsparse and dense let' look at an example of those there are manymany movies in the worldand dense vecto...
16,623
decision trees in spark with mllib alrightlet' actually build some decision trees using spark and the mllib librarythis is very cool stuff wherever you put the course materials for this booki want you to go to that folder now make sure you're completely closed out of canopyor whatever environment you're using for pytho...
16,624
exploring decision trees code sowe are just looking at raw python script file nowwithout any of the usual embellishment of the ipython notebook stuff let' walk through what' going on in the script we'll go through it slowlybecause this is your first spark script that you've seen in this book firstwe're going to importf...
16,625
we need the -bcfmfe pjou classwhich is data type required by the %fdjtjpo sff classand the %fdjtjpo sff class itselfimported from nmmjcusff nextpretty much every spark script you see is going to include this linewhere we import qbsl$pog and qbsl$poufyugspnqztqbsljnqpsu qbsl$pog qbsl$poufyu this is needed to create th...
16,626
and then we will create our qbsl$poufyu object using that configurationtd qbsl$poufyu dpog dpog that gives us an td object we can use for creating rdds nextwe have bunch of functions pnfgvodujpotuibudpowfsupvs$ joqvuebubjoupovnfsjdbm gfbuvsftgpsfbdikpcdboejebuf efgcjobsz :jg : sfuvsofmtf sfuvsoefgnbq&evdbujpo efhsff ...
16,627
importing and cleaning our data let' go to the first bit of python code that actually gets executed in this script the first thing we're going to do is load up this btu)jsftdtw fileand that' the same file we used in the decision tree exercise that we did earlier in this book let' pause quickly to remind ourselves of t...
16,628
you can see that excel actually imported this into tablebut if you were to look at the raw text you' see that it' made up of comma-separated values the first line is the actual headings of each columnso what we have above are the number of years of prior experienceis the candidate currently employed or notnumber of pre...
16,629
nowwe're going to use nbq function what we need to do next is start to make more structure out of this information right nowevery row of my rdd is just line of textit is comma-delimited textbut it' still just giant line of textand want to take that commaseparated value list and actually split it up into individual fiel...
16,630
it takes in list of fieldsand just to remind you again what that looks likelet' pull up that dtw excel file againsoat this pointevery rdd entry has fieldit' python listwhere the first element is the years of experiencesecond element is employedso on and so forth the problems here are that we want to convert those list...
16,631
firstit takes in our list of usjoh'jfmet ready to convert it into -bcfmfe pjoutwhere the label is the target value-was this person hired or not or -followed by an array that consists of all the other fields that we care about sothis is how you create -bcfmfe pjou that the %fdjtjpo sff -mjc class can consume soyou see i...
16,632
creating test candidate and building our decision tree let' create little test candidate we can useso we can use our model to actually predict whether someone new would be hired or not what we're going to do is create test candidate that consists of an array of the same values for each field as we had in the csv fileuf...
16,633
continuing to move through our %fdjtjpo sffusbjo$mbttjgjfs callwe are going to use the hjoj impurity metric as we measure the entropy we have nby%fqui of which is just an upper boundary on how far we're going to gothat can be larger if you wish finallynby#jot is just way to trade off computational expense if you canso...
16,634
all we need to do is call tqbsltvcnjuso this is script that lets you run spark scripts from pythonand then the name of the script qbsl%fdjtjpo sffqz that' all have to do tqbsltvcnju qbsl%fdjtjpo sffqz hit returnand off it will go againif were doing this on cluster and created my qbsl$pog accordinglythis would actua...
16,635
we can walk through this and see what it means soin our output decision tree we actually end up with depth of fourwith nine different nodesandagainif we remind ourselves what these different fields correlate tothe way to read this isif (feature in )so that means if the employed is nothen we drop down to feature this li...
16,636
alrightso againwe begin with some boilerplate stuff gspnqztqbslnmmjcdmvtufsjohjnqpsufbot gspnovnqzjnqpsubssbzsboepn gspnnbuijnqpsutrsu gspnqztqbsljnqpsu qbsl$pog qbsl$poufyu gspntlmfbsoqsfqspdfttjohjnqpsutdbmf we're going to import the fbot package from the clustering -mjc packagewe're going to import array and ra...
16,637
' going to set the name of my application to qbslfbot and create qbsl$poufyu object that can then use to create rdds that run on my local machine we'll skip past the dsfbuf$mvtufsfe%bub function for nowand go to the first line of code that gets run ebub tdqbsbmmfmj[ tdbmf dsfbuf$mvtufsfe%bub  the first thing we're...
16,638
let' start by printing out the cluster assignments for each one of our points sowe're going to take our original data and transform it using lambda functionsftvmu %ebubnbq mbncebqpjou dmvtufstqsfejdu qpjou dbdif this function is just going to transform each point into the cluster number that is predicted from our mo...
16,639
within set sum of squared errors (wsssenowhow do we measure how good our clusters arewellone metric for that is called the within set sum of squared errorswowthat sounds fancyit' such big term that we need an abbreviation for itwssse all it iswe look at the distance from each point to its centroidthe final centroid in ...
16,640
againfeel free to take moment and stare at this little bit longer if you want it to sink in nothing really fancy going on herebut there are few important pointswe introduced the use of cache if you want to make sure that you don' do unnecessary recomputations on an rdd that you're going to use more than once we introdu...
16,641
and finallywe computed the wssse metricit came out to in this example soif you want to play around with this little biti encourage you to do so you can see what happens to that error metric as you increase or decrease the values of kand think about why that may be you can also experiment with what happens if you don' n...
16,642
you can kind of see where we're going with this solet' say we have very high term frequency and very low document frequency for given word the ratio of these two things can give me measure of the relevance of that word to the document soif see word that occurs very often in given documentbut not very often in the overa...
16,643
doing this at scale is the hard part if you want to do this over all of wikipediathen you're going to have to run this on cluster but for the sake of argumentwe are just going to run this on our own desktop for nowusing small sample of wikipedia data using tfidf how do we turn that into an actual search problemonce we ...
16,644
go into your course materials and open up the '*%'qz scriptand that should open up canopy with the following codenowstep back for moment and let it sink in that we're actually creating working search algorithmalong with few examples of using it in less than lines of code hereand it' scalable could run this on cluster...
16,645
import statements we're going to start by importing the qbsl$pog and qbsl$poufyu libraries that we need for any spark script that we run in pythonand then we're going to import )btijoh and *%using the following commands gspnqztqbsljnqpsu qbsl$pog qbsl$poufyu gspnqztqbslnmmjcgfbuvsfjnqpsu)btijoh gspnqztqbslnmmjcgfb...
16,646
finallyi' going to map that datatake in each list of fieldsextract field number three ywhich happen to know is the body of the article itselfthe actual article textand ' in turn going to split that based on spacesepdvnfout gjfmetnbq mbnceby tqmju what does is extract the body of the text from each wikipedia articlea...
16,647
this is actually represented as sparse vector at this point to save even more space sonot only have we converted all of our words to numbersbut we've also stripped out any missing data in the event that word does not appear in document where you're not storing the fact that word does not appear explicitlyit saves even ...
16,648
what this does is extract the tf-idf score for gettysburgfrom the hash value it maps to for every documentand stores that in this hfuuztcvsh fmfwbodf rdd we then combine that with the epdvnfou/bnft so we can see the results[jqqfe ftvmut hfuuztcvsh fmfwbodf[jq epdvnfou/bnft finallywe can print out the answerqsjou #ftu...
16,649
using the spark dataframe api for mllib this was originally produced for spark so let' talk about what' new in spark and what new capabilities exist in mllib now sothe main thing with spark is that they moved more and more toward dataframes and datasets datasets and dataframes are kind of used interchangeably sometimes...
16,650
as you seefor one thingwe're using nm instead of -mjcand that' because the new dataframe-based api is in there implementing linear regression in this examplewhat we're going to do is implement linear regressionand linear regression is just way of fitting line to set of data what we're going to do in this exercise is ta...
16,651
that is just text file that has comma-delimited values of two columnsand they're just two columns ofmore or less randomlylinearly correlated data it can represent whatever you want let' imagine that it represents heights and weightsfor example sothe first column might represent heightsthe second column might represent ...
16,652
nowlike saidwe're going to split our data in half usbjo ftu egsboepn qmju usbjojoh%usbjo ftu uftu%usbjo ftu we're going to do / split between training data and test data this returns back two dataframesone that ' going to use to actually create my modeland one that ' going to use to evaluate my model will next create ...
16,653
finallywe can zip them back together and just print them out side by side and see how well it doesqsfejdujpo"oe-bcfm qsfejdujpot[jq mbcfmt dpmmfdu gpsqsfejdujpojoqsfejdujpo"oe-bcfm qsjou qsfejdujpo tqbsltupq this is kind of convoluted way of doing iti did this to be more consistent with the previous examplebut simpl...
16,654
here we have our actual and predicted values side by sideand you can see that they're not too bad they tend to be more or less in the same ballpark there you have ita linear regression model in action using spark using the new dataframe-based api for mllib more and moreyou'll be using these apis going forward with mlli...
16,655
testing and experimental design in this we'll see the concept of / testing we'll go through the -testthe -statisticand the -valueall useful tools for determining whether result is actually real or result of random variation we'll dive into some real examples and get our hands dirty with some python code and compute the...
16,656
/ tests if you're going to be data scientist at big tech web companythis is something you're going to definitely be involved inbecause people need to run experiments to try different things on website and measure the results of itand that' actually not as straightforward as most people think it is what is an / testwell...
16,657
/ testing will split people up into people who see the orange buttonand people who see the blue buttonand can then measure the behavior between these two groups and how they might differand make my decision on what color my buttons should be based on that data you can test all sorts of things with an / test these inclu...
16,658
measuring conversion for / testing the first thing you need to figure out when you're designing an experiment on website is what are you trying to optimize forwhat is it that you really want to drive with this changeand this isn' always very obvious thing maybe it' the amount that people spendthe amount of revenue well...
16,659
how to attribute conversions another thing to watch out for is attributing conversions to change downstream if the action you're trying to drive doesn' happen immediately upon the user experiencing the thing that you're testingthings get little bit dodgy let' say change the color of button on page athe user then goes t...
16,660
you need to make sure that your business owners understand that this is an important effect that you need to quantify and understand before making business decisions following an / test or any experiment that you run on the web nowsometimes you need to choose conversion metric that has less variance it could be that th...
16,661
the -statistic or -test let' start with the -statisticalso known as -test it is basically measure of the difference in behavior between these two setsbetween your control and treatment groupexpressed in units of standard error it is based on standard errorwhich accounts for the variance inherent in the data itselfso by...
16,662
the -value is basically the probability that this experiment satisfies the null hypothesisthat isthe probability that there is no real difference between the control and the treatment' behavior low -value means there' low probability of it having no effectkind of double negative going on thereso it' little bit counter ...
16,663
let' go to an actual example and see how you might measure -statistics and -values using python measuring -statistics and -values using python let' fabricate some experimental data and use the -statistic and -value to determine whether given experimental result is real effect or not we're going to actually fabricate so...
16,664
in this casewe have -statistic of - the negative indicates that it is negative changethis was bad thing and the -value is veryvery small sothat implies that there is an extremely low probability that this change is just result of random chance remember that in order to declare significancewe need to see high tvalue -st...
16,665
you knowyou could look at this after the fact and say" percent oddsyou knowthat' not so badwe can live with that,butno meanin reality and practice you want to see pvalues that are below percentideally below percentand value of percent means it' actually not that strong of result sodon' justify it after the factgo into ...
16,666
sample size increased seven-digits let' actually increase the sample size to as shown hereoqsboepnopsnbm oqsboepnopsnbm tubutuuftu@joe "here is the resultwhat does that dowellnowwe're back under for the -statisticand our value' around percent we're seeing these kind of fluctua...
16,667
go ahead and play with thissee what the effect of different standard deviations has on the initial datasetsor differences in meansand different sample sizes just want you to dive inplay around with these different datasets and actually run themand see what the effect is on the -statistic and the -value and hopefully th...
16,668
at that point you can pull the plug on the experiment and either roll out the change more widely or remove it because it was actually having negative effect you can always tell people to go back and try againuse what they learned from the experiment to maybe try it again with some changes and soften the blow little bit...
16,669
/ test gotchas an important point want to make is that the results of an / testeven when you measure them in principled manner using -valuesis not gospel there are many effects that can actually skew the results of your experiment and cause you to make the wrong decision let' go through few of these and let you know ho...
16,670
novelty effects one problem is novelty effects one major achilles heel of an / test is the short time frame over which they tend to be runand this causes couple of problems first of allthere might be longer-term effects to the changeand you're not going to measure thosebut alsothere is certain effect to just something ...
16,671
it might even be involved with the weatherduring the summer people behave differently because it' hot out they're feeling kind of lazythey're on vacation more often maybe if you happen to do your experiment during the time of terrible storm in highly populated area that could skew your results as well againjust be cogn...
16,672
nowthese are all issues that using an established off-the-shelf framework like google experiments or optimizely or one of those guys can help with so that you're not reinventing the wheel on all these problems if your company does have homegrowninhouse solution because they're not comfortable with sharing that data wit...
16,673
attribution errors we talked briefly about attribution errors earlier this is if you are actually using downstream behavior from changeand that gets into gray area you need to understand how you're actually counting those conversions as function of distance from the thing that you changed and agree with your business s...
16,674
if you want to further your career in this fieldwhat ' really encourage you to do is talk to your boss if you work at company that has access to some interesting datasets of its ownsee if you can play around with them obviouslyyou want to talk to your boss first before you use any data owned by your companybecause ther...
16,675
/ test challenges about attribution errors data pollution novelty effects seasonal effects selection bias selection bias issuesauditing  / testing / tests about concepts conversionmeasuring for conversionsattributing no difference between two groups performing varianceas enemy apache spark...
16,676
data science in big data world the data science process machine learning handling large data on single computer first steps in big data join the nosql movement the rise of graph databases text mining and text analytics data visualization to the end user
16,677
preface xiii acknowledgments xiv about this book xvi about the authors xviii about the cover illustration xx data science in big data world benefits and uses of data science and big data facets of data structured data unstructured data natural language machine-generated data graph-based or network data audioimageand vi...
16,678
viii machine learning frameworks nosql databases scheduling tools benchmarking tools system deployment service programming security an introductory working example of hadoop summary the data science process overview of the data science process don' be slave to the process step defining research goals and creating proje...
16,679
ix the modeling process engineering features and selecting model training your model validating model predicting new observations types of machine learning supervised learning semi-supervised learning summary unsupervised learning handling large data on single computer the problems you face when handling large data gen...
16,680
case studyassessing risk when loaning money step the research goal step data preparation step report building step data retrieval step data exploration summary join the nosql movement introduction to nosql acidthe core principle of relational databases cap theoremthe problem with dbs on many nodes the base principles o...
16,681
xi case studyclassifying reddit posts meet the natural language toolkit data science process overview and step the research goal step data retrieval step data preparation step data exploration step revisiteddata preparation adapted step data analysis step presentation and automation summary data visualization to the en...
16,682
it' in all of us data science is what makes us humans what we are today nonot the computer-driven data science this book will introduce you tobut the ability of our brains to see connectionsdraw conclusions from factsand learn from our past experiences more so than any other species on the planetwe depend on our brains...
16,683
big thank you to all the people of manning involved in the process of making this book for guiding us all the way through our thanks also go to ravishankar rajagopalan for giving the manuscript full technical proofreadand to jonathan thoms and michael roberts for their expert comments there were many other reviewers wh...
16,684
xv ' really like to thank all my coworkers in my companyespecially mo and arnofor all the adventures we have been through together mo and arno have provided me excellent support and advice appreciate all of their time and effort in making this book complete they are great peopleand without themthis book may not have be...
16,685
can only show you the door you're the one that has to walk through it morpheusthe matrix welcome to the bookwhen reading the table of contentsyou probably noticed the diversity of the topics we're about to cover the goal of introducing data science is to provide you with little bit of everything--enough to get you star...
16,686
xvii in through we apply machine learning on increasingly large data sets keeps it small the data still fits easily into an average computer' memory increases the challenge by looking at "large data this data fits on your machinebut fitting it into ram is hardmaking it challenge to process without computing cluster fin...
16,687
davy cielen is an experienced entrepreneurbook authorand professor he is the co-owner with arno and mo of optimately and maitontwo data science companies based in belgium and the ukrespectivelyand co-owner of third data science company based in somaliland the main focus of these companies is on strategic big data scien...
16,688
xix mohamed ali is an entrepreneur and data science consultant together with davy and arnohe is the co-owner of optimately and maitontwo data science companies based in belgium and the ukrespectively his passion lies in two areasdata science and sustainable projectsthe latter being materialized through the creation of ...
16,689
the illustration on the cover of introducing data science is taken from the edition of sylvain marechal' four-volume compendium of regional dress customs this book was first published in paris in one year before the french revolution each illustration is colored by hand the caption for this illustration reads "homme sa...
16,690
big data world this covers defining data science and big data recognizing the different types of data gaining insight into the data science process introducing the fields of data science and big data working through examples of hadoop big data is blanket term for any collection of data sets so large or complex that it ...
16,691
data science in big data world the characteristics of big data are often referred to as the three vsvolume--how much data is therevariety--how diverse are different types of datavelocity--at what speed is new data generatedoften these characteristics are complemented with fourth vveracityhow accurate is the datathese f...
16,692
is another example of real-time personalized advertising human resource professionals use people analytics and text mining to screen candidatesmonitor the mood of employeesand study informal networks among coworkers people analytics is the central theme in the book moneyballthe art of winning an unfair game in the book...
16,693
data science in big data world facets of data in data science and big data you'll come across many different types of dataand each of them tends to require different tools and techniques the main categories of data are thesestructured unstructured natural language machine-generated graph-based audiovideoand images stre...
16,694
facets of data delete move spam new team of ui engineers cda@engineer com today : to xyz@program com an investment banking client of mine has had the go ahead to build new team of ui engineers to work on various areas of cutting-edge single-dealer trading platform they will be recruiting at all levels and paying betwee...
16,695
data science in big data world the natural language processing community has had success in entity recognitiontopic recognitionsummarizationtext completionand sentiment analysisbut models trained in one domain don' generalize well to other domains even state-of-the-art techniques aren' able to decipher the meaning of e...
16,696
facets of data the machine data shown in figure would fit nicely in classic table-structured database this isn' the best approach for highly interconnected or "networkeddatawhere the relationships between entities have valuable role to play graph-based or network data "graph datacan be confusing term because any data c...
16,697
data science in big data world audioimageand video audioimageand video are data types that pose specific challenges to data scientist tasks that are trivial for humanssuch as recognizing objects in picturesturn out to be challenging for computers mlbam (major league baseball advanced mediaannounced in that they'll incr...
16,698
throughout this bookthe data science process will be applied to bigger case studies and you'll get an idea of different possible research goals retrieving data the second step is to collect data you've stated in the project charter which data you need and where you can find it in this step you ensure that you can use t...
16,699
data science in big data world the previous description of the data science process gives you the impression that you walk through this process in linear waybut in reality you often have to step back and rework certain findings for instanceyou might find outliers in the data exploration phase that point to data import ...