sklearn中文文档

Rbf(*args)

A class for radial basis function interpolation of functions from
N-D scattered data to an M-D domain.

Parameters
----------
*args : arrays
    x, y, z, ..., d, where x, y, z, ... are the coordinates of the nodes
    and d is the array of values at the nodes

1.方法种类

function : str or callable, optional
    The radial basis function, based on the radius, r, given by the norm
    (default is Euclidean distance); the default is 'multiquadric'::
 
    'multiquadric': sqrt((r/self.epsilon)**2 + 1)
        'inverse': 1.0/sqrt((r/self.epsilon)**2 + 1)
        'gaussian': exp(-(r/self.epsilon)**2)
        'linear': r
        'cubic': r**3
        'quintic': r**5
        'thin_plate': r**2 * log(r)
        If callable, then it must take 2 arguments (self, r). The epsilon
        parameter will be available as self.epsilon. Other keyword
        arguments passed in will be available as well.
epsilon : float, optional
    Adjustable constant for gaussian or multiquadrics functions
    - defaults to approximate average distance between nodes (which is
    a good start).
smooth : float, optional
    Values greater than zero increase the smoothness of the
    approximation. 0 is for interpolation (default), the function will
    always go through the nodal points in this case.
norm : str, callable, optional
    A function that returns the 'distance' between two points, with
    inputs as arrays of positions (x, y, z, ...), and an output as an
    array of distance. E.g., the default: 'euclidean', such that the result
    is a matrix of the distances from each point in ``x1`` to each point in
    ``x2``. For more options, see documentation of
    `scipy.spatial.distances.cdist`.
mode : str, optional
    Mode of the interpolation, can be '1-D' (default) or 'N-D'. When it is
    '1-D' the data `d` will be considered as 1-D and flattened
    internally. When it is 'N-D' the data `d` is assumed to be an array of
    shape (n_samples, m), where m is the dimension of the target domain.
  1. 属性
----------
N : int
    The number of data points (as determined by the input arrays).
di : ndarray
    The 1-D array of data values at each of the data coordinates `xi`.
xi : ndarray
    The 2-D array of data coordinates.
function : str or callable
    The radial basis function. See description under Parameters.
epsilon : float
    Parameter used by gaussian or multiquadrics functions. See Parameters.
smooth : float
    Smoothing parameter. See description under Parameters.
norm : str or callable
    The distance function. See description under Parameters.
mode : str
    Mode of the interpolation. See description under Parameters.
nodes : ndarray
    A 1-D array of node values for the interpolation.
A : internal property, do not use

3.Examples
--------
>>> from scipy.interpolate import Rbf
>>> x, y, z, d = np.random.rand(4, 50)
>>> rbfi = Rbf(x, y, z, d)  # radial basis function interpolator instance
>>> xi = yi = zi = np.linspace(0, 1, 20)
>>> di = rbfi(xi, yi, zi)   # interpolated values
>>> di.shape
(20,)

