Tải bản đầy đủ (.pdf) (426 trang)

Artificial intelligence with python kho tài liệu bách khoa

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (34.69 MB, 426 trang )


TableofContents
ArtificialIntelligencewithPython
Credits
AbouttheAuthor
AbouttheReviewer
www.PacktPub.com
Whysubscribe?
CustomerFeedback
Preface
Whatthisbookcovers
Whatyouneedforthisbook
Whothisbookisfor
Conventions
Readerfeedback
Customersupport
Downloadingtheexamplecode
Downloadingthecolorimagesofthisbook
Errata
Piracy
Questions
1.IntroductiontoArtificialIntelligence
WhatisArtificialIntelligence?
WhydoweneedtostudyAI?
ApplicationsofAI
BranchesofAI
DefiningintelligenceusingTuringTest
Makingmachinesthinklikehumans
Buildingrationalagents
GeneralProblemSolver
SolvingaproblemwithGPS


Buildinganintelligentagent
Typesofmodels
InstallingPython3
InstallingonUbuntu
InstallingonMacOSX
InstallingonWindows
Installingpackages
Loadingdata
Summary
2.ClassificationandRegressionUsingSupervisedLearning
Supervisedversusunsupervisedlearning
Whatisclassification?
Preprocessingdata
Binarization


Meanremoval
Scaling
Normalization
Labelencoding
LogisticRegressionclassifier
NaïveBayesclassifier
Confusionmatrix
SupportVectorMachines
ClassifyingincomedatausingSupportVectorMachines
WhatisRegression?
Buildingasinglevariableregressor
Buildingamultivariableregressor
EstimatinghousingpricesusingaSupportVectorRegressor
Summary

3.PredictiveAnalyticswithEnsembleLearning
WhatisEnsembleLearning?
BuildinglearningmodelswithEnsembleLearning
WhatareDecisionTrees?
BuildingaDecisionTreeclassifier
WhatareRandomForestsandExtremelyRandomForests?
BuildingRandomForestandExtremelyRandomForestclassifiers
Estimatingtheconfidencemeasureofthepredictions
Dealingwithclassimbalance
Findingoptimaltrainingparametersusinggridsearch
Computingrelativefeatureimportance
PredictingtrafficusingExtremelyRandomForestregressor
Summary
4.DetectingPatternswithUnsupervisedLearning
Whatisunsupervisedlearning?
ClusteringdatawithK-Meansalgorithm
EstimatingthenumberofclusterswithMeanShiftalgorithm
Estimatingthequalityofclusteringwithsilhouettescores
WhatareGaussianMixtureModels?
BuildingaclassifierbasedonGaussianMixtureModels
FindingsubgroupsinstockmarketusingAffinityPropagationmodel
Segmentingthemarketbasedonshoppingpatterns
Summary
5.BuildingRecommenderSystems
Creatingatrainingpipeline
Extractingthenearestneighbors
BuildingaK-NearestNeighborsclassifier
Computingsimilarityscores
Findingsimilarusersusingcollaborativefiltering
Buildingamovierecommendationsystem

Summary
6.LogicProgramming
Whatislogicprogramming?


Understandingthebuildingblocksoflogicprogramming
Solvingproblemsusinglogicprogramming
InstallingPythonpackages
Matchingmathematicalexpressions
Validatingprimes
Parsingafamilytree
Analyzinggeography
Buildingapuzzlesolver
Summary
7.HeuristicSearchTechniques
Whatisheuristicsearch?
UninformedversusInformedsearch
ConstraintSatisfactionProblems
Localsearchtechniques
SimulatedAnnealing
Constructingastringusinggreedysearch
Solvingaproblemwithconstraints
Solvingtheregion-coloringproblem
Buildingan8-puzzlesolver
Buildingamazesolver
Summary
8.GeneticAlgorithms
Understandingevolutionaryandgeneticalgorithms
Fundamentalconceptsingeneticalgorithms
Generatingabitpatternwithpredefinedparameters

