id int64 0 25.6k | text stringlengths 0 4.59k |
|---|---|
17,800 | your algorithms cannot assume that the entire data is in ram managing data becomes major task in itself using computer clusters or multicore machines becomes necessity and not luxury this will focus on this last piece of the puzzlehow to use multiple cores (either on the same machine or on separate machinesto speed up ... |
17,801 | task could be "call double with argument another task would be "call double with argument using jugswe can build these tasks as followsfrom jug import task task(double task(double save this to file called jugfile py (which is just regular python filenowwe can run jug execute to run the tasks this is something you run o... |
17,802 | sleep( return * @taskgenerator def add(ab)return @taskgenerator def print_final_result(onamevalue)with open(oname' 'as outputprint >>output"final result:"value double( double(yy double( double( print_final_result('output txt'add( , )except for the use of taskgeneratorthe preceding code could have been standard python f... |
17,803 | now we run jug status againwe can see that the two initial double operators are running at the same time after about secondsthe whole process will finish and the output txt file will be written by the wayif your file was called anything other than jugfile pyyou would then have to specify it explicitly on the command li... |
17,804 | looking under the hood how does jug workat the basic levelit is very simplea task is function plus its argument its arguments may be either values or other tasks if task takes other tasksthere is dependency between the two tasks (and the second one cannot be run until the results of the first task are availablebased on... |
17,805 | jug is also specially optimized to work with numpy arrays sowhenever your tasks return or receive numpy arraysyou are taking advantage of this optimization jug is another piece of this ecosystem where everything works together we will now look back at computer vision-pattern recognition finding related posts we learned... |
17,806 | def write_result(ofnamevalue)with open(ofname' 'as outprint >>out"result is:"value write_result('output txt'resone small inconvenience of using jug is that we must always write functions to output the results to files as shown in the preceding examples this is small price to pay for the extra convenience of using jug n... |
17,807 | there are three modes of usea reserved modewhereby you prepay to have cheaper per-hour accessa fixed per-hour rateand variable rate which depends on the overall compute market (when there is less demandthe costs are lowerwhen there is more demandthe prices go upfor testingyou can use single machine in the free tier thi... |
17,808 | amazon web services is very large topicand there are various books exclusively available which cover aws entirely the purpose of this is to give you an overall impression of what is available and what is possible with aws in the practical spirit of this bookwe do this by working through examplesbut we will not exhaust ... |
17,809 | we pick and click on ec (the second element on the leftmost column--this panel is shown as it was when this book was writtenamazon regularly makes minor changesso you may see something slightly differentwe now see the ec management console as shown in the following screenshotin the top-right corneryou can pick your reg... |
17,810 | in ec parlancea running server is called an instance so nowwe want to select launch instance nowfollow the classic wizard select the amazon linux option (if you are familiar with one of the other offered linux distributionssuch as red hatsuseor ubuntuyou can also select one of thosebut the configurations will be slight... |
17,811 | thereforewe will be calling the ssh command and passing it the key files that we downloaded earlier as the identity (using the - optionwe are logging in as user ec -user at the machine with the address ec- - us-west- conompute amazonaws com this address willof coursebe different in your case if you choose another distr... |
17,812 | in this systempip is installed as python-pip for conveniencewe will use pip to upgrade itself we will then use pip to install the necessary packagessudo pip-python install - pip sudo pip install scikit-learn jug mahotas at this pointyou can install any other package you like using pip running jug on our cloud machine w... |
17,813 | you can assign fixed ip to an instance using amazon' elastic ips functionalitywhich you will find on the left-hand side of the ec console this is useful if you find yourself creating and modifying instances very often there is small cost associated with this feature with eight coresyou can run eight jug processes simul... |
17,814 | keyskeysand more keys there are three completely different types of keys that are important when dealing with awsa standard username/password combinationwhich you use to log in to the website the ssh key systemwhich is public/private key system implemented with fileswith your public key fileyou can log in to remote mac... |
17,815 | we need to create new ssh key with the followingstarcluster createkey mykey - ssh/mykey rsa now that we have configured node cluster and set up the keyslet' try it out starcluster start mycluster this may take few minutes as it allocates new machines why when our cluster is only nodeswe always have master node all of t... |
17,816 | we can use the same jugfile py system as beforeexcept that nowinstead of running it directly on the masterwe schedule it on the cluster firstwrite very simple wrapper script#!/usr/bin/env bash jug execute jugfile py call it using run-jugfile sh and use chmod + run-jugfile sh to give it an executable permissionfor in 's... |
17,817 | summary we saw how to use juga little python frameworkto manage computations in way that takes advantage of multiple cores or multiple machines although this framework is genericit was built specifically to address the data analysis needs of its author (who is also an author of this bookthereforeit has several aspects ... |
17,818 | about machine learning we are at the end of our book and now take moment to look at what else is out there that could be useful for our readers there are many wonderful resources out there to learn more about machine learning (way too much to cover them all hereour list can therefore represent only small and very biase... |
17,819 | if you want to move beyond an introduction and learn all the gory mathematical detailsthen machine learninga probabilistic perspectivek murphythe mit pressis an excellent option it is very recent (published in )and contains the cutting edge of ml research this , page book can also serve as referenceas very little of ma... |
17,820 | machined learnings at degdeg flowingdata at degdeg the average pace is one per monthcovering theoretical discussions of practical problems although being more of statistics blogthe posts often intersect with machine learning simply statistics at degdeg the average pace is one per daywith the posts revolving more around... |
17,821 | of coursewinning something is nicebut you can gain lot of useful experience just by participating soyou have to stay tunedespecially after the competition is over and participants start sharing their approaches in the forum most of the timewinning is not about developing new algorithmit is about cleverly preprocessingn... |
17,822 | acceptedanswerid attribute additive smoothing add-one smoothing advanced baskets analysis amazon linux python packagesinstalling on amazon regions amazon web services see aws apriori algorithm area under curve (auc as keypoint detection associated press (ap association rule mining - association rules attributes presele... |
17,823 | building evaluating - loss function search procedure structure classification performance improvingwith mel frequency cepstral coefficients - classifier buildingfft used classesusing creating - integratinginto site parameterstuning - performanceimproving performancemeasuring slimming training classifierclassy answers t... |
17,824 | false negative false positive fast fourier transform see fft fast fourier transformation feature engineering feature extraction about lda pca features about computingfrom images designing - engineering selecting writing - feature selection feature selection methods fft usedfor building classifier fftpack package filter... |
17,825 | jugfile jugdata directory jugfile py file jug invalidate jug status --cache kaggle url keys kmeans - -means clustering -nearest neighbor (knnalgorithm labels laplace smoothing lasso about usingin scikit-learn latent dirichlet allocation (lda learning algorithm selecting - levenshtein distance lidstone smoothing lift li... |
17,826 | using movie neighborsviewing multiple methodscombining - mp files convertinginto wave format multiclass classification multiclass problems confusion matrixused for accuracy measurement - multidimensional regression multidimensional scaling see mds multinomialnb music decomposinginto sine wave components music data fetc... |
17,827 | sketching pearsonr(function penalized regression elastic net penalty penalty lasso model penn treebank project url greater than scenarios about hyperparameterssetting predictionrating - recommendationsrating - text example png polyfit(function portable batch system (pbs postclassification problem logistic regressionapp... |
17,828 | for paula,thomas and his brother on the way lib fl ff |
17,829 | introduction part ithe python language tutorial introduction lexical conventions and syntax types and objects operators and expressions program structure and control flow functions and functional programming classes and object-oriented programming modulespackagesand distribution input and output execution environment t... |
17,830 | introduction ithe python language tutorial introduction running python variables and arithmetic expressions conditionals file input and output strings lists tuples sets dictionaries iteration and looping functions generators coroutines objects and classes exceptions modules getting help lexical conventions and syntax l... |
17,831 | contents first-class objects built-in types for representing data the none type numeric types sequence types mapping types set types built-in types for representing program structure callable types classestypesand instances modules built-in types for interpreter internals code objects frame objects traceback objects ge... |
17,832 | the attribute operator the function call (operator conversion functions boolean expressions and truth values object equality and identity order of evaluation conditional expressions program structure and control flow program structure and execution conditional execution loops and iteration exceptions built-in exception... |
17,833 | contents polymorphism dynamic binding and duck typing static methods and class methods properties descriptors data encapsulation and private attributes object memory management object representation and attribute binding _slots_ operator overloading types and class membership tests abstract base classes metaclasses cla... |
17,834 | execution environment interpreter options and environment interactive sessions xi launching python applications site configuration files per-user site packages enabling future features program termination testingdebuggingprofilingand tuning documentation strings and the doctest module unit testing and the unittest modu... |
17,835 | xii gc notes inspect marshal notes pickle notes sys variables functions traceback types notes warnings notes weakref example notes mathematics decimal decimal objects context objects functions and constants examples notes fractions math notes numbers notes random seeding and initialization random integers random sequen... |
17,836 | data structuresalgorithmsand code simplification abc array xiii notes bisect collections deque and defaultdict named tuples abstract base classes contextlib functools heapq itertools examples operator string and text handling codecs low-level codecs interface / -related functions useful constants standard encodings re ... |
17,837 | xiv format codes notes unicodedata python database access relational database api specification connections cursors forming queries type objects error handling multithreading mapping results into dictionaries database api extensions sqlite module module-level functions connection objects cursors and basic operations db... |
17,838 | operating system services commands notes xv configparserconfigparser the configparser class example notes datetime date objects time objects datetime objects timedelta objects mathematical operations involving dates tzinfo objects date and time parsing errno posix error codes windows error codes fcntl example notes io ... |
17,839 | contents mmap notes msvcrt optparse example notes os process environment file creation and file descriptors files and directories process management system configuration exceptions os path signal example notes subprocess examples notes time notes winreg notes threads and concurrency basic concepts concurrent programmin... |
17,840 | lock objects rlock xvii semaphore and bounded semaphore events condition variables working with locks thread termination and suspension utility functions the global interpreter lock programming with threads queuequeue queue example with threads coroutines and microthreading network programming and sockets network progr... |
17,841 | xviii internet application programming ftplib example http package http client (httplib http server (basehttpservercgihttpserversimplehttpserver http cookies (cookie http cookiejar (cookielibsmtplib example urllib package urllib request (urllib urllib response urllib parse urllib error urllib robotparser (robotparser n... |
17,842 | email package xix parsing email composing email notes hashlib hmac example htmlparser example mimetypes json quopri xml package xml example document xml dom minidom xml etree elementtree xml sax xml sax saxutils miscellaneous library modules python services string processing operating system modules network internet da... |
17,843 | contents adding values to module error handling reference counting threads embedding the python interpreter an embedding template compilation and linking basic interpreter operation and setup accessing python from converting python objects to ctypes loading shared libraries foreign functions datatypes calling foreign f... |
17,844 | print(and exec(functions use of iterators and views integers and integer division comparisons xxi iterators and generators file namesargumentsand environment variables library reorganization absolute imports code migration and to porting code to python providing test coverage using the to tool practical porting strateg... |
17,845 | david beazley is long-time python enthusiasthaving been involved with the python community since he is probably best known for his work on swiga popular software package for integrating / +programs with other programming languagesincluding pythonperlruby,tcland java he has also written number of other programming tools... |
17,846 | this book would not be possible without the support of many people first and foremosti' like to thank noah gift for jumping into the project and providing his amazing feedback on the fourth edition kurt grandis also provided useful comments for many ' also like to acknowledge past technical reviewers timothy boronczykp... |
17,847 | as the reader of this bookyou are our most important critic and commentator we value your opinion and want to know what we're doing rightwhat we could do betterwhat areas you' like to see us publish inand any other words of wisdom you're willing to pass our way you can email or write me directly to let me know what you... |
17,848 | his book is intended to be concise reference to the python programming language although an experienced programmer will probably be able to learn python from this bookit' not intended to be an extended tutorial or treatise on how to program ratherthe goal is to present the core python languageand the most essential par... |
17,849 | introduction to include outside reference material this is especially true for low-level system and networking modules in which effective use of module normally relies on myriad of options listed in manuals and outside references in additionin order to produce more concise referencea number of deprecated and relatively... |
17,850 | the python language tutorial introduction lexical conventions and syntax types and objects operators and expressions program structure and control flow functions and functional programming classes and object-oriented programming modulespackagesand distribution input and output execution environment testingdebuggingprof... |
17,851 | lib fl ff |
17,852 | tutorial introduction his provides quick introduction to python the goal is to illustrate most of python' essential features without getting too bogged down in special rules or details to do thisthe briefly covers basic concepts such as variablesexpressionscontrol flowfunctionsgeneratorsclassesand input/output this is ... |
17,853 | tutorial introduction note if you try the preceding example and it fails with syntaxerroryou are probably using python if this is the caseyou can continue to follow along with this but be aware that the print statement turned into function in python simply add parentheses around the items to be printed in the examples ... |
17,854 | the interpreter runs statements until it reaches the end of the input file if it' running interactivelyyou can exit the interpreter by typing the eof (end of filecharacter or by selecting exit from pull-down menu of python ide on unixeof is ctrl+don windowsit' ctrl+ program can request to exit by raising the systemexit... |
17,855 | tutorial introduction the while statement tests the conditional expression that immediately follows if the tested statement is truethe body of the while statement executes the condition is then retested and the body executed again until the condition becomes false because the body of the loop is denoted by indentationt... |
17,856 | conditionals the if and else statements can perform simple tests here' an exampleif bprint "computer says yeselseprint "computer says nothe bodies of the if and else clauses are denoted by indentation the else clause is optional to create an empty clauseuse the pass statementas followsif bpass do nothing elseprint "com... |
17,857 | tutorial introduction file input and output the following program opens file and reads its contents line by linef open("foo txt"line readline(while lineprint lineprint(line,end=''line readline( close(returns file object invokes readline(method on file trailing ',omits newline character use in python the open(function r... |
17,858 | in python the raw_input(function is called input()but it works in exactly the same manner strings to create string literalsenclose them in singledoubleor triple quotes as followsa "hello worldb 'python is groovyc """computer says 'no'""the same type of quote used to start string must be used to terminate it triplequote... |
17,859 | tutorial introduction although str(and repr(both create stringstheir output is usually slightly different str(produces the output that you get when you use the print statementwhereas repr(creates string that you type into program to exactly represent the value of an object for examplex str( ' repr( ' the inexact repres... |
17,860 | lists can contain any kind of python objectincluding other listsas in the following examplea [ ,"dave", ["mark" [ , ]] items contained in nested lists are accessed by applying more than one indexing operationas followsa[ [ ][ [ ][ ][ returns "davereturns returns the program in listing illustrates few more advanced feat... |
17,861 | tutorial introduction tuples to create simple data structuresyou can pack collection of values together into single object using tuple you create tuple by enclosing group of values in parentheses like thisstock ('goog' address ('www python org' person (first_namelast_namephonepython often recognizes that tuple is inten... |
17,862 | looks like two-dimension array of rows and columns each row is represented by tuple and can be accessed as followsportfolio[ ('goog' portfolio[ ('msft' individual items of data can be accessed like thisportfolio[ ][ portfolio[ ][ here' an easy way to loop over all of the records and expand fields into set of variablest... |
17,863 | tutorial introduction dictionaries dictionary is an associative array or hash table that contains objects indexed by keys you create dictionary by enclosing the values in curly braces (})like thisstock "name"goog""shares "price to access members of dictionaryuse the key-indexing operator as followsname stock["name"valu... |
17,864 | iteration and looping the most widely used looping construct is the for statementwhich is used to iterate over collection of items iteration is one of python' richest features howeverthe most common form of iteration is to simply loop over all the members of sequence such as stringlistor tuple here' an examplefor in [ ... |
17,865 | tutorial introduction for line in fprint linethe for loop is one of python' most powerful language features because you can create custom iterator objects and generator functions that supply it with sequences of values more details about iterators and generators can be found later in this and in "functions and function... |
17,866 | generators instead of returning single valuea function can generate an entire sequence of results if it uses the yield statement for exampledef countdown( )print "counting down!while yield generate value (nn - any function that uses yield is known as generator calling generator function creates an object that produces ... |
17,867 | tutorial introduction here' an example of hooking both of these generators together to create simple processing pipelinea python implementation of unix "tail - grep pythonwwwlog tail(open("access-log")pylines grep(wwwlog,"python"for line in pylinesprint linea subtle aspect of generators is that they are often mixed tog... |
17,868 | prep all of the matchers by calling next(for in matchersm next(feed an active log file into all matchers note for this to worka web server must be actively writing data to the log wwwlog tail(open("access-log")for line in wwwlogfor in matchersm send(linesend data into each matcher coroutine further details about corout... |
17,869 | tutorial introduction method always refers to the object itself by conventionself is the name used for this argument all operations involving the attributes of an object must explicitly refer to the self variable methods with leading and trailing double underscores are special methods for example_ _init_ is used to ini... |
17,870 | if an ioerror occursdetails concerning the cause of the error are placed in and control passes to the code in the except block if some other kind of exception is raisedit' passed to the enclosing code block (if anyif no errors occurthe code in the except block is ignored when an exception is handledprogram execution re... |
17,871 | tutorial introduction the import statement creates new namespace and executes all the statements in the associated py file within that namespace to access the contents of the namespace after importsimply use the name of the module as prefixas in div divide(in the preceding example if you want to import module using dif... |
17,872 | lexical conventions and syntax his describes the syntactic and lexical conventions of python program topics include line structuregrouping of statementsreserved wordsliteralsoperatorstokensand source code encoding line structure and indentation each statement in program is terminated with newline long statements can sp... |
17,873 | lexical conventions and syntax although tabs can be used for indentationthis practice is discouraged the use of spaces is universally preferred (and encouragedby the python programming community when tab characters are encounteredthey're converted into the number of spaces required to move to the next column that' mult... |
17,874 | floating-point numbers complex numbers the identifiers true and false are interpreted as boolean values with the integer values of and respectively number such as is interpreted as decimal integer to specify an integer using octalhexadecimalor binary notationprecede the value with xor brespectively (for example fea or ... |
17,875 | table continued character description \ \ \ line feed vertical tab horizontal tab carriage return form feed octal value (\ to \ unicode character (\ to \uffffunicode character (\ to \uffffffffunicode character name hexadecimal value (\ to \xff\ \ \ooo \uxxxx \uxxxxxxxx \ {charname\xhh the escape codes \ooo and \ are us... |
17,876 | for an authoritative reference on code points and character namesconsult optionallyyou can precede string literal with an or rsuch as in '\dthese strings are known as raw strings because all their backslash characters are left intact--that isthe string literally contains the enclosed textincluding the backslashes the m... |
17,877 | operatorsdelimitersand special symbols the following operators are recognized-*/*//<%/>**=&<!|>^+>><<the following tokens serve as delimiters for expressionslistsdictionariesand various parts of statementfor examplethe equal (=character serves as delimiter between the name and value of an assignmentwhereas the comma (,... |
17,878 | more than one decorator can be usedbut each one must be on separate line here' an example@foo @bar def spam()pass more information about decorators can be found in "functions and functional programming,and "classes and object-oriented programming source code encoding python source programs are normally written in stand... |
17,879 | lib fl ff |
17,880 | types and objects ll the data stored in python program is built around the concept of an object objects include fundamental data types such as numbersstringslistsand dictionaries howeverit' also possible to create user-defined objects in the form of classes in additionmost objects related to program structure and the i... |
17,881 | types and objects is operator compares the identity of two objects the built-in function type(returns the type of an object here' an example of different ways you might compare two objectscompare two objects def compare( , )if is ba and are the same object statements if =ba and have the same value statements if type(ai... |
17,882 | this example creates single object containing the value is merely name that refers to the newly created object when is assigned ab becomes new name for the same object and the object' reference count increases likewisewhen you place into listthe object' reference count increases again throughout the exampleonly one obj... |
17,883 | types and objects [ - [ - change an element in notice how also changed because and refer to the same object in this examplea change made to one of the variables is reflected in the other to avoid thisyou have to create copy of an object rather than new reference two types of copy operations are applied to container obj... |
17,884 | the first-class nature of objects can be seen by adding some more unusual items to this dictionary here are some examplesitems["func"abs import math items["mod"math items["error"valueerror nums [ , , , items["append"nums append add the abs(function add module add an exception type add method of another object in this e... |
17,885 | table built-in types for data representation type category type name description none numbers type(noneint long the null object none integer arbitrary-precision integer (python onlyfloating point complex number boolean (true or falsecharacter string unicode character string (python onlylist tuple range of integers crea... |
17,886 | - to this is the same as the double type in python doesn' support -bit single-precision floating-point numbers if precise control over the space and precision of numbers is an issue in your programconsider using the numpy extension (which can be found at complex numbers are represented as pair of floating-point numbers... |
17,887 | table continued item description len(smin(smax(snumber of elements in minimum value in maximum value in sum of items in checks whether all items in are true checks whether any item in is true sum( [,initial]all(sany(stable operations applicable to mutable sequences item description [iv [ :jt [ : :stridet del [idel [ :j... |
17,888 | table method continued description index( [,start [,stop]]returns the smallest where [ ]== start and stop optionally specify the starting and ending index for the search insert( ,xinserts at index pop([ ]returns the element and removes it from the list if is omittedthe last element is returned remove(xsearches for and ... |
17,889 | may be given negative valuesin which case the index is taken from the end of the string the translate(method is used to perform advanced character substitutions such as quickly stripping all control characters out of string as an argumentit accepts translation table containing one-to-one mapping of characters in the or... |
17,890 | table continued method description format(*args**kwargss index(sub [start [,end]]formats finds the first occurrence of the specified substring sub or raises an error checks whether all characters are alphanumeric checks whether all characters are alphabetic checks whether all characters are digits checks whether all ch... |
17,891 | table continued splits string into list of lines if keepends is trailing newlines are preserved startswith(prefix [,start [,end]]checks whether string starts with prefix strip([chrs]removes leading and trailing whitespace or characters supplied in chrs swapcase(converts uppercase to lowercaseand vice versa title(return... |
17,892 | table item methods and operations for dictionaries description returns the number of items in returns the item of with key sets [kto del [kremoves [kfrom in returns true if is key in clear(removes all items from copy(makes copy of fromkeys( [,value]create new dictionary with keys from sequence and values all set to val... |
17,893 | be generally compatible with both versions of python if you need to store the result of these methods as datamake copy by storing it in list for exampleitems list( items()if you simply want list of all keysuse keys list(mset types set is an unordered collection of unique items unlike sequencessets provide no indexing o... |
17,894 | table continued item description removes item from if item is not member of snothing happens intersection_update(tcomputes the intersection of and and leaves the result in pop(returns an arbitrary set element and removes it from remove(itemremoves item from if item is not memberkeyerror is raised symmetric_difference_u... |
17,895 | types and objects user-defined functions user-defined functions are callable objects created at the module level by using the def statement or with the lambda operator here' an exampledef foo( , )return bar lambda ,yx user-defined function has the following attributesattribute(sdescription _doc_ _name_ _dict_ _code_ _d... |
17,896 | in this examplemeth is known as bound method bound method is callable object that wraps both function (the methodand an associated instance when you call bound methodthe instance is passed to the method as the first parameter (selfthusmeth in the example can be viewed as method call that is primed and ready to go but w... |
17,897 | types and objects classes and instances as callables class objects and instances also operate as callable objects class object is created by the class statement and is called as function in order to create new instances in this casethe arguments to the function are passed to the _init_ (method of the class in order to ... |
17,898 | assigned to the corresponding module object modules define namespace that' implemented using dictionary accessible in the attribute _dict_ whenever an attribute of module is referenced (using the dot operator)it' translated into dictionary lookup for examplem is equivalent to _dict_ [" "likewiseassignment to an attribu... |
17,899 | types and objects attribute description tuple containing names of variables referenced by nested functions co_freevars tuple containing names of free variables used by nested functions co_code string representing raw bytecode co_consts tuple containing the literals used by the bytecode co_names tuple containing names u... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.