资源简介

Python科学计算最佳实践——SciPy指南(Elegant SciPy),包含代码和数据源 SciPy Python 源代码

资源截图

代码片段和文件信息

import numpy as np
from scipy import sparse


def invert_nonzero(arr):
    arr_inv = arr.copy()
    nz = np.nonzero(arr)
    arr_inv[nz] = 1 / arr[nz]
    return arr_inv


def xlogx(arr):
    arrlog = arr.copy()
    nz = np.nonzero(arr)
    arrlog[nz] = arr[nz] * np.log2(arr[nz])
    return arrlog


def vi(x y):
    pxy = sparse.coo_matrix((np.ones(x.size) (x.ravel() y.ravel()))
                            dtype=float).tocsr()
    pxy.data /= np.sum(pxy.data)
    px = np.array(pxy.sum(axis=1)).ravel()
    py = np.array(pxy.sum(axis=0)).ravel()
    px_inv = sparse.diags([invert_nonzero(px)] [0])
    py_inv = sparse.diags([invert_nonzero(py)] [0])
    hygx = -(px * xlogx(py_inv.dot(pxy)).sum(axis=0)).sum()
    hxgy = -(py * xlogx(pxy.dot(px_inv)).sum(axis=1)).sum()
    return hygx + hx

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2019-03-18 21:44  elegant-scipy-master\
     文件          70  2019-03-18 21:44  elegant-scipy-master\.boto
     文件         220  2019-03-18 21:44  elegant-scipy-master\.gitignore
     文件         104  2019-03-18 21:44  elegant-scipy-master\.gitmodules
     目录           0  2019-03-18 21:44  elegant-scipy-master\.matplotlib\
     文件          20  2019-03-18 21:44  elegant-scipy-master\.matplotlib\matplotlibrc
     文件        1238  2019-03-18 21:44  elegant-scipy-master\.travis.yml
     文件         342  2019-03-18 21:44  elegant-scipy-master\CONTRIBUTING.md
     文件        1561  2019-03-18 21:44  elegant-scipy-master\LICENSE-CODE.md
     文件       19120  2019-03-18 21:44  elegant-scipy-master\LICENSE.md
     文件        5229  2019-03-18 21:44  elegant-scipy-master\Makefile
     目录           0  2019-03-18 21:44  elegant-scipy-master\OReilly_HTMLBook\
     文件        4791  2019-03-18 21:44  elegant-scipy-master\README.md
     目录           0  2019-03-18 21:44  elegant-scipy-master\_images\
     文件       63516  2019-03-18 21:44  elegant-scipy-master\_images\cover.jpg
     目录           0  2019-03-18 21:44  elegant-scipy-master\data\
     文件      152630  2019-03-18 21:44  elegant-scipy-master\data\00998v.jpg
     文件       66328  2019-03-18 21:44  elegant-scipy-master\data\ConnOrdered_040903.mat
     文件       18056  2019-03-18 21:44  elegant-scipy-master\data\NeuronTypeOrdered_040903.mat
     文件         299  2019-03-18 21:44  elegant-scipy-master\data\Nightingale-sound.license
     文件      732392  2019-03-18 21:44  elegant-scipy-master\data\Nightingale-sound.mp3
     文件      311444  2019-03-18 21:44  elegant-scipy-master\data\chem-network.npy
     文件    11657845  2019-03-18 21:44  elegant-scipy-master\data\counts.txt.bz2
     文件         589  2019-03-18 21:44  elegant-scipy-master\data\expr.tsv
     文件      311444  2019-03-18 21:44  elegant-scipy-master\data\gap-network.npy
     文件      361181  2019-03-18 21:44  elegant-scipy-master\data\genes.csv
     文件         300  2019-03-18 21:44  elegant-scipy-master\data\iris-target.csv
     文件       15000  2019-03-18 21:44  elegant-scipy-master\data\iris.csv
     文件         359  2019-03-18 21:44  elegant-scipy-master\data\neuron-types.npy
     文件        5660  2019-03-18 21:44  elegant-scipy-master\data\neurons.npy
     文件     1352368  2019-03-18 21:44  elegant-scipy-master\data\nightingale.wav
............此处省略95个文件信息

评论

共有 条评论