Visualizingtheevolution
Solvingthesymbolregressionproblem
Buildinganintelligentrobotcontroller
Summary
9.BuildingGamesWithArtificialIntelligence
Usingsearchalgorithmsingames
Combinatorialsearch
Minimaxalgorithm
Alpha-Betapruning
Negamaxalgorithm
InstallingeasyAIlibrary
BuildingabottoplayLastCoinStanding
BuildingabottoplayTic-Tac-Toe
BuildingtwobotstoplayConnectFour™againsteachother
BuildingtwobotstoplayHexapawnagainsteachother
Summary
10.NaturalLanguageProcessing
Introductionandinstallationofpackages
Tokenizingtextdata
Convertingwordstotheirbaseformsusingstemming
Convertingwordstotheirbaseformsusinglemmatization
Dividingtextdataintochunks


ExtractingthefrequencyoftermsusingaBagofWordsmodel
Buildingacategorypredictor
Constructingagenderidentifier
Buildingasentimentanalyzer
TopicmodelingusingLatentDirichletAllocation
Summary

11.ProbabilisticReasoningforSequentialData
Understandingsequentialdata
Handlingtime-seriesdatawithPandas
Slicingtime-seriesdata
Operatingontime-seriesdata
Extractingstatisticsfromtime-seriesdata
GeneratingdatausingHiddenMarkovModels
IdentifyingalphabetsequenceswithConditionalRandomFields
Stockmarketanalysis
Summary
12.BuildingASpeechRecognizer
Workingwithspeechsignals
Visualizingaudiosignals
Transformingaudiosignalstothefrequencydomain
Generatingaudiosignals
Synthesizingtonestogeneratemusic
Extractingspeechfeatures
Recognizingspokenwords
Summary
13.ObjectDetectionandTracking
InstallingOpenCV
Framedifferencing
Trackingobjectsusingcolorspaces
Objecttrackingusingbackgroundsubtraction
BuildinganinteractiveobjecttrackerusingtheCAMShiftalgorithm
Opticalflowbasedtracking
Facedetectionandtracking
UsingHaarcascadesforobjectdetection
Usingintegralimagesforfeatureextraction
Eyedetectionandtracking

Summary
14.ArtificialNeuralNetworks
Introductiontoartificialneuralnetworks
Buildinganeuralnetwork
Traininganeuralnetwork
BuildingaPerceptronbasedclassifier
Constructingasinglelayerneuralnetwork
Constructingamultilayerneuralnetwork
Buildingavectorquantizer
Analyzingsequentialdatausingrecurrentneuralnetworks
VisualizingcharactersinanOpticalCharacterRecognitiondatabase


BuildinganOpticalCharacterRecognitionengine
Summary
15.ReinforcementLearning
Understandingthepremise
Reinforcementlearningversussupervisedlearning
Realworldexamplesofreinforcementlearning
Buildingblocksofreinforcementlearning
Creatinganenvironment
Buildingalearningagent
Summary
16.DeepLearningwithConvolutionalNeuralNetworks
WhatareConvolutionalNeuralNetworks?
ArchitectureofCNNs
TypesoflayersinaCNN
Buildingaperceptron-basedlinearregressor
Buildinganimageclassifierusingasinglelayerneuralnetwork
BuildinganimageclassifierusingaConvolutionalNeuralNetwork

Summary


ArtificialIntelligencewithPython


ArtificialIntelligencewithPython
Copyright©2017PacktPublishing
Allrightsreserved.Nopartofthisbookmaybereproduced,storedinaretrievalsystem,or
transmittedinanyformorbyanymeans,withoutthepriorwrittenpermissionofthepublisher,
exceptinthecaseofbriefquotationsembeddedincriticalarticlesorreviews.
Everyefforthasbeenmadeinthepreparationofthisbooktoensuretheaccuracyofthe
informationpresented.However,theinformationcontainedinthisbookissoldwithoutwarranty,
eitherexpressorimplied.Neithertheauthor,norPacktPublishing,anditsdealersand
distributorswillbeheldliableforanydamagescausedorallegedtobecauseddirectlyor
indirectlybythisbook.
PacktPublishinghasendeavoredtoprovidetrademarkinformationaboutallofthecompanies
andproductsmentionedinthisbookbytheappropriateuseofcapitals.However,Packt
Publishingcannotguaranteetheaccuracyofthisinformation.
Firstpublished:January2017
Productionreference:1230117
PublishedbyPacktPublishingLtd.
LiveryPlace
35LiveryStreet
Birmingham
B32PB,UK.
ISBN978-1-78646-439-2
www.packtpub.com



