Tag: scipy

ImportError:无法导入名称NUMPY_MKL

我试图运行以下简单的代码 import scipy scipy.test() 但是我收到以下错误 Traceback (most recent call last): File "<stdin>", line 1, in <module> File "C:\Python27\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 586, in runfile execfile(filename, namespace) File "C:/Users/Mustafa/Documents/My Python Code/SpectralGraphAnalysis/main.py", line 8, in <module> import scipy File "C:\Python27\lib\site-packages\scipy\__init__.py", line 61, in <module> from numpy._distributor_init import NUMPY_MKL # requires numpy+mkl ImportError: cannot import name NUMPY_MKL 我在Windows 10下使用python 2.7。 […]

重新采样表示图像的numpy数组

我正在寻找如何以一个新的尺寸重新取样代表图像数据的numpy数组,最好有一个插值方法的select(最近的,双线性等)。 我知道有 scipy.misc.imresize 这是通过包装PIL的resizefunction来完成的。 唯一的问题是,因为它使用PIL,numpy数组必须符合图像格式,给我最多4个“彩色”通道。 我希望能够调整任意图像的大小,使用任何数量的“颜色”通道。 我想知道是否有一个简单的方法来做这个scipy / numpy,或者如果我需要推出自己的。 对于如何自己制作一个我有两个想法: 一个在每个通道上分别运行scipy.misc.imresize的函数 创build我自己的使用scipy.ndimage.interpolation.affine_transform 第一个对于大数据可能会很慢,第二个似乎没有提供除了样条的其他插值方法。

直方图Matplotlib

所以我有一个小问题。 我有一个已经在直方图格式的scipy数据集,所以我有bin的中心和每个bin的事件数量。 我现在如何绘制直方图。 我只是试着做 bins, n=hist() 但它不是那样的。 任何build议?

无法通过pip安装Scipy

在通过pip安装scipy时: pip install scipy 点未能build立scipy并引发以下错误: Cleaning up… Command /Users/administrator/dev/KaggleAux/env/bin/python2.7 -c "import setuptools, tokenize;__file__='/Users/administrator/dev/KaggleAux/env/build/scipy/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install –record /var/folders/zl/7698ng4d4nxd49q1845jd9340000gn/T/pip-eO8gua-record/install-record.txt –single-version-externally-managed –compile –install-headers /Users/administrator/dev/KaggleAux/env/bin/../include/site/python2.7 failed with error code 1 in /Users/administrator/dev/KaggleAux/env/build/scipy Storing debug log for failure in /Users/administrator/.pip/pip.log 我怎样才能让scipy成功build立? 这可能是OSX优胜美地的一个新问题,因为我刚刚升级,之前没有安装scipy的问题。 debugging日志: Cleaning up… Removing temporary dir /Users/administrator/dev/KaggleAux/env/build… Command /Users/administrator/dev/KaggleAux/env/bin/python2.7 -c "import setuptools, tokenize;__file__='/Users/administrator/dev/KaggleAux/env/build/scipy/setup.py';exec(compile(getattr(tokenize, 'open', […]

如何在Python中做指数和对数曲线拟合? 我发现只有多项式拟合

我有一组数据,我想比较哪一行最好地描述它(不同阶的多项式,指数或对数)。 我使用Python和Numpy和多项式拟合有一个函数polyfit() 。 但是我没有发现这样的指数和对数拟合函数。 有没有? 或者如何解决呢?

以便携式数据格式保存/加载scipy sparse csr_matrix

如何以便携式格式保存/加载scipy sparse csr_matrix ? scipy稀疏matrix是在Python 3(Windows 64位)上创build的,可以在Python 2(Linux 64位)上运行。 最初,我使用pickle(协议= 2和fix_imports = True),但是从Python 3.2.2(Windows 64位)到Python 2.7.2(Windows 32位)不起作用,并且出现错误: TypeError: ('data type not understood', <built-in function _reconstruct>, (<type 'numpy.ndarray'>, (0,), '[98]')). 接下来,尝试了numpy.save和numpy.load以及scipy.io.mmwrite()和scipy.io.mmread() ,这些方法都没有工作。

在python中用scipy / numpy合并数据

有没有一种更有效的方法来在预先指定的箱子中取一个数组的平均值? 例如,我有一个数组数组和数组,对应于该数组中的开始和结束位置,我想只是在这些箱中的意思? 我有下面的代码,但我想知道如何可以减less和改善。 谢谢。 from scipy import * from numpy import * def get_bin_mean(a, b_start, b_end): ind_upper = nonzero(a >= b_start)[0] a_upper = a[ind_upper] a_range = a_upper[nonzero(a_upper < b_end)[0]] mean_val = mean(a_range) return mean_val data = rand(100) bins = linspace(0, 1, 10) binned_data = [] n = 0 for n in range(0, len(bins)-1): b_start = […]

如何使用NumPy来计算移动平均线?

似乎没有任何function简单地计算numpy / scipy上的移动平均值,导致了复杂的解决scheme 。 我的问题是双重的: (正确)用numpy实现移动平均线的最简单方法是什么? 由于这似乎不平凡和容易出错,是否有一个很好的理由不包括在这种情况下的电池 ?

Python中的多重线性回归

我似乎无法find任何执行多重回归的Python库。 我发现的唯一的事情只做简单的回归。 我需要将我的因variables(y)与几个独立variables(x1,x2,x3等)进行比较。 例如,用这个数据: print 'y x1 x2 x3 x4 x5 x6 x7' for t in texts: print "{:>7.1f}{:>10.2f}{:>9.2f}{:>9.2f}{:>10.2f}{:>7.2f}{:>7.2f}{:>9.2f}" / .format(ty,t.x1,t.x2,t.x3,t.x4,t.x5,t.x6,t.x7) (输出以上:) y x1 x2 x3 x4 x5 x6 x7 -6.0 -4.95 -5.87 -0.76 14.73 4.02 0.20 0.45 -5.0 -4.55 -4.52 -0.71 13.74 4.47 0.16 0.50 -10.0 -10.96 -11.64 -0.98 15.49 4.18 0.19 0.53 -5.0 […]

在32位Windows 7机器上的Python 3.5中安装scipy

我一直在试图安装Scipy到我的Windows 7机器上的Python 3.5(32位)安装使用预构build的二进制文件: http : //www.lfd.uci.edu/~gohlke/pythonlibs 我有,为了,安装了以下库 numpy‑1.10.1+mkl‑cp35‑none‑win32.whl scipy‑0.16.1‑cp35‑none‑win32.whl 然后,当试图使用安装的软件包时,我得到以下的错误 from scipy import sparse < … Complete error trace ommitted … > packages\scipy\sparse\csr.py", line 13, in <module> from ._sparsetools import csr_tocsc, csr_tobsr, csr_count_blocks, \ ImportError: DLL load failed: The specified module could not be found. 但是,如果我按照Python 3.4的相同过程replace安装程序: numpy‑1.10.1+mkl‑cp35‑none‑win32.whl scipy‑0.16.1‑cp35‑none‑win32.whl 一切似乎工作。 是否有额外的依赖关系或安装我缺less的Python 3.5安装包?