NumPy Cookbook

所需积分/C币:9 2013-03-30 02:32:50 5.21MB PDF
7
收藏 收藏
举报

使用NumPy进行数据分析,可以替代matlab。
NumPy C。 okboo k Copyright c 2012 Packt Publishing All rights reserved No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher except in the case of brief quotations embedded in critical articles or reviews Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book. Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information First published: October 2012 Production reference:1181012 Published by Packt Publishing Ltd Livery Place 35 Livery Street Birmingham B3 2PB, UK SBN978-184951892-5 www.packtpub.com CoverImagebyavishekroy(royo07avishek88@gmail.com) Credits Author Project Coordinator Ivan Idris Vishal bowa Reviewers Proofreader Alexandre desert Clyde Jenkins Ludovico fische Ryan R Ro Monica Ajmera Mehta Acquisition Editor Production Coordinators Arvindkumar gupta Lead technical editor Manu Josep Ankita shashi Cover work Technical Editors Arvindkumar gi Merin Jose Manu Joseph shit Raja Farhaan shaikh Nitee sh Copy Editor Insiya morbiwala About the Author Ivan Idris has an MSc in Experimental Physics. His graduation thesis had a strong emphasis on applied computer Science. After graduating, he worked for several companies as a Java Developer, Data Warehouse Developer, and Qa analyst. His main professional interests are business intelligence, big data, and cloud computing. He enjoys writing clean, testable code, and interesting technical articles. He is the author of Num Py 1.5 Beginner's Guide You can find more information and a blog with a few Num Py examples at ivanidris net I would like to dedicate this book to my family and friends. I would like to take this opportunity to thank the reviewers and the team at Packt for making this book possible. Thanks also goes to my teachers, professors, and colleagues, who taught me about science and programming. Last but not least, I would like to acknowledge my parents, family, and friends for their support. About the reviewers Alexandre Devert is a computer scientist. To put his happy obsessions to good use, he decided to solve optimization problems, in both academic and industrial contexts. This included all kinds of optimization problems, such as civil engineering problems, packing problems, logistics problems, biological engineering problems-you name it. It involved throwing lots of science on the wall and seeing what sticks. To do so, he had to analyze and visualize large amounts of data quickly, for which Python, Num Py, Scipy, and matplotlib excel Thus, the latter are among the daily tools he has been using for a couple of years. He also lectures on data mining at the University of Science and Technology of china, and uses those very same tools for demonstration purposes and to enlighten his students with graphics glittering of anti-aliased awesomeness I would like to thank my significant other for her understanding my usually hefty work schedule, and my colleagues, for their patience with my shallow interpretation of concepts such as a deadline Ludovico Fischer is a software developer working in the Netherlands. By day, he builds enterprise applications for large multinational companies. By night, he cultivates his academic interests in mathematics and computer science, and plays with mathematical and scientific software Ryan R. Rosario is a Doctoral Candidate at the University of California, Los Angeles He works at Riot Games as a Data Scientist, and he enjoys turning large quantities of massive, messy data into gold. He is heavily involved in the open source community particularly with R, Python, Hadoop, and Machine Learning, and has also contributed code to various Python and r projects. He maintains a blog dedicated to data science and related topicsathttp://www.bytemining.comHehasalsoservedasatechnicalreviewerfor NumPy 1.5 Beginner's Guide wwwpacktpub.com Support files, eBooks, discount offers and more Youmightwanttovisitwww.PacktPubcomforsupportfilesanddownloadsrelatedto our book Did you know that Packt offers eBook versions of every book published, with PDF and e Pub filesavailableYoucanupgradetotheebookversionatwww.Packtpub.comandasaprint book customer, you are entitled to a discount on the eBook copy. Get in touch with us at service@packtpub com for more details Atwww.paCktpub.comyoucanalsoreadacollectionoffreetechnicalarticlessignup for a range of free newsletters and receive exclusive discounts and offers on Packt books and ebooks PACKTLIB http://packtlib.Packtpub.corm Do you need instant solutions to your IT questions? PacktLib is Packt 's online digital book library. Here, you can access, read and search across Packt's entire library of books Why Subscribe? Fully searchable across every book published by Packt Copy and paste, print and bookmark content on demand and accessible via web browser Free Access for packt account holders IfyouhaveanaccountwithPacktatwww.Packtpub.comyoucanusethistoaccess PacktLib today and view nine entirely free books Simply use your login credentials for immediate access Table of contents Preface Chapter 1: Winding Along with IPython Introductlon 5 Installing IPython 6 Using IPython as a shell Reading manual pages 10 Installing Matplotlib Running a web notebook 12 Exporting a web notebook 14 Importing a web notebook 16 Configuring a notebook server 20 Exploring the SymPy profile 23 Chapter 2: Advanced Indexing and Array Concepts 25 Introduction 25 Installing sciP 26 Installing PIL 28 Resizing images 29 Creating views and copies 32 Flipping Lena 34 Fancy indexing 36 Indexing with a list of locations 39 Indexing with booleans 40 Stride tricks for sudoku 42 Broadcasting arrays 45 Chapter 3: Get to Grips with Commonly Used Functions 49 Introduction 50 Summing Fibonacci numbers 50 Finding pri rime factors 54 Table of contents Finding palindromic numbers 56 The steady state vector determination 58 Discovering a power law 64 Trading periodically on dips 67 Simulating trading at random 70 Sieving integers with the Sieve of Erasthothenes 72 Chapter 4: Connecting NumPy with the Rest of the World 75 ntroduction 75 UsIng the buffer protocol 76 Using the array interface 79 ExchangIng data wIth MATLAB and octave 80 Installing RPy2 82 Interfacing with R 82 Installing JPype 84 Sending a NumPy array to JPype 84 Installing Google App engine 86 Deploying Num Py code in the Google cloud 88 Running NumPy code in a Python Anywhere web console 90 Setting up Picloud 92 Chapter 5: Audio and Image processing 95 Introduction 95 Loading images into memory map 96 combining images 100 Blurring images 104 Repeating audio fragments 108 Generating sounds 110 Designing an audio filter 114 Edge detection with the Sobel filter 117 Chapter 6: Special Arrays and Universal Functions 121 Introduction 121 Creating a universal function 121 Finding pythagorean triples 122 Performing string operations with chararray 124 Creating a masked array 125 goring negative and extreme values 128 Creating a scores table with recarray 131 Chapter 7: Profiling and Debugging 135 ntroduction 135 Profiling with timeit 135 filing with IPython 139 Table of contents stalling line_profiler 142 Profiling code with line_ profiler 143 Profiling code with the cProfile extension 144 Debugging with IPython 146 Debugging with pudb 148 Chapter 8: Quality Assurance 151 Introduction 151 Installing Pyflakes 151 PerformIng static analysls wlth Pyflakes 152 Analyzing code with Pylint 153 PerformIng static analysls wIth Pychecker 155 Testing code with docstrings 156 Writing unit tests 158 Testing code with mocks 162 Testing the BDD way 164 Chapter 9: Speed Up code with Cython 169 Introductlon 169 Installing cython 170 Building a hello world program 170 Using Cython with NumPy 172 Calling c functions 173 Profiling Cython code 175 Approximating factorials with Cython 178 Chapter 10: Fun with Scikits 183 Introduction 183 Installing scikits-learn 184 Loading an example dataset 184 Clustering Dow Jones stocks with scikits-learn 185 Installing scikits-statsmodels 189 Performing a normality test with scikits-statsmodels 190 Installing scikits-image 191 Detecting corners 191 Detecting edges 193 Installing Pandas 194 Estimating stock returns correlation with Pandas 195 Loading data as pandas objects from statsmodels 198 Resampling time series data 200 Index 205 II

...展开详情
试读 127P NumPy Cookbook
立即下载 低至0.43元/次 身份认证VIP会员低至7折
一个资源只可评论一次,评论内容不能少于5个字
您会向同学/朋友/同事推荐我们的CSDN下载吗?
谢谢参与!您的真实评价是我们改进的动力~
上传资源赚积分or赚钱
    最新推荐
    NumPy Cookbook 9积分/C币 立即下载
    1/127
    NumPy Cookbook第1页
    NumPy Cookbook第2页
    NumPy Cookbook第3页
    NumPy Cookbook第4页
    NumPy Cookbook第5页
    NumPy Cookbook第6页
    NumPy Cookbook第7页
    NumPy Cookbook第8页
    NumPy Cookbook第9页
    NumPy Cookbook第10页
    NumPy Cookbook第11页
    NumPy Cookbook第12页
    NumPy Cookbook第13页
    NumPy Cookbook第14页
    NumPy Cookbook第15页
    NumPy Cookbook第16页
    NumPy Cookbook第17页
    NumPy Cookbook第18页
    NumPy Cookbook第19页
    NumPy Cookbook第20页

    试读结束, 可继续阅读

    9积分/C币 立即下载 >