Credits
Author
PrateekJoshi
Reviewer
RichardMarsden
CommissioningEditor
VeenaPagare
AcquisitionEditor
TusharGupta
ContentDevelopmentEditor
AishwaryaPandere
TechnicalEditor
KaranThakkar

CopyEditors
VikrantPhadkay
SafisEditing
ProjectCoordinator
NidhiJoshi
Proofreader
SafisEditing
Indexer
MariammalChettiyar
ProductionCoordinator
ShantanuN.Zagade


AbouttheAuthor
PrateekJoshiisanartificialintelligenceresearcher,publishedauthoroffivebooks,andTEDx
speaker.HeisthefounderofPlutoAI,aventure-fundedSiliconValleystartupbuildingan

analyticsplatformforsmartwatermanagementpoweredbydeeplearning.Hisworkinthisfield
hasledtopatents,techdemos,andresearchpapersatmajorIEEEconferences.Hehasbeen
aninvitedspeakerattechnologyandentrepreneurshipconferencesincludingTEDx,AT&T
Foundry,SiliconValleyDeepLearning,andOpenSiliconValley.Prateekhasalsobeenfeatured
asaguestauthorinprominenttechmagazines.
Histechblog(www.prateekjoshi.com)hasreceivedmorethan1.2millionpageviewsfrom200
overcountriesandhasover6,600+followers.Hefrequentlywritesontopicssuchasartificial
intelligence,Pythonprogramming,andabstractmathematics.Heisanavidcoderandhaswon
manyhackathonsutilizingawidevarietyoftechnologies.HegraduatedfromUniversityof
SouthernCaliforniawithamaster’sdegreespecializinginartificialintelligence.Hehasworked
atcompaniessuchasNvidiaandMicrosoftResearch.Youcanlearnmoreabouthimonhis
personalwebsiteatwww.prateekj.com.


AbouttheReviewer
RichardMarsdenhasover20yearsofprofessionalsoftwaredevelopmentexperience.After
startinginthefieldofgeophysicalsurveyingfortheoilindustry,hehasspentthelasttenyears
runningtheWinwaedSoftwareTechnologyLLCindependentsoftwarevendor.Winwaed
specializesingeospatialtoolsandapplicationsincludingwebapplications,andoperatesthe
websitefortoolsandadd-insforgeospatialapplicationssuch
asCaliperMaptitudeandMicrosoftMapPoint.
RichardwasalsoatechnicalreviewerofthefollowingPacktpublications:PythonGeospatial
DevelopmentandPythonGeospatialAnalysisEssentials,bothbyErikWestra;Python
GeospatialAnalysisCookbookbyMichaelDiener;MasteringPythonForensicsbyDrs
MichaelSpreitzenbarthandDrJohannUhrmann;andEffectivePythonPenetrationTestingby
RejahRehim.


www.PacktPub.com
Forsupportfilesanddownloadsrelatedtoyourbook,pleasevisitwww.PacktPub.com.

DidyouknowthatPacktofferseBookversionsofeverybookpublished,withPDFandePub
filesavailable?YoucanupgradetotheeBookversionatwww.PacktPub.comandasaprint
bookcustomer,youareentitledtoadiscountontheeBookcopy.Getintouchwithus
atformoredetails.
Atwww.PacktPub.com,youcanalsoreadacollectionoffreetechnicalarticles,signupfora
rangeoffreenewslettersandreceiveexclusivediscountsandoffersonPacktbooksand
eBooks.

/>Getthemostin-demandsoftwareskillswithMapt.MaptgivesyoufullaccesstoallPackt
booksandvideocourses,aswellasindustry-leadingtoolstohelpyouplanyourpersonal
developmentandadvanceyourcareer.

Whysubscribe?
FullysearchableacrosseverybookpublishedbyPackt
Copyandpaste,print,andbookmarkcontent
Ondemandandaccessibleviaawebbrowser


CustomerFeedback
ThankyouforpurchasingthisPacktbook.Wetakeourcommitmenttoimprovingourcontent
andproductstomeetyourneedsseriously—that'swhyyourfeedbackissovaluable.Whatever
yourfeelingsaboutyourpurchase,pleaseconsiderleavingareviewonthisbook'sAmazon
page.Notonlywillthishelpus,moreimportantlyitwillalsohelpothersinthecommunityto
makeaninformeddecisionabouttheresourcesthattheyinvestintolearn.
Youcanalsoreviewforusonaregularbasisbyjoiningourreviewers'club.Ifyou're
interestedinjoining,orwouldliketolearnmoreaboutthebenefitsweoffer,please
contactus:


Preface

Artificialintelligenceisbecomingincreasinglyrelevantinthemodernworldwhereeverythingis
drivenbydataandautomation.Itisusedextensivelyacrossmanyfieldssuchasimage
recognition,robotics,searchengines,andself-drivingcars.Inthisbook,wewillexplorevarious
real-worldscenarios.Wewillunderstandwhatalgorithmstouseinagivencontextandwrite
functionalcodeusingthisexcitingbook.
Wewillstartbytalkingaboutvariousrealmsofartificialintelligence.We’llthenmoveonto
discussmorecomplexalgorithms,suchasExtremelyRandomForests,HiddenMarkovModels,
GeneticAlgorithms,ArtificialNeuralNetworks,andConvolutionalNeuralNetworks,andsoon.
ThisbookisforPythonprogrammerslookingtouseartificialintelligencealgorithmstocreate
real-worldapplications.ThisbookisfriendlytoPythonbeginners,butfamiliaritywithPython
programmingwouldcertainlybehelpfulsoyoucanplayaroundwiththecode.Itisalsouseful
toexperiencedPythonprogrammerswhoarelookingtoimplementartificialintelligence
techniques.
Youwilllearnhowtomakeinformeddecisionsaboutthetypeofalgorithmsyouneedtouse
andhowtoimplementthosealgorithmstogetthebestpossibleresults.Ifyouwanttobuild
versatileapplicationsthatcanmakesenseofimages,text,speech,orsomeotherformofdata,
thisbookonartificialintelligencewilldefinitelycometoyourrescue!


Whatthisbookcovers
Chapter1,IntroductiontoArtificialIntelligence,teachesyouvariousintroductoryconceptsin
artificialintelligence.Ittalksaboutapplications,branches,andmodelingofArtificialIntelligence.
ItwalksthereaderthroughtheinstallationofnecessaryPythonpackages.
Chapter2,ClassificationandRegressionUsingSupervisedLearning,coversvarious
supervisedlearningtechniquesforclassificationandregression.Youwilllearnhowtoanalyze
incomedataandpredicthousingprices.
Chapter3,PredictiveAnalyticswithEnsembleLearning,explainspredictivemodeling
techniquesusingEnsembleLearning,particularlyfocusedonRandomForests.Wewilllearn
howtoapplythesetechniquestopredicttrafficontheroadsnearsportsstadiums.
Chapter4,DetectingPatternswithUnsupervisedLearning,coversunsupervisedlearning

algorithmsincludingK-meansandMeanShiftClustering.Wewilllearnhowtoapplythese
algorithmstostockmarketdataandcustomersegmentation.
Chapter5,BuildingRecommenderSystems,illustratesalgorithmsusedtobuild
recommendationengines.Youwilllearnhowtoapplythesealgorithmstocollaborativefiltering
andmovierecommendations.
Chapter6,LogicProgramming,coversthebuildingblocksoflogicprogramming.Wewillsee
variousapplications,includingexpressionmatching,parsingfamilytrees,andsolvingpuzzles.
Chapter7,HeuristicSearchTechniques,showsheuristicsearchtechniquesthatareusedto
searchthesolutionspace.Wewilllearnaboutvariousapplicationssuchassimulatedannealing,
regioncoloring,andmazesolving.
Chapter8,GeneticAlgorithms,coversevolutionaryalgorithmsandgeneticprogramming.We
willlearnaboutvariousconceptssuchascrossover,mutation,andfitnessfunctions.Wewill
thenusetheseconceptstosolvethesymbolregressionproblemandbuildanintelligentrobot
controller.
Chapter9,BuildingGameswithArtificialIntelligence,teachesyouhowtobuildgameswith
artificialintelligence.WewilllearnhowtobuildvariousgamesincludingTicTacToe,Connect
Four,andHexapawn.
Chapter10,NaturalLanguageProcessing,coverstechniquesusedtoanalyzetextdata
includingtokenization,stemming,bagofwords,andsoon.Wewilllearnhowtousethese
techniquestodosentimentanalysisandtopicmodeling.
Chapter11,ProbabilisticReasoningforSequentialData,showsyoutechniquesusedto
analyzetimeseriesandsequentialdataincludingHiddenMarkovmodelsandConditional
RandomFields.Wewilllearnhowtoapplythesetechniquestotextsequenceanalysisand
stockmarketpredictions.
Chapter12,BuildingASpeechRecognizer,demonstratesalgorithmsusedtoanalyzespeech
data.Wewilllearnhowtobuildspeechrecognitionsystems.
Chapter13,ObjectDetectionandTracking,Itcoversalgorithmsrelatedtoobjectdetection
andtrackinginlivevideo.Wewilllearnaboutvarioustechniquesincludingopticalflow,face
tracking,andeyetracking.
Chapter14,ArtificialNeuralNetworks,coversalgorithmsusedtobuildneuralnetworks.We