"""
# Available radial basis functions that can be selected as strings;

they all start with h (self._init_function relies on that)

## 2.python并行计算

1.类平行(Logger):
可读的并行映射助手类。

更多信息请参阅:ref: ’ User Guide '。

2.参数

n_jobs: int,默认:无
并发运行的作业的最大数量,如数量
当backend="multiprocessing"时的Python工作进程
或者当backend="threading"时,线程池的大小。
-1表示所有cpu。 如果给定1,则没有并行计算代码
,这对调试很有用。 对于小于-1的n_jobs,
(n_cpus + 1 + n_jobs)。 因此对于n_jobs = -2, all
只使用一个cpu。
None是’unset’的标记,将被解释为n_jobs=1
(顺序执行),除非调用是在
为设置另一个值的Parallel_backend上下文管理器
n_jobs。
backend: str, ParallelBackendBase实例或None,默认:‘loky’
指定并行后端实现。
支持后端:

-“loky”默认使用,可以诱导一些
交换输入和时的通信和内存开销
使用辅助Python进程输出数据。
-“多进程”基于前一个进程,后端基于
“multiprocessing.Pool”。 不如“loky”强大。
-“threading”是一个非常低开销的后端,但它会受到影响
从Python全局解释器锁
很大程度上依赖于Python对象。 “threading”是非常有用的
当执行瓶颈是编译后的扩展时
显式释放GIL(例如封装的Cython循环)
在“with nogil”块或对库的昂贵调用中
NumPy)。
-最后,您可以注册后端通过调用
register_parallel_backend。 这将允许您实现
你喜欢的后端。
不建议在调用中硬编码后端名称
在库中平行的。 相反,建议设置软提示
(偏好)或硬约束(要求)使之成为可能
类从外部更改后端,库用户可以使用
parallel_backend上下文管理器。
prefer: str in {‘processes’, ‘threads’}或None,默认:None
软提示选择默认后端,如果没有特定的后端
使用parallel_backend上下文管理器选择。 的
默认的基于进程的后端是“loky”和默认
基于线程的后端是“threading”。 如果’ ‘后端’ ’
参数指定。
require: ‘sharedmem’或None,默认None
硬约束选择后端。 如果设置为sharedmem,
所选的后端将是单主机的,甚至是基于线程的
如果用户请求一个非基于线程的后端
parallel_backend。
详细:int,可选的
冗长级别:如果非零,则进度消息为
打印出来。 超过50,输出被发送到标准输出。
消息的频率随着冗长程度的增加而增加。
如果大于10,则报告所有迭代。
超时:浮动,可选的
每个任务要完成的超时时间限制。 如果有任何任务需要更长的时间
a TimeOutError将被触发。 仅当n_jobs != 1时生效
Pre_dispatch: {‘all’, integer, or expression,如’3*n_jobs’}
预分派任务的批数。
默认设置是“2 * n_jobs”。 当batch_size="auto"时,这是合理的
违约,工人永远不应该挨饿。
Batch_size: int或’auto’,默认为’auto’
一次分派给每个任务的原子任务数
工人。 当个人评估非常快的时候,调度
对worker的调用可能比顺序计算慢,因为
的开销。 批处理快速计算一起可以减轻
这一点。
“自动”策略记录了批处理所需的时间
来完成,并动态调整批大小以保持时间
大概是半秒,用的是启发式。 最初的批处理
尺寸是1。
’ ’ batch_size=“auto” ’ ’ with ’ ’ backend=“threading” ’ '将调度
线程后端在同一时间分批处理单个任务
非常小的开销和使用更大的批处理大小没有被证明
在这种情况下会带来任何收益。
temp_folder: str,可选的
用于memmapping大数组的池所使用的文件夹
用于与工作进程共享内存。 如果没有,这个将尝试
顺序:

—JOBLIB_TEMP_FOLDER环境所指向的文件夹
变量,
—如果文件夹存在且可写,则输入/dev/shm
在现代Linux上默认可用的RAM磁盘文件系统
分布,
—默认的系统临时文件夹
被TMP、TMPDIR或TEMP环境覆盖
变量,通常是Unix操作系统下的/tmp。

仅当backend="loky"或"multiprocessing"时激活。
max_nbytes int, str,或None,可选,默认1M
传递给工作人员的数组大小的阈值
在temp_folder中触发自动内存映射。 可以是整型
字节,或人类可读的字符串,例如,1M表示1M。
使用None关闭大阵列的memmapping功能。
仅当backend="loky"或"multiprocessing"时激活。
mmap_mode: {None, ‘r+’, ‘r’, ‘w+’, ‘c’}
传递给工作人员的numpy数组的Memmapping模式。
更多细节请参阅’max_nbytes’参数文档。

笔记

该对象使用worker并行计算对象的应用
函数的许多不同的参数。 它带来的主要功能
除了使用原始多处理或并发。 期货API
是(详情见例子):

*更易读的代码,特别是因为它避免
构造参数列表。

*简单的调试:
-信息跟踪,即使错误发生
客户端
-使用’n_jobs=1’可以关闭并行计算
用于调试而不更改代码路径
早期捕获酸洗错误

*可选的进度计。

*使用Ctrl-C中断多进程作业

*灵活的酸洗控制的通信
工作流程。

*能够有效地使用共享内存与工人
用于基于numpy的大型数据结构的进程。

3.测试小例子

from math import sqrt
from joblib import Parallel, delayed
Parallel(n_jobs=1)(delayed(sqrt)(i**2) for i in range(10))
[0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0]

    Reshaping the output when the function has several return
    values:

    >>> from math import modf
    >>> from joblib import Parallel, delayed
    >>> r = Parallel(n_jobs=1)(delayed(modf)(i/2.) for i in range(10))
    >>> res, i = zip(*r)
    >>> res
    (0.0, 0.5, 0.0, 0.5, 0.0, 0.5, 0.0, 0.5, 0.0, 0.5)
    >>> i
    (0.0, 0.0, 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0)

    The progress meter: the higher the value of `verbose`, the more
    messages:

    >>> from time import sleep
    >>> from joblib import Parallel, delayed
    >>> r = Parallel(n_jobs=2, verbose=10)(delayed(sleep)(.2) for _ in range(10)) #doctest: +SKIP
    [Parallel(n_jobs=2)]: Done   1 tasks      | elapsed:    0.6s
    [Parallel(n_jobs=2)]: Done   4 tasks      | elapsed:    0.8s
    [Parallel(n_jobs=2)]: Done  10 out of  10 | elapsed:    1.4s finished

    Traceback example, note how the line of the error is indicated
    as well as the values of the parameter passed to the function that
    triggered the exception, even though the traceback happens in the
    child process:

    >>> from heapq import nlargest
    >>> from joblib import Parallel, delayed
    >>> Parallel(n_jobs=2)(delayed(nlargest)(2, n) for n in (range(4), 'abcde', 3)) #doctest: +SKIP
    #...
     



    >>> from math import sqrt
    >>> from joblib import Parallel, delayed
    >>> def producer():
    ...     for i in range(6):
    ...         print('Produced %s' % i)
    ...         yield i
    >>> out = Parallel(n_jobs=2, verbose=100, pre_dispatch='1.5*n_jobs')(
    ...                delayed(sqrt)(i) for i in producer()) #doctest: +SKIP
    Produced 0
    Produced 1
    Produced 2
    [Parallel(n_jobs=2)]: Done 1 jobs     | elapsed:  0.0s
    Produced 3
    [Parallel(n_jobs=2)]: Done 2 jobs     | elapsed:  0.0s
    Produced 4
    [Parallel(n_jobs=2)]: Done 3 jobs     | elapsed:  0.0s
    Produced 5
    [Parallel(n_jobs=2)]: Done 4 jobs     | elapsed:  0.0s
    [Parallel(n_jobs=2)]: Done 6 out of 6 | elapsed:  0.0s remaining: 0.0s
    [Parallel(n_jobs=2)]: Done 6 out of 6 | elapsed:  0.0s finished

'''


更多推荐