logo资料库

scipy参考文档(机器学习).pdf

第1页 / 共1362页
第2页 / 共1362页
第3页 / 共1362页
第4页 / 共1362页
第5页 / 共1362页
第6页 / 共1362页
第7页 / 共1362页
第8页 / 共1362页
资料共1362页,剩余部分请下载后查看
SciPy Tutorial
Introduction
Basic functions
Special functions (scipy.special)
Integration (scipy.integrate)
Optimization (scipy.optimize)
Interpolation (scipy.interpolate)
Fourier Transforms (scipy.fftpack)
Signal Processing (scipy.signal)
Linear Algebra (scipy.linalg)
Sparse Eigenvalue Problems with ARPACK
Compressed Sparse Graph Routines (scipy.sparse.csgraph)
Spatial data structures and algorithms (scipy.spatial)
Statistics (scipy.stats)
Multidimensional image processing (scipy.ndimage)
File IO (scipy.io)
Weave (scipy.weave)
Contributing to SciPy
Contributing new code
Contributing by helping maintain existing code
Other ways to contribute
Recommended development setup
SciPy structure
Useful links, FAQ, checklist
API - importing from Scipy
Guidelines for importing functions from Scipy
API definition
Release Notes
SciPy 0.14.0 Release Notes
SciPy 0.13.2 Release Notes
SciPy 0.13.1 Release Notes
SciPy 0.13.0 Release Notes
SciPy 0.12.1 Release Notes
SciPy 0.12.0 Release Notes
SciPy 0.11.0 Release Notes
SciPy 0.10.1 Release Notes
SciPy 0.10.0 Release Notes
SciPy 0.9.0 Release Notes
SciPy 0.8.0 Release Notes
SciPy 0.7.2 Release Notes
SciPy 0.7.1 Release Notes
SciPy 0.7.0 Release Notes
Reference
Clustering package (scipy.cluster)
K-means clustering and vector quantization (scipy.cluster.vq)
Hierarchical clustering (scipy.cluster.hierarchy)
Constants (scipy.constants)
Discrete Fourier transforms (scipy.fftpack)
Integration and ODEs (scipy.integrate)
Interpolation (scipy.interpolate)
Input and output (scipy.io)
Linear algebra (scipy.linalg)
Low-level BLAS functions
Finding functions
BLAS Level 1 functions
BLAS Level 2 functions
BLAS Level 3 functions
Low-level LAPACK functions
Finding functions
All functions
Interpolative matrix decomposition (scipy.linalg.interpolative)
Miscellaneous routines (scipy.misc)
Multi-dimensional image processing (scipy.ndimage)
Orthogonal distance regression (scipy.odr)
Optimization and root finding (scipy.optimize)
Nonlinear solvers
Signal processing (scipy.signal)
Sparse matrices (scipy.sparse)
Sparse linear algebra (scipy.sparse.linalg)
Compressed Sparse Graph Routines (scipy.sparse.csgraph)
Spatial algorithms and data structures (scipy.spatial)
Distance computations (scipy.spatial.distance)
Special functions (scipy.special)
Statistical functions (scipy.stats)
Statistical functions for masked arrays (scipy.stats.mstats)
C/C++ integration (scipy.weave)
Bibliography
Index
SciPy Reference Guide Release 0.14.0 Written by the SciPy community May 03, 2014
CONTENTS 1 SciPy Tutorial . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Introduction . . Basic functions . Special functions (scipy.special) Integration (scipy.integrate) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.2 . . . . . . . . . . . . . . . . . . 1.3 . . . . . . . . . . . . . . . . . . . . . . 1.4 . . . . . . . . . . . . . . . . . . . . . . 1.5 Optimization (scipy.optimize) . . . . . . . . . . . . . . . . . . . . . Interpolation (scipy.interpolate) 1.6 . . . . . . . . . . . . . . . . . . 1.7 Fourier Transforms (scipy.fftpack) . Signal Processing (scipy.signal) . . . . . 1.8 1.9 . . . . . . . . . . . . . . . . . . . . Linear Algebra (scipy.linalg) . . . . . . 1.10 Sparse Eigenvalue Problems with ARPACK . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.11 Compressed Sparse Graph Routines (scipy.sparse.csgraph) . 1.12 Spatial data structures and algorithms (scipy.spatial) . . . . . . . 1.13 Statistics (scipy.stats) . . . . . . . . . . . . . . . . . . . . . . . . . 1.14 Multidimensional image processing (scipy.ndimage) 1.15 File IO (scipy.io) . . 1.16 Weave (scipy.weave) 3 3 5 9 10 16 30 42 51 69 82 85 88 94 . . . . . . . . . . 113 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134 . 140 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 Contributing to SciPy Contributing new code . Contributing by helping maintain existing code . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175 . 176 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176 Recommended development setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177 SciPy structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178 2.1 2.2 2.3 Other ways to contribute . 2.4 2.5 . 2.6 Useful links, FAQ, checklist . . . . . . . . . . . . . . . . . 3 API - importing from Scipy 3.1 Guidelines for importing functions from Scipy . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.2 API definition . 181 . 181 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182 . . . . . . . . 4 Release Notes SciPy 0.14.0 Release Notes 4.1 SciPy 0.13.2 Release Notes 4.2 SciPy 0.13.1 Release Notes 4.3 SciPy 0.13.0 Release Notes 4.4 SciPy 0.12.1 Release Notes 4.5 SciPy 0.12.0 Release Notes 4.6 SciPy 0.11.0 Release Notes 4.7 SciPy 0.10.1 Release Notes 4.8 4.9 SciPy 0.10.0 Release Notes 4.10 SciPy 0.9.0 Release Notes . . . . . . . . . . . . . . . . . . . . . 185 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219 . . . . . . . . . i
4.11 SciPy 0.8.0 Release Notes . 4.12 SciPy 0.7.2 Release Notes . 4.13 SciPy 0.7.1 Release Notes . 4.14 SciPy 0.7.0 Release Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229 5 Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Constants (scipy.constants) . Clustering package (scipy.cluster) 235 . 235 . . 235 . . . . . . . . . . . 239 . 254 . 268 . . . . . . . . . . . . . . . . . 283 Integration and ODEs (scipy.integrate) . . . . . . . . . . . . . . . . . . 302 Interpolation (scipy.interpolate) . . . . . . . . . . . . . . . . . . . . . . . 361 Input and output (scipy.io) . . . . . . . . . . . . . . . . . . . . . . . . . . . 372 Linear algebra (scipy.linalg) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 415 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 416 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 416 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 429 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 434 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 441 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 441 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 441 . . 491 . . . . . . . . . . . . . . . . . . . . 500 . . . . . . . . . . . . . . . . . 509 . . . . . . . . . . . . . . . 563 . . . . . . . . . . . . . 572 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 636 . . . . . . . . . . . . . . . . . . 638 . . . . . . . . . . . . . . . . . . . 746 . . . . . . . . . . . . . . . 842 . . . . . 870 . 881 . . . . . . . . 915 . . . . . . . . . . . . . . . . . . . . . . 929 . . . . . . . . . . . . . . . . . . 972 . . . . . . 1294 . . . . . . . . . . . . . . . . . . . . . . 1319 5.1 5.2 K-means clustering and vector quantization (scipy.cluster.vq) . . . 5.3 Hierarchical clustering (scipy.cluster.hierarchy) 5.4 . . . . . 5.5 Discrete Fourier transforms (scipy.fftpack) . . . . . 5.6 5.7 5.8 5.9 . 5.10 Low-level BLAS functions . . . 5.11 Finding functions . . . 5.12 BLAS Level 1 functions . . . . 5.13 BLAS Level 2 functions . 5.14 BLAS Level 3 functions . . . 5.15 Low-level LAPACK functions . 5.16 Finding functions . . 5.17 All functions . . . 5.18 Interpolative matrix decomposition (scipy.linalg.interpolative) 5.19 Miscellaneous routines (scipy.misc) . . . 5.20 Multi-dimensional image processing (scipy.ndimage) . . . 5.21 Orthogonal distance regression (scipy.odr) . . . . . 5.22 Optimization and root finding (scipy.optimize) . . . 5.23 Nonlinear solvers . 5.24 Signal processing (scipy.signal) . . . . . . . . 5.25 Sparse matrices (scipy.sparse) . . . . . . . . 5.26 Sparse linear algebra (scipy.sparse.linalg) 5.27 Compressed Sparse Graph Routines (scipy.sparse.csgraph) . 5.28 Spatial algorithms and data structures (scipy.spatial) 5.29 Distance computations (scipy.spatial.distance) . . . . . . 5.30 Special functions (scipy.special) 5.31 Statistical functions (scipy.stats) 5.32 Statistical functions for masked arrays (scipy.stats.mstats) . . . . . . . . . 5.33 C/C++ integration (scipy.weave) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1325 1337 Bibliography Index ii
SciPy Reference Guide, Release 0.14.0 Release Date 0.14.0 May 03, 2014 SciPy (pronounced “Sigh Pie”) is open-source software for mathematics, science, and engineering. CONTENTS 1
SciPy Reference Guide, Release 0.14.0 2 CONTENTS
CHAPTER ONE SCIPY TUTORIAL 1.1 Introduction Contents • Introduction – SciPy Organization – Finding Documentation SciPy is a collection of mathematical algorithms and convenience functions built on the Numpy extension of Python. It adds significant power to the interactive Python session by providing the user with high-level commands and classes for manipulating and visualizing data. With SciPy an interactive Python session becomes a data-processing and system- prototyping environment rivaling sytems such as MATLAB, IDL, Octave, R-Lab, and SciLab. The additional benefit of basing SciPy on Python is that this also makes a powerful programming language available for use in developing sophisticated programs and specialized applications. Scientific applications using SciPy benefit from the development of additional modules in numerous niche’s of the software landscape by developers across the world. Everything from parallel programming to web and data-base subroutines and classes have been made available to the Python programmer. All of this power is available in addition to the mathematical libraries in SciPy. This tutorial will acquaint the first-time user of SciPy with some of its most important features. It assumes that the user has already installed the SciPy package. Some general Python facility is also assumed, such as could be acquired by working through the Python distribution’s Tutorial. For further introductory help the user is directed to the Numpy documentation. For brevity and convenience, we will often assume that the main packages (numpy, scipy, and matplotlib) have been imported as: >>> import numpy as np >>> import scipy as sp >>> import matplotlib as mpl >>> import matplotlib.pyplot as plt These are the import conventions that our community has adopted after discussion on public mailing lists. You will see these conventions used throughout NumPy and SciPy source code and documentation. While we obviously don’t require you to follow these conventions in your own code, it is highly recommended. 1.1.1 SciPy Organization SciPy is organized into subpackages covering different scientific computing domains. These are summarized in the following table: 3
SciPy Reference Guide, Release 0.14.0 Subpackage cluster constants fftpack integrate interpolate io linalg ndimage odr optimize signal sparse spatial special stats weave Description Clustering algorithms Physical and mathematical constants Fast Fourier Transform routines Integration and ordinary differential equation solvers Interpolation and smoothing splines Input and Output Linear algebra N-dimensional image processing Orthogonal distance regression Optimization and root-finding routines Signal processing Sparse matrices and associated routines Spatial data structures and algorithms Special functions Statistical distributions and functions C/C++ integration Scipy sub-packages need to be imported separately, for example: >>> from scipy import linalg, optimize Because of their ubiquitousness, some of the functions in these subpackages are also made available in the scipy namespace to ease their use in interactive sessions and programs. In addition, many basic array functions from numpy are also available at the top-level of the scipy package. Before looking at the sub-packages individually, we will first look at some of these common functions. 1.1.2 Finding Documentation SciPy and NumPy have documentation versions in both HTML and PDF format available at http://docs.scipy.org/, that cover nearly all available functionality. However, this documentation is still work-in-progress and some parts may be incomplete or sparse. As we are a volunteer organization and depend on the community for growth, your participation - everything from providing feedback to improving the documentation and code - is welcome and actively encouraged. Python’s documentation strings are used in SciPy for on-line documentation. There are two methods for reading them and getting help. One is Python’s command help in the pydoc module. Entering this command with no arguments (i.e. >>> help ) launches an interactive help session that allows searching through the keywords and modules available to all of Python. Secondly, running the command help(obj) with an object as the argument displays that object’s calling signature, and documentation string. The pydoc method of help is sophisticated but uses a pager to display the text. Sometimes this can interfere with the terminal you are running the interactive session within. A scipy-specific help system is also available under the command sp.info. The signature and documentation string for the object passed to the help command are printed to standard output (or to a writeable object passed as the third argument). The second keyword argument of sp.info defines the maximum width of the line for printing. If a module is passed as the argument to help than a list of the functions and classes defined in that module is printed. For example: >>> sp.info(optimize.fmin) fmin(func, x0, args=(), xtol=0.0001, ftol=0.0001, maxiter=None, maxfun=None, full_output=0, disp=1, retall=0, callback=None) Minimize a function using the downhill simplex algorithm. Parameters ---------- func : callable func(x,*args) 4 Chapter 1. SciPy Tutorial
分享到:
收藏