willlearnhowtobuildanOpticalCharacterRecognitionsystemusingneuralnetworks.
Chapter15,ReinforcementLearning,teachesthetechniquesusedtobuildreinforcement
learningsystems.Wewilllearnhowtobuildlearningagentsthatcanlearnfrominteractingwith
theenvironment.
Chapter16,DeepLearningwithConvolutionalNeuralNetworks,coversalgorithmsusedto


builddeeplearningsystemsusingConvolutionalNeuralNetworks.Wewilllearnhowtouse
TensorFlowtobuildneuralnetworks.Wewillthenuseittobuildanimageclassifierusing
convolutionalneuralnetworks.


Whatyouneedforthisbook
ThisbookisfocusedonartificialintelligenceinPythonasopposedtothePythonitself.Wehave
usedPython3tobuildvariousapplications.WefocusonhowtoutilizevariousPythonlibraries
inthebestpossiblewaytobuildrealworldapplications.Inthatspirit,wehavetriedtokeepall
ofthecodeasfriendlyandreadableaspossible.Wefeelthatthiswillenableourreadersto
easilyunderstandthecodeandreadilyuseitindifferentscenarios.


Whothisbookisfor
ThisbookisforPythondeveloperswhowanttobuildreal-worldartificialintelligence
applications.ThisbookisfriendlytoPythonbeginners,butbeingfamiliarwithPythonwouldbe
usefultoplayaroundwiththecode.ItwillalsobeusefulforexperiencedPythonprogrammers
whoarelookingtouseartificialintelligencetechniquesintheirexistingtechnologystacks.


Conventions
Inthisbook,youwillfindanumberoftextstylesthatdistinguishbetweendifferentkindsof
information.Herearesomeexamplesofthesestylesandanexplanationoftheirmeaning.

Codewordsintext,databasetablenames,foldernames,filenames,fileextensions,
pathnames,dummyURLs,userinput,andTwitterhandlesareshownasfollows:"Wecan
includeothercontextsthroughtheuseoftheincludedirective."
Ablockofcodeissetasfollows:
[default]
exten=>s,1,Dial(Zap/1|30)
exten=>s,2,Voicemail(u100)
exten=>s,102,Voicemail(b100)
exten=>i,1,Voicemail(s0)

Whenwewishtodrawyourattentiontoaparticularpartofacodeblock,therelevantlinesor
itemsaresetinbold:
[default]
exten=>s,1,Dial(Zap/1|30)
exten=>s,2,Voicemail(u100)
exten=>s,102,Voicemail(b100)
exten=>i,1,Voicemail(s0)

Anycommand-lineinputoroutputiswrittenasfollows:
#cp/usr/src/asterisk-addons/configs/cdr_mysql.conf.sample
/etc/asterisk/cdr_mysql.conf

Newtermsandimportantwordsareshowninbold.Wordsthatyouseeonthescreen,for
example,inmenusordialogboxes,appearinthetextlikethis:"Theshortcutsinthisbookare
basedontheMacOSX10.5+scheme."

Note
Warningsorimportantnotesappearinaboxlikethis.

Tip

Tipsandtricksappearlikethis.


Readerfeedback
Feedbackfromourreadersisalwayswelcome.Letusknowwhatyouthinkaboutthisbookwhatyoulikedordisliked.Readerfeedbackisimportantforusasithelpsusdeveloptitlesthat
youwillreallygetthemostoutof.
Tosendusgeneralfeedback,simplye-mail,andmentionthebook's
titleinthesubjectofyourmessage.
Ifthereisatopicthatyouhaveexpertiseinandyouareinterestedineitherwritingor
contributingtoabook,seeourauthorguideatwww.packtpub.com/authors.


