id
int64
0
25.6k
text
stringlengths
0
4.59k
17,500
fig python prompt fig python interpreter fig anaconda fig jupyter notebook fig spyder software fig pycharm software
17,501
reserved words these words have some pre-defined significance in python programming language it should be noted that reserved words may not be used as constants or any other identifier names example of reserved words include ifelseforbreak etc whitespace line containing only whitespacepossibly with commentis known as b...
17,502
#program to enter string using input(function username=input("enter your name"print("hello ",usernamein [ ]runfileenter your nameindia hello india explanationin the above programthe user is prompted to enter the name which is stored in variable "usernameand hence when the username is printedthe name is printed the abov...
17,503
it can be observed that the first time when the program was executed the integer value corresponding to amount and decimal value corresponding to profit were printed in their respective formssince the type of input data was same as the functions used howeverwhen the functions were executed for the second timewe can see...
17,504
in [ ]runfileenter the first value var typeenter the second value var typeenter the third value"hello dearvar hello dear typeexplanationthe first statements ask the user to enter the first value the value entered by the user is stored in var (here the statement print('var ='var 'type:'type(var )displays the output on t...
17,505
explanationwe can observe that the use of each print statement displays the result in new line hence"hello""and""welcomeare printed on three different lines sometimesit is convenient to view the output of single line of printed text over several python statements as an examplewe may compute part of complicated calculat...
17,506
#program to show the use of 'separgument in print statement wxyz #without separator print(wx,yz#using no space as separator print(wx,yzsep=''#using comma as separator print(wx,yzsep=','#using space as separator print(wx,yzsep='#using colon as separator print(wx,yzsep=':'#using as separator print(wx,yzsep=''in [ ]runfil...
17,507
arithmetic operators different arithmetic operators like addition(+for adding two operandssubtraction (-for subtracting second operand from first multiplication(*for multiplying both operands division(/for dividing numerator by denominator modulus operator(%for determining remainder of after an integer divisionexponent...
17,508
python for beginners explanationthe first two statements prompt the user to enter two numbers when the user types the number and then presses the enter keyvalue is assigned the integer similarlythe user enters number which is stored in value laterthe different arithmetic operators produce the desired result it can be o...
17,509
#modulus and (%=assignment operator it divides the left operand with the right operand and assigns the remainder to the left operand % is equivalent to ans=value ans%=value print("the answer using modulus assignment is:",ans#exponential and (**=assignment operator it divides the left operand with the right operand and ...
17,510
#the greater than (>operator checks if the value of left operand is greater than the value of right operand if yesthen the condition becomes true print("the result of greater than operator is", > #the greater than or equal to (>=operator checks if the value of left operand is greater than or equal to the value of right...
17,511
#using "orlogical operator print("the use of or operator returns:", > or > #using "notlogical operator print("the use of not operator returns:"not >zin [ ]runfilethe use of and operator returnsfalse the use of or operator returnstrue the use of not operator returnstrue explanationin the first examplex> does not holds g...
17,512
the use of or operator returnstrue the use of or operator returnstrue the use of not operator on returnsfalse the use of not operator on returnstrue explanationthe use of "andoperation on and returns "falsesince both are not true however"xand "xreturns true since both the conditions are true similarly "yand "yreturns "...
17,513
explanationin the first example " +zand " +yare evaluated first since they are inside the parenthesis and are then multiplied to each other hencethe result is * in the second examplesincemultiplication has higher precedence than additionhence multiplication of and is done first and then added to hencethe result is + si...
17,514
by ankur patel copyright ( human ai collaborationinc all rights reserved isbn- - originally printed in the united states of america published by 'reilly mediainc gravenstein highway northsebastopolca 'reilly books may be purchased for educationalbusinessor sales promotional use online editions are also available for mo...
17,515
preface xi part fundamentals of unsupervised learning unsupervised learning in the machine learning ecosystem basic machine learning terminology rules-based vs machine learning supervised vs unsupervised the strengths and weaknesses of supervised learning the strengths and weaknesses of unsupervised learning using unsu...
17,516
end-to-end machine learning project environment setup version controlgit clone the hands-on unsupervised learning git repository scientific librariesanaconda distribution of python neural networkstensorflow and keras gradient boostingversion onexgboost gradient boostingversion twolightgbm clustering algorithms interact...
17,517
unsupervised learning using scikit-learn dimensionality reduction the motivation for dimensionality reduction the mnist digits database dimensionality reduction algorithms linear projection vs manifold learning principal component analysis pcathe concept pca in practice incremental pca sparse pca kernel pca singular va...
17,518
normal pca anomaly detection on the test set ica anomaly detection on the test set dictionary learning anomaly detection on the test set conclusion clustering mnist digits dataset data preparation clustering algorithms -means -means inertia evaluating the clustering results -means accuracy -means and the number of prin...
17,519
unsupervised learning using tensorflow and keras autoencoders neural networks tensorflow keras autoencoderthe encoder and the decoder undercomplete autoencoders overcomplete autoencoders dense vs sparse autoencoders denoising autoencoder variational autoencoder conclusion hands-on autoencoder data preparation the compo...
17,520
the power of supervised and unsupervised conclusion part iv deep unsupervised learning using tensorflow and keras recommender systems using restricted boltzmann machines boltzmann machines restricted boltzmann machines recommender systems collaborative filtering the netflix prize movielens dataset data preparation defi...
17,521
supervised only unsupervised and supervised solution conclusion generative adversarial networks gansthe concept the power of gans deep convolutional gans convolutional neural networks dcgans revisited generator of the dcgan discriminator of the dcgan discriminator and adversarial models dcgan for the mnist dataset mnis...
17,522
reinforcement learning most promising areas of unsupervised learning today the future of unsupervised learning final words index table of contents
17,523
brief history of machine learning machine learning is subfield of artificial intelligence (aiin which computers learn from data--usually to improve their performance on some narrowly defined task-without being explicitly programmed the term machine learning was coined as early as (by arthur samuela legend in the field ...
17,524
cycles around ai occurred but had very little staying power by the early sinterest in and funding for ai had hit trough ai is backbut why nowai has re-emerged with vengeance over the past two decades--first as purely academic area of interest and now as full-blown field attracting the brightest minds at both universiti...
17,525
ai is now viewed as breakthrough horizontal technologyakin to the advent of computers and smartphonesthat will have significant impact on every single industry over the next decade successful commercial applications involving machine learning include--but are certainly not limited to--optical character recognitionemail...
17,526
algorithm to train neural networks with many layerskicking off the deep learning revolution netflix launches the netflix prize competitionwith one million dollar pursechallenging teams to use machine learning to improve its recommendation system' accuracy by at least team won the prize in ai achieves superhuman perform...
17,527
the world google deepmind' alphago beats world-class professional fan hui at the game go in alphago defeats lee sedoland in alphago defeats ke jie in new version called alphago zero defeats the previous alphago version to zero alphago zero incorporates unsupervised learning techniques and masters go just by playing its...
17,528
unsupervised learning is one of the trendiest topics in ai today the book' goal is to outline the concepts and tools required for you to develop the intuition necessary for applying this technology to everyday problems that you work on in other wordsthis is an applied bookone that will allow you to build real-world sys...
17,529
refer to the scikit-learn documentation (stable/modules/classes htmlpart iiiunsupervised learning using tensorflow and keras representation learning and automatic feature extractionautoencodersand semisupervised learning part ivdeep unsupervised learning using tensorflow and keras restricted boltzmann machinesdeep beli...
17,530
using code examples supplemental material (code examplesetc is available for download on github (this book is here to help you get your job done in generalif example code is offered with this bookyou may use it in your programs and documentation you do not need to contact us for permission unless you're reproducing sig...
17,531
please address comments and questions concerning this book to the publishero'reilly mediainc gravenstein highway north sebastopolca (in the united states or canada(international or local(faxwe have web page for this bookwhere we list errataexamplesand any additional information you can access this page at to comment or...
17,532
fundamentals of unsupervised learning to startlet' explore the current machine learning ecosystem and where unsupervised learning fits in we will also build machine learning project from scratch to cover basics such as setting up the programming environmentacquiring and preparing dataexploring dataselecting machine lea...
17,533
unsupervised learning in the machine learning ecosystem most of human and animal learning is unsupervised learning if intelligence was cakeunsupervised learning would be the cakesupervised learning would be the icing on the cakeand reinforcement learning would be the cherry on the cake we know how to make the icing and...
17,534
dependent variableor response variable (or class since this is classification problemthe set of examples the ai trains on is known as the training setand each individual example is called training instance or sample during the trainingthe ai is attempting to minimize its cost function or error rateor framed more positi...
17,535
unless the car can learn and adapt on its own based on its experience we could also use machine learning systems as an exploration or data discovery tool to gain deeper insight into the problem we are trying to solve for examplein the email spam filter examplewe can learn which words or phrases are most predictive of s...
17,536
image classification system as the supervised learning ai trains on the datait will be able to measure its performance (via cost functionby comparing its predicted image label with the true image label that we have on file the ai will explicitly try to minimize this cost function such that its error on never-before-see...
17,537
togetheretc of coursethe unsupervised learning ai itself cannot label these groups as "chairsor "dogsbut now that similar images are grouped togetherhumans have much simpler labeling task instead of labeling millions of images by handhumans can manually label all the distinct groupsand the labels will apply to all the ...
17,538
of datathe rocket ship cannot fly but not all data is created equal to use supervised algorithmswe need lots of labeled datawhich is hard and costly to generate with unsupervised learningwe can automatically label unlabeled examples here is how it would workwe would cluster all the examples and then apply the labels fr...
17,539
rate points and build function approximation to make good decisions when the features are very numerousthis search becomes very expensiveboth from time and compute perspective in some casesit may be impossible to find good solution fast enough this problem is known as the curse of dimensionalityand unsupervised learnin...
17,540
before we delve into unsupervised learning systemslet' take look at supervised learning algorithms and how they work this will help frame where unsupervised learning fits within the machine learning ecosystem in supervised learningthere are two major types of problemsclassification and regression in classificationthe a...
17,541
algorithms (including some real-world applicationsbefore doing the same for unsupervised algorithms linear methods the most basic supervised learning algorithms model simple linear relationship between the input features and the output variable that we wish to predict linear regression the simplest of all the algorithm...
17,542
the simplest classification algorithm is logistic regressionwhich is also linear method but the predictions are transformed using the logistic function the outputs of this transformation are class probabilities--in other wordsthe probabilities that the instance belongs to the various classeswhere the sum of the probabi...
17,543
knn does poorly when the number of observations and features grow knn becomes computationally inefficient in this highly populatedhigh-dimensional space since it needs to calculate distances from the new point to many nearby labeled points in order to predict labels it cannot rely on an efficient model with reduced num...
17,544
we can improve overfitting further by sampling not only the instances but also the predictors with random forestswe take multiple random samples of instances from the training data like we do in baggingbutfor each split in each decision treewe make the split based not on all the predictors but rather random sample of t...
17,545
boundary-defining points of another label should be maximized as much as possible alsothe boundaries do not have to be linear--we can use nonlinear kernels to more flexibly separate the data neural networks we can learn representations of the data using neural networkswhich are composed of an input layerseveral hidden ...
17,546
less useful in explaining the dataset for other featuresthe values might vary considerably--these features are worth exploring in greater detail since they will be better at helping the model we design separate the data in pcathe algorithm finds low-dimensional representation of the data while retaining as much of the ...
17,547
instances are modeled further away dictionary learning an approach known as dictionary learning involves learning the sparse representation of the underlying data these representative elements are simplebinary vectors (zeros and ones)and each instance in the dataset can be reconstructed as weighted sum of the represent...
17,548
smaller set of just the most important features from herewe can run other unsupervised learning algorithms on this smaller set of features to find interesting patterns in the data (see the next section on clustering)orif we have labelswe can speed up the training cycle of supervised learning algorithms by feeding in th...
17,549
clustering then joins the leaves together--as we move vertically up the upside-down tree--based on how similar they are to each other the instances (or groups of instancesthat are most similar to each other are joined soonerwhile the instances that are not as similar are joined later with this iterative processall the ...
17,550
to generate new feature representationswe can use feedforwardnonrecurrent neural network to perform representation learningwhere the number of nodes in the output layer matches the number of nodes in the input layer this neural network is known as an autoencoder and effectively reconstructs the original featureslearnin...
17,551
occur in the process firstthe gradient of the error function may become very smallandsince backpropagation relies on multiplying these small weights togetherthe weights of the network may update very slowly or not at allpreventing proper training of the network this is known as the vanishing gradient problem conversely...
17,552
one applied example of unsupervised pretraining is the restricted boltzmann machine (rbm) shallowtwo-layer neural network the first layer is the input layerand the second layer is the hidden layer each node is connected to every node in the other layerbut nodes are not connected to nodes of the same layer--this is wher...
17,553
underlying structure of the true data distribution even when there are no labels gans learn the underlying structure in the data through the training process and efficiently capture the structure using smallmanageable number of parameters this process is similar to the representation learning that occurs in deep learni...
17,554
sensory data as input and no prior knowledge of the rules of the games in deepmind again captured the imagination of the machine learning community--this time the deepmind reinforcement learning-based ai agent alphago beat lee sedolone of the world' best go players these successes have cemented reinforcement learning a...
17,555
solved using hybrid of supervised and unsupervised learning known as semisupervised learning we will explore this area in greater detail later in the book successful applications of unsupervised learning in the last ten yearsmost successful commercial applications of machine learning have come from the supervised learn...
17,556
as tool to understand biological systems within this large fieldluis works in bioimage informaticswhich is the application of machine learning techniques to the analysis of images of biological specimens his main focus is on the processing of large scale image data with robotic microscopesit is possible to acquire hund...
17,557
matthieu brucher holds an engineering degree from the ecole superieure 'electricite (informationsignalsmeasures)franceand has phd in unsupervised manifold learning from the universite de strasbourgfrance he currently holds an hpc software developer position in an oil company and works on next generation reservoir simul...
17,558
molecular and cell biology at the university of melbourne he is currently research fellow at nanyang technological universitysingaporeand an honorary fellow at the university of melbourneaustralia he co-edits the python papers and has co-founded the python user group (singapore)where he has served as vice president sin...
17,559
support filesebooksdiscount offers and more you might want to visit www packtpub com for support files and downloads related to your book did you know that packt offers ebook versions of every book publishedwith pdf and epub files availableyou can upgrade to the ebook version at www packtpub com and as print book custo...
17,560
preface getting started with python machine learning machine learning and python the dream team what the book will teach you (and what it will notwhat to do when you are stuck getting started introduction to numpyscipyand matplotlib installing python chewing data efficiently with numpy and intelligently with scipy lear...
17,561
building more complex classifiers more complex dataset and more complex classifier learning about the seeds dataset features and feature engineering nearest neighbor classification binary and multiclass classification summary clustering finding related posts measuring the relatedness of posts how not to do it how to do...
17,562
tuning the instance tuning the classifier fetching the data slimming the data down to chewable chunks preselection and processing of attributes defining what is good answer creating our first classifier starting with the -nearest neighbor (knnalgorithm engineering the features training the classifier measuring the clas...
17,563
successfully cheating using sentiwordnet our first estimator putting everything together summary regression recommendations regression recommendations improved classification iii music genre classification predicting house prices with regression multidimensional regression cross-validation for regression penalized regr...
17,564
improving classification performance with mel frequency cepstral coefficients summary computer vision pattern recognition introducing image processing loading and displaying images basic image processing thresholding gaussian blurring filtering for different effects adding salt and pepper noise pattern recognition comp...
17,565
using amazon web services (awscreating your first machines automating the generation of clusters with starcluster summary installing python packages on amazon linux running jug on our cloud machine appendixwhere to learn more about machine learning index online courses books & sites blogs data sources getting competiti...
17,566
you could argue that it is fortunate coincidence that you are holding this book in your hands (or your -book readerafter allthere are millions of books printed every yearwhich are read by millions of readersand then there is this book read by you you could also argue that couple of machine learning algorithms played th...
17,567
topic modelingtakes us beyond assigning each post to single cluster and shows us how assigning them to several topics as real text can deal with multiple topics classification detecting poor answersexplains how to use logistic regression to find whether user' answer to question is good or bad behind the sceneswe will l...
17,568
what you need for this book this book assumes you know python and how to install library using easy_install or pip we do not rely on any advanced mathematics such as calculus or matrix algebra to summarize itwe are using the following versions throughout this bookbut you should be fine with any more recent onepython nu...
17,569
when we wish to draw your attention to particular part of code blockthe relevant lines or items are set in bolddef nn_movie(movie_likenessreviewsuidmid)likes movie_likeness[midargsort(reverse the sorting so that most alike are in beginning likes likes[::- returns the rating for the most similar movie available for ell ...
17,570
downloading the example code you can download the example code files for all packt books you have purchased from your account at elsewhereyou can visit have the files -mailed directly to you errata although we have taken every care to ensure the accuracy of our contentmistakes do happen if you find mistake in one of ou...
17,571
machine learning machine learning (mlteaches machines how to carry out tasks by themselves it is that simple the complexity comes with the detailsand that is most likely the reason you are reading this book maybe you have too much data and too little insightand you hoped that using machine learning algorithms will help...
17,572
machine learning and python the dream team the goal of machine learning is to teach machines (softwareto carry out tasks by providing them with couple of examples (how to do or not do tasklet us assume that each morning when you turn on your computeryou perform the same task of moving -mails around so that only those -...
17,573
what the book will teach you (and what it will notthis book will give you broad overview of the types of learning algorithms that are currently used in the diverse fields of machine learning and what to watch out for when applying them from our own experiencehoweverwe know that doing the "coolstuff--using and tweaking ...
17,574
choosing the right learning algorithm is not simply shootout of the three or four that are in your toolbox (there will be more algorithms in your toolbox that you will seeit is more of thoughtful process of weighing different performance and functional requirements do you need fast results and are willing to sacrifice ...
17,575
in such situationthere are many different ways to get help most likelyyour problem will already have been raised and solved in the following excellent & siteslearning topics for almost every questionit contains above-average answers from machine learning experts even if you don' have any questionsit is good habit to ch...
17,576
introduction to numpyscipyand matplotlib before we can talk about concrete machine learning algorithmswe have to talk about how best to store the data we will chew through this is important as the most advanced learning algorithm will not be of any help to us if they will never finish this may be simply because accessi...
17,577
you will also find the book numpy beginner' guide second editionivan idrispackt publishing very valuable additional tutorial style guides are at scipy-lectures github comyou may also visit the official scipy tutorial at in this bookwe will use numpy version and scipy version learning numpy so let us import numpy and pl...
17,578
the funny thing starts when we realize just how much the numpy package is optimized for exampleit avoids copies wherever possible [ ][ ]= array([ ][ ] ]] array( ]in this casewe have modified the value to in band we can immediately see the same change reflected in as well keep that in mind whenever you need true copy re...
17,579
of courseby using numpy arrays we sacrifice the agility python lists offer simple operations like adding or removing are bit complex for numpy arrays luckilywe have both at our disposaland we will use the right one for the task at hand indexing part of the power of numpy comes from the versatile ways in which its array...
17,580
[~np isnan( )array( ]np mean( [~np isnan( )] comparing runtime behaviors let us compare the runtime behavior of numpy with normal python lists in the following codewe will calculate the sum of all squared numbers of to and see how much time the calculation will take we do it times and report the total time so that our ...
17,581
howeverthe speed comes at price using numpy arrayswe no longer have the incredible flexibility of python listswhich can hold basically anything numpy arrays always have only one datatype np array([ , , ] dtype dtype('int 'if we try to use elements of different typesnumpy will do its best to coerce them to the most reas...
17,582
scipy package functionality constants physical and mathematical constants conversion methods fftpack discrete fourier transform algorithms integrate integration routines interpolate interpolation (linearcubicand so onio data input and output linalg linear algebra routines using the optimized blas and lapack libraries m...
17,583
our first (tinymachine learning application let us get our hands dirty and have look at our hypothetical web startupmlaaswhich sells the service of providing machine learning algorithms via http with the increasing success of our companythe demand for better infrastructure also increases to serve all incoming web reque...
17,584
using scipy' genfromtxt()we can easily read in the data import scipy as sp data sp genfromtxt("web_traffic tsv"delimiter="\ "we have to specify tab as the delimiter so that the columns are correctly determined quick check shows that we have correctly read in the data print(data[: ][ + + + nan + + + + + + + + + + + + + ...
17,585
we are missing only out of entriesso we can afford to remove them remember that we can index scipy array with another array sp isnan(yreturns an array of booleans indicating whether an entry is not number using ~we logically negate that array so that we choose only those elements from and where does contain valid numbe...
17,586
choosing the right model and learning algorithm now that we have first impression of the datawe return to the initial questionhow long will our server handle the incoming web trafficto answer this we have tofind the real model behind the noisy data points use the model to extrapolate into the future to find the point i...
17,587
print(res + this means that the best straight line fit is the following functionf( we then use poly (to create model function from the model parameters sp poly (fp print(error( xy) we have used full=true to retrieve more details on the fitting process normallywe would not need itin which case only the model parameters ...
17,588
it seems like the first four weeks are not that far offalthough we clearly see that there is something wrong with our initial assumption that the underlying model is straight line plushow good or bad actually is the error of , , the absolute value of the error is seldom of use in isolation howeverwhen comparing two com...
17,589
the error is , , which is almost half the error of the straight-line model this is goodhoweverit comes with price we now have more complex functionmeaning that we have one more parameter to tune inside polyfit(the fitted polynomial is as followsf( ** soif more complexity gives better resultswhy not increase the complex...
17,590
at this pointwe have the following choicesselecting one of the fitted polynomial models switching to another more complex model classsplinesthinking differently about the data and starting again of the five fitted modelsthe first-order model clearly is too simpleand the models of order and are clearly overfitting only ...
17,591
clearlythe combination of these two lines seems to be much better fit to the data than anything we have modeled before but stillthe combined error is higher than the higher-order polynomials can we trust the error at the endasked differentlywhy do we trust the straight line fitted only at the last week of our data more...
17,592
the models of degree and don' seem to expect bright future for our startup they tried so hard to model the given data correctly that they are clearly useless to extrapolate further this is called overfitting on the other handthe lower-degree models do not seem to be capable of capturing the data properly this is called...
17,593
although we cannot look into the futurewe can and should simulate similar effect by holding out part of our data let us removefor instancea certain percentage of the data and train on the remaining one then we use the hold-out data to calculate the error as the model has been trained not knowing the hold-out datawe sho...
17,594
answering our initial question finallywe have arrived at model that we think represents the underlying process bestit is now simple task of finding out when our infrastructure will reach , requests per hour we have to calculate when our model function reaches the value , having polynomial of degree we could simply comp...
17,595
summary congratulationsyou just learned two important things of thesethe most important one is that as typical machine learning operatoryou will spend most of your time understanding and refining the data--exactly what we just did in our first tiny machine learning example and we hope that the example helped you to sta...
17,596
real-world examples can machine distinguish between flower species based on imagesfrom machine learning perspectivewe approach this problem by having the machine learn how to perform this task based on examples of each species so that it can classify images where the species are not marked this process is called classi...
17,597
in generalwe will call any measurement from our data as features additionallyfor each plantthe species was recorded the question now isif we saw new flower out in the fieldcould we make good prediction about its species from its measurementsthis is the supervised learning or classification problemgiven labeled examples...
17,598
we are using matplotlibit is the most well-known plotting package for python we present the code to generate the top-left plot the code for the other plots is similar to the following codefrom matplotlib import pyplot as plt from sklearn datasets import load_iris import numpy as np we load the data with load_iris from ...
17,599
this is our first modeland it works very well in that it separates the iris setosa flowers from the other two species without making any mistakes what we had here was simple structurea simple threshold on one of the dimensions then we searched for the best dimension threshold we performed this visually and with some ca...