Customersupport
NowthatyouaretheproudownerofaPacktbook,wehaveanumberofthingstohelpyouto
getthemostfromyourpurchase.

Downloadingtheexamplecode
Youcandownloadtheexamplecodefilesforthisbookfromyouraccountat
.Ifyoupurchasedthisbookelsewhere,youcanvisit
andregistertohavethefilese-maileddirectlytoyou.
Youcandownloadthecodefilesbyfollowingthesesteps:
1. Loginorregistertoourwebsiteusingyoure-mailaddressandpassword.
2. HoverthemousepointerontheSUPPORTtabatthetop.
3. ClickonCodeDownloads&Errata.
4. EnterthenameofthebookintheSearchbox.
5. Selectthebookforwhichyou'relookingtodownloadthecodefiles.
6. Choosefromthedrop-downmenuwhereyoupurchasedthisbookfrom.
7. ClickonCodeDownload.
Oncethefileisdownloaded,pleasemakesurethatyouunziporextractthefolderusingthe
latestversionof:

WinRAR/7-ZipforWindows
Zipeg/iZip/UnRarXforMac
7-Zip/PeaZipforLinux
ThecodebundleforthebookisalsohostedonGitHubat
Wealsohaveothercode
bundlesfromourrichcatalogofbooksandvideosavailableat
Checkthemout!

Downloadingthecolorimagesofthisbook

WealsoprovideyouwithaPDFfilethathascolorimagesofthescreenshots/diagramsusedin
thisbook.Thecolorimageswillhelpyoubetterunderstandthechangesintheoutput.Youcan
downloadthisfilefrom
/>
Errata
Althoughwehavetakeneverycaretoensuretheaccuracyofourcontent,mistakesdohappen.
Ifyoufindamistakeinoneofourbooks-maybeamistakeinthetextorthecode-wewouldbe
gratefulifyoucouldreportthistous.Bydoingso,youcansaveotherreadersfromfrustration
andhelpusimprovesubsequentversionsofthisbook.Ifyoufindanyerrata,pleasereport
thembyvisitingselectingyourbook,clickingonthe
ErrataSubmissionFormlink,andenteringthedetailsofyourerrata.Onceyourerrataare
verified,yoursubmissionwillbeacceptedandtheerratawillbeuploadedtoourwebsiteor
addedtoanylistofexistingerrataundertheErratasectionofthattitle.
Toviewthepreviouslysubmittederrata,goto
andenterthenameofthebookinthesearch
field.TherequiredinformationwillappearundertheErratasection.

Piracy
PiracyofcopyrightedmaterialontheInternetisanongoingproblemacrossallmedia.AtPackt,



wetaketheprotectionofourcopyrightandlicensesveryseriously.Ifyoucomeacrossany
illegalcopiesofourworksinanyformontheInternet,pleaseprovideuswiththelocation
addressorwebsitenameimmediatelysothatwecanpursuearemedy.
Pleasecontactusatwithalinktothesuspectedpiratedmaterial.
Weappreciateyourhelpinprotectingourauthorsandourabilitytobringyouvaluablecontent.

Questions
Ifyouhaveaproblemwithanyaspectofthisbook,youcancontactus
at,andwewilldoourbesttoaddresstheproblem.


Chapter1.IntroductiontoArtificial
Intelligence
Inthischapter,wearegoingtodiscusstheconceptofArtificialIntelligence(AI)andhowit's
appliedintherealworld.Wespendasignificantportionofoureverydaylifeinteractingwith
smartsystems.Itcanbeintheformofsearchingforsomethingontheinternet,Biometricface
recognition,orconvertingspokenwordstotext.ArtificialIntelligenceisattheheartofallthis
andit'sbecominganimportantpartofourmodernlifestyle.AllthesesystemarecomplexrealworldapplicationsandArtificialIntelligencesolvestheseproblemswithmathematicsand
algorithms.Duringthecourseofthisbook,wewilllearnthefundamentalprinciplesthatare
usedtobuildsuchapplicationsandthenimplementthemaswell.Ouroverarchinggoalisto
enableyoutotakeupnewandchallengingArtificialIntelligenceproblemsthatyoumight
encounterinyoureverydaylife.
Bytheendofthischapter,youwillknow:
WhatisAIandwhydoweneedtostudyit?
ApplicationsofAI
BranchesofAI
Turingtest
Rationalagents
GeneralProblemSolvers

Buildinganintelligentagent
InstallingPython3onvariousoperatingsystems
InstallingthenecessaryPythonpackages

WhatisArtificialIntelligence?
ArtificialIntelligence(AI)isawaytomakemachinesthinkandbehaveintelligently.These
machinesarecontrolledbysoftwareinsidethem,soAIhasalottodowithintelligentsoftware
programsthatcontrolthesemachines.Itisascienceoffindingtheoriesandmethodologiesthat
canhelpmachinesunderstandtheworldandaccordinglyreacttosituationsinthesameway
thathumansdo.
IfwelookcloselyathowthefieldofAIhasemergedoverthelastcoupleofdecades,youwill
seethatdifferentresearcherstendtofocusondifferentconceptstodefineAI.Inthemodern
world,AIisusedacrossmanyverticalsinmanydifferentforms.Wewantthemachinesto
sense,reason,think,andact.Wewantourmachinestoberationaltoo.
AIiscloselyrelatedtothestudyofhumanbrain.ResearchersbelievethatAIcanbe
accomplishedbyunderstandinghowthehumanbrainworks.Bymimickingthewaythehuman
brainlearns,thinks,andtakesaction,wecanbuildamachinethatcandothesame.Thiscan
beusedasaplatformtodevelopintelligentsystemsthatarecapableoflearning.


WhydoweneedtostudyAI?
AIhastheabilitytoimpacteveryaspectofourlives.ThefieldofAItriestounderstandpatterns
andbehaviorsofentities.WithAI,wewanttobuildsmartsystemsandunderstandtheconcept
ofintelligenceaswell.Theintelligentsystemsthatweconstructareveryusefulin
understandinghowanintelligentsystemlikeourbraingoesaboutconstructinganother
intelligentsystem.
Let'stakealookathowourbrainprocessesinformation:

ComparedtosomeotherfieldssuchasMathematicsorPhysicsthathavebeenaroundfor
centuries,AIisrelativelyinitsinfancy.Overthelastcoupleofdecades,AIhasproducedsome

spectacularproductssuchasself-drivingcarsandintelligentrobotsthatcanwalk.Basedon
thedirectioninwhichweareheading,it'sprettyobviousthatachievingintelligencewillhavea
greatimpactonourlivesinthecomingyears.
Wecan'thelpbutwonderhowthehumanbrainmanagestodosomuchwithsucheffortless
ease.Wecanrecognizeobjects,understandlanguages,learnnewthings,andperformmany
moresophisticatedtaskswithourbrain.Howdoesthehumanbraindothis?Whenyoutrytodo
thiswithamachine,youwillseethatitfallswaybehind!Forexample,whenwetrytolookfor
thingssuchasextraterrestriallifeortimetravel,wedon'tknowifthosethingsexist.Thegood
thingabouttheholygrailofAIisthatweknowitexists.Ourbrainistheholygrail!Itisa
spectacularexampleofanintelligentsystem.Allwehavetodoistomimicitsfunctionalityto
createanintelligentsystemthatcandosomethingsimilar,possiblyevenmore.
Let'sseehowrawdatagetsconvertedtowisdomthroughvariouslevelsofprocessing:


OneofthemainreasonswewanttostudyAIistoautomatemanythings.Weliveinaworld
where:
Wedealwithhugeandinsurmountableamountsofdata.Thehumanbraincan'tkeeptrack
ofsomuchdata.
Dataoriginatesfrommultiplesourcessimultaneously.
Thedataisunorganizedandchaotic.
Knowledgederivedfromthisdatahastobeupdatedconstantlybecausethedataitself
keepschanging.
Thesensingandactuationhastohappeninrealtimewithhighprecision.
Eventhoughthehumanbrainisgreatatanalyzingthingsaroundus,itcannotkeepupwiththe
precedingconditions.Hence,weneedtodesignanddevelopintelligentmachinesthatcando
this.WeneedAIsystemsthatcan:
Handlelargeamountsofdatainanefficientway.WiththeadventofCloudComputing,we
arenowabletostorehugeamountsofdata.
Ingestdatasimultaneouslyfrommultiplesourceswithoutanylag.
Indexandorganizedatainawaythatallowsustoderiveinsights.

Learnfromnewdataandupdateconstantlyusingtherightlearningalgorithms.


×