定量分析方法第04講:Scipy基礎

2021-01-11 Python研究生

from IPython.core.interactiveshell import InteractiveShell
from IPython.display import display, Latex
InteractiveShell.ast_node_interactivity = "all"

Scipy

SciPy是基於NumPy的擴展,是數學算法的集合。

scipy.io: 數據輸入輸出

scipy.integrate: 積分

scipy.interpolate: 插值

scipy.linalg: 線性代數

scipy.optimize: 優化

scipy.cluster: 聚類

scipy.constants: 物理和數學常量

scipy.fftpack: 傅立葉變換

scipy.ndimage: n維圖像包

scipy.odr: 正交距離回歸

scipy.signal: 信號處理

scipy.sparse: 稀疏矩陣

scipy.spatial: 空間數據結構和算法

scipy.special: 一些特殊的數學函數

scipy.stats: 統計

積分

import numpy as np
import scipy.integrate as integrate
(a,error) = integrate.quad(lambda x: 1, 0, 4)
a,error
integrate.quad(lambda x: x**2, 0, 4)
invexp = lambda x: np.exp(-x)
integrate.quad(invexp, 0, np.inf)
y = lambda x: 1 if x<=0 else 0
integrate.quad(y, -1, 1)

插值

SciPy通用插值工具可用於1、2和更高維度的數據:

表示1-D中插值(interp1d)的類,提供了幾種插值方法。

griddata可以進行N維內插(N = 1,2,3,4,…)。

基於FORTRAN庫FITPACK的一維和二維(平滑)三次樣條插值函數。

使用徑向基函數進行插值。

from scipy.interpolate import interp1d
import matplotlib.pyplot as plt

x = np.linspace(0, 10, num=11, endpoint=True)
y = np.cos(x)
f = interp1d(x, y)
f2 = interp1d(x, y, kind='cubic')

xnew = np.linspace(0, 10, num=41, endpoint=True)
_= plt.plot(x, y, 'o', xnew, f(xnew), '-', xnew, f2(xnew), '--')
_= plt.legend(['data', 'linear', 'cubic'], loc='best')
plt.show()

def func(x, y):
return x*(1-x)*np.cos(4*np.pi*x) * np.sin(4*np.pi*y**2)**2
grid_x, grid_y = np.mgrid[0:1:100j, 0:1:200j]
grid_x.shape
grid_y.shape
points = np.random.rand(1000, 2)
values = func(points[:,0], points[:,1])
from scipy.interpolate import griddata
grid_z0 = griddata(points, values, (grid_x, grid_y), method='nearest')
grid_z1 = griddata(points, values, (grid_x, grid_y), method='linear')
grid_z2 = griddata(points, values, (grid_x, grid_y), method='cubic')
grid_z0.shape

import matplotlib.pyplot as plt
_= plt.subplot(221)
_= plt.imshow(func(grid_x, grid_y).T, extent=(0,1,0,1), origin='lower')
_= plt.plot(points[:,0], points[:,1], 'k.', ms=1)
_= plt.title('Original')
_= plt.subplot(222)
_= plt.imshow(grid_z0.T, extent=(0,1,0,1), origin='lower')
_= plt.title('Nearest')
_= plt.subplot(223)
_= plt.imshow(grid_z1.T, extent=(0,1,0,1), origin='lower')
_= plt.title('Linear')
_= plt.subplot(224)
_= plt.imshow(grid_z2.T, extent=(0,1,0,1), origin='lower')
_= plt.title('Cubic')
_= plt.gcf().set_size_inches(6, 6)
plt.show()

圖像處理

import scipy
from scipy import ndimage
from matplotlib import pyplot
import numpy as np
import scipy.ndimage as nd

img = pyplot.imread("wx.jpg")
pyplot.imsave("wx_1.jpg", img)
_= pyplot.imshow(img)
type(img),img.shape

from scipy.ndimage import correlate
a = np.arange(10)
a
correlate(a, [1, 1, 1])
correlate(a, [1, 1, 1], output=np.float64)

a = np.arange(25).reshape(5,5)
a
pyplot.imshow(a)

weights = [[9, 9, 9],
[0, 1, 0],
[0, 0, 0]]
b = correlate(a, weights)
pyplot.imshow(b)

from scipy import misc
f = misc.face()
# misc.imsave('face.png', f) # uses the Image module (PIL)
f.shape, f.dtype

import matplotlib.pyplot as plt
plt.imshow(f)
plt.show()

face = misc.face(gray=True)
face.mean(), face.max(), face.min()

import scipy.misc
import matplotlib.pyplot as plt

f = scipy.misc.face(gray=True)

_= plt.figure(figsize=(10, 3.6))

_= plt.subplot(131)
_= plt.imshow(f, cmap=plt.cm.gray)

_= plt.subplot(132)
_= plt.imshow(f, cmap=plt.cm.gray, vmin=30, vmax=200)
_= plt.axis('off')

_= plt.subplot(133)
_= plt.imshow(f, cmap=plt.cm.gray)
_= plt.contour(f, [50, 200])
_= plt.axis('off')

_= plt.subplots_adjust(wspace=0, hspace=0., top=0.99, bottom=0.01, left=0.05,right=0.99)
plt.show()

import numpy as np
import scipy.misc
from scipy import ndimage
import matplotlib.pyplot as plt

face = scipy.misc.face(gray=True)
lx, ly = face.shape
# Cropping
crop_face = face[lx//4:-lx//4, ly//4:-ly//4]
# up <-> down flip
flip_ud_face = np.flipud(face)
# rotation
rotate_face = ndimage.rotate(face, 45)
rotate_face_noreshape = ndimage.rotate(face, 45, reshape=False)

plt.figure(figsize=(12.5, 2.5))

#plt.subplot(151)
#plt.imshow(face, cmap=plt.cm.gray)
_= plt.axis('off')
_= plt.subplot(152)
_= plt.imshow(crop_face, cmap=plt.cm.gray)
_= plt.axis('off')
_= plt.subplot(153)
_= plt.imshow(flip_ud_face, cmap=plt.cm.gray)
_= plt.axis('off')
_= plt.subplot(154)
_= plt.imshow(rotate_face, cmap=plt.cm.gray)
_= plt.axis('off')
_= plt.subplot(155)
_= plt.imshow(rotate_face_noreshape, cmap=plt.cm.gray)
_= plt.axis('off')

_= plt.subplots_adjust(wspace=0.02, hspace=0.3, top=1, bottom=0.1, left=0, right=1)

_= plt.show()

import scipy
from scipy import ndimage
import matplotlib.pyplot as plt

f = scipy.misc.face(gray=True).astype(float)
blurred_f = ndimage.gaussian_filter(f, 3)

filter_blurred_f = ndimage.gaussian_filter(blurred_f, 1)

alpha = 30
sharpened = blurred_f + alpha * (blurred_f - filter_blurred_f)

_= plt.figure(figsize=(12, 4))

_= plt.subplot(131)
_= plt.imshow(f, cmap=plt.cm.gray)
_= plt.axis('off')
_= plt.subplot(132)
_= plt.imshow(blurred_f, cmap=plt.cm.gray)
_= plt.axis('off')
_= plt.subplot(133)
_= plt.imshow(sharpened, cmap=plt.cm.gray)
_= plt.axis('off')

_= plt.tight_layout()
_= plt.show()

多維圖像處理函數

Filters

convolve: 多維卷積。

convolve1d: 沿給定軸計算一維卷積。

correlate: 多維相關。

correlate1d: 沿給定軸計算一維相關性。

ga* ssian_filter: 多維高斯濾波器。

ga* ssian_filter1d: 一維高斯濾波器。

ga ssian_gradient_magnit de: 高斯導數多維梯度。

ga* ssian_laplace: 高斯二階導數多維拉普拉斯濾波器。

generic_filter: 使用給定的函數計算多維過濾器。

generic_filter1d: 沿給定軸計算一維濾波器。

generic_gradient_magnit* de: 使用梯度函數計算梯度。

generic_laplace: N-D拉普拉斯濾波器。

laplace: 基於近似二階導數的N-D拉普拉斯濾波器。

maxim* m_filter: 多維最大過濾器。

maxim* m_filter1d: 沿給定軸計算一維最大濾波器。

median_filter: 多維中值濾波器。

minim* m_filter: 多維最小過濾器。

minim* m_filter1d: 沿給定軸計算一維最小濾波器。

percentile_filter: 計算多維百分比濾波器。

prewitt: Prewitt過濾器。

rank_filter: 多維等級過濾器。

sobel: Sobel濾波器。

uniform_filter: 多維均勻過濾器。

uniform_filter1d: 沿給定軸計算一維均勻濾波器。

Fourier filters

fourier_ellipsoid: 多維橢球傅立葉濾波器。

fourier_gaussian: 多維高斯傅立葉濾波器。

fourier_shift: 多維傅立葉移位濾波器。

fourier_uniform: 多維均勻傅立葉濾波器。

Interpolation

affine_transform: 仿射變換。

geometric_transform: 幾何變換。

map_coordinates: 通過插值將輸入數組映射到新坐標。

rotate: 旋轉數組。

shift: 移位數組。

spline_filter: 多維樣條濾波器。

spline_filter1d: 沿給定軸計算一維樣條濾波器。

zoom: 縮放數組。

Measurements

center_of_mass: 計算標籤處數組值的質心。

extrema: 標籤處數組的最小值和最大值及其位置。

find_objects: 在標記數組中查找對象。

histogram: 數組值的直方圖。

label: 在數組中標註。

labeled_comprehension: 。

maximum: 標記區域上數組的最大值。

maximum_position: 在標籤處找到數組值的最大值的位置。

mean: 標籤處數組值的平均值。

median: 標記區域上數組值的中位數。

minim* m: 標記區域上數組的最小值。

minim* m_position: 在標籤處找到數組的最小值的位置。

standard_deviation: N-D圖像陣列的值的標準偏差,可以指定子區域。

s* m: 數組總和。

variance: 方差,可以指定子區域。

watershed_ift: 使用圖像森林變換算法

Morphology

binary_closing: 使用給定的結構化元素進行多維二進位關閉。

binary_dilation: 具有給定結構元素的多維二進位膨脹。

binary_erosion: 具有給定結構元素的多維二元侵蝕。

binary_fill_holes: 填充二進位對象中的孔。

binary_hit_or_miss: 多維二進位命中或失敗變換。

binary_opening: 具有給定結構元素的多維二進位開放。

binary_propagation: 具有給定結構元素的多維二進位傳播。

black_tophat: 多維黑色高帽過濾器。

distance_transform_bf: 通過蠻力算法實現距離變換功能。

distance_transform_cdt: 倒角類型轉換的距離轉換。

distance_transform_edt: 精確的歐氏距離變換。

generate_binary_structure: 為二進位形態學運算生成二進位結構。

grey_closing: 多維灰度關閉。

grey_dilation: 使用結構化元素或對應於平面結構化元素的足跡計算灰度擴展。

grey_erosion: 使用結構化元素或對應於平面結構化元素的足跡計算灰度侵蝕。

grey_opening: 多維灰度開口。

iterate_structure: 通過自身擴展來迭代結構。

morphological_gradient: 多維形態梯度。

morphological_laplace: 多維形態拉普拉斯。

white_tophat: 多維白色禮帽過濾器。

線性代數(scipy.linalg)scipy.linalg和numpy.linalgnumpy.matrix與2-D numpy.ndarray

numpy.matrix是矩陣類,具有比numpy.ndarray更方便的接口,用於矩陣操作。

numpy.matrix支持例如類似於MATLAB的創建語法

numpy.matrix的星號運算符,表示矩陣乘法,I和T成員作逆和轉置運算

import numpy as np
A = np.mat('[1 2;3 4]')
A
A.I
b = np.mat('[5 6]')
b
b.T
A*b.T

import numpy as np
from scipy import linalg
A = np.array([[1,3,5],[2,5,1],[2,3,8]])
A
linalg.inv(A)
np.round(A.dot(linalg.inv(A)))

We want to fit a quadratic polynomial of the form y = a + b*x**2 to this data. We first form the 「design matrix」 M, with a constant column of 1s and a column containing x**2。
We want to find the least-squares solution to M.dot(p) = y, where p is a vector with length 2 that holds the parameters a and b.

from scipy.linalg import lstsq
import matplotlib.pyplot as plt
x = np.array([1, 2.5, 3.5, 4, 5, 7, 8.5])
y = np.array([0.3, 1.1, 1.5, 2.0, 3.2, 6.6, 8.6])
M = x[:, np.newaxis]**[0, 2]
p, res, rnk, s = lstsq(M, y)
p
_= plt.plot(x, y, 'o', label='data')
xx = np.linspace(0, 9, 101)
yy = p[0] + p[1]*xx**2
_= plt.plot(xx, yy, label='least squares fit, $y = a + bx^2$')
_= plt.xlabel('x')
_= plt.ylabel('y')
_= plt.legend(framealpha=1, shadow=True)
_= plt.grid(alpha=0.25)
_= plt.show()

聚類(scipy.cluster)scipy.cluster.vqscipy.cluster.hierarchy

層次結構模塊提供了用於層次結構和聚類的功能。它從距離矩陣生成層次聚類,計算聚類的統計信息,剪切連結以生成平坦聚類以及使用樹狀圖可視化聚類。

from scipy.cluster.vq import kmeans2
import matplotlib.pyplot as plt

np.random.seed(12345678)
a = np.random.multivariate_normal([0, 6], [[2, 1], [1, 1.5]], size=45)
b = np.random.multivariate_normal([2, 0], [[1, -1], [-1, 3]], size=30)
c = np.random.multivariate_normal([6, 4], [[5, 0], [0, 1.2]], size=25)
z = np.concatenate((a, b, c))
np.random.shuffle(z)
z[:5]

centroid, label = kmeans2(z, 3, minit='points')
centroid
label
counts = np.bincount(label)
counts

w0 = z[label == 0]
w1 = z[label == 1]
w2 = z[label == 2]
_= plt.plot(w0[:, 0], w0[:, 1], 'o', alpha=0.5, label='cluster 0')
_= plt.plot(w1[:, 0], w1[:, 1], 'd', alpha=0.5, label='cluster 1')
_= plt.plot(w2[:, 0], w2[:, 1], 's', alpha=0.5, label='cluster 2')
_= plt.plot(centroid[:, 0], centroid[:, 1], 'k*', label='centroids')
_= plt.axis('equal')
_= plt.legend(shadow=True)
_= plt.show()

from scipy.cluster import hierarchy
import matplotlib.pyplot as plt
from scipy.spatial.distance import pdist

ytdist = np.array([662., 877., 255., 412., 996., 295., 468.])
ytdist2 = ytdist[:,np.newaxis]*[1,0]
C = hierarchy.ward(pdist(ytdist2))
hierarchy.fcluster(C, t=2,criterion='maxclust')

Z = hierarchy.linkage(ytdist2, 'single')
_= plt.figure()
dn = hierarchy.dendrogram(Z)

X = [[0, 0], [0, 1], [1, 0],
[0, 4], [0, 3], [1, 4],
[4, 0], [3, 0], [4, 1],
[4, 4], [3, 4], [4, 3]]
C = hierarchy.ward(pdist(X))
hierarchy.fcluster(C, t=2,criterion='maxclust')
_= plt.figure()
Z = hierarchy.linkage(C, 'single')
dn = hierarchy.dendrogram(Z)

稀疏圖

Fast graph algorithms based on sparse matrix representations.

connected_components:連接子圖

laplacian:有向圖的拉普拉斯矩陣。

shortest_path:最短路徑圖

dijkstra:Dijkstra算法

floyd_warshall:使用Floyd-Warshall算法計算最短路徑長度

bellman_ford:使用Bellman-Ford算法計算最短路徑長度。

johnson:使用Johnson的算法計算最短路徑長度。

breadth_first_order:廣度優先遍歷。

depth_first_order:深度優先遍歷。

depth_first_tree:深度優先遍歷生成的樹。

minimum_spanning_tree:無向圖的最小生成樹

reverse_cuthill_mckee:返回以反向Cuthill McKee排序對稀疏CSR或CSC矩陣排序的置換數組。

maximum_flow:最大流。

maximum_bipartite_matching:二分圖匹配。

structure_rank:計算具有給定稀疏模式的圖結構秩

construct_dist_matrix:構造距離矩陣

csgraph_from_dense:從稠密圖構造CSR格式的稀疏圖。

csgraph_from_masked:從掩碼數組構造CSR格式的圖。

csgraph_masked_from_dense:從稠密圖構造。

csgraph_to_dense:將稀疏圖表示轉換為稠密圖。

csgraph_to_masked:將稀疏圖形表示為掩碼圖。

from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import connected_components

graph = [
[ 0, 1 , 1, 0 , 0 ],
[ 0, 0 , 1 , 0 ,0 ],
[ 0, 0, 0, 0, 0],
[0, 0 , 0, 0, 1],
[0, 0, 0, 0, 0]
]
graph = csr_matrix(graph)
print(graph)
n_components, labels = connected_components(csgraph=graph, directed=False, return_labels=True)
n_components
labels

from scipy.sparse.csgraph import shortest_path

graph = [
[0, 1, 2, 0],
[0, 0, 0, 1],
[2, 0, 0, 3],
[0, 0, 0, 0]
]
graph = csr_matrix(graph)
dist_matrix, predecessors = shortest_path(csgraph=graph,
directed=False, indices=0, return_predecessors=True)
dist_matrix
predecessors

from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import floyd_warshall

graph = [
[0, 1 , 2, 0],
[0, 0, 0, 1],
[2, 0, 0, 3],
[0, 0, 0, 0]
]
graph = csr_matrix(graph)
print(graph)

dist_matrix, predecessors = floyd_warshall(csgraph=graph, directed=False, return_predecessors=True)
dist_matrix
predecessors

優化與求根(scipy.optimize)標量函數(Scalar function)優化

def f(x):
return (x - 2) * x * (x + 2)**2

from scipy.optimize import minimize_scalar
res = minimize_scalar(f)
res.x

res = minimize_scalar(f, bounds=(-3, -1), method='bounded')
res.x

局部多變量優化

from scipy.optimize import minimize, rosen, rosen_der
x0 = [1.3, 0.7, 0.8, 1.9, 1.2]
res = minimize(rosen, x0, method='Nelder-Mead', tol=1e-6)
res.x

res = minimize(rosen, x0, method='BFGS', jac=rosen_der,
options={'gtol': 1e-6, 'disp': True})
res.x

help(rosen)
help(rosen_der)

fun = lambda x: (x[0] - 1)**2 + (x[1] - 2.5)**2
cons = ({'type': 'ineq', 'fun': lambda x: x[0] - 2 * x[1] + 2},
{'type': 'ineq', 'fun': lambda x: -x[0] - 2 * x[1] + 6},
{'type': 'ineq', 'fun': lambda x: -x[0] + 2 * x[1] + 2})
# Constraint type: eq = equality, ineq = inequality.
bnds = ((0, None), (0, None))
res = minimize(fun, (2, 0), method='SLSQP', bounds=bnds,constraints=cons)
res

全局(Global)優化

basinhopping: basin-hopping algorithm

brute: Minimize a function over a given range by brute force.

differential_evolution,差分進化: Finds the global minimum of a multivariate function.

shgo: Finds the global minimum of a function using SHG optimization.

dual_annealing, 模擬退火: Find the global minimum of a function using Dual Annealing.

from scipy.optimize import dual_annealing
func = lambda x: np.sum(x*x - 10*np.cos(2*np.pi*x)) + 10*np.size(x)
lw = [-5.12] * 10
up = [5.12] * 10
ret = dual_annealing(func, bounds=list(zip(lw, up)), seed=1234)
ret.x

from scipy.optimize import differential_evolution
import numpy as np
def ackley(x):
arg1 = -0.2 * np.sqrt(0.5 * (x[0] ** 2 + x[1] ** 2))
arg2 = 0.5 * (np.cos(2. * np.pi * x[0]) + np.cos(2. * np.pi * x[1]))
return -20. * np.exp(arg1) - np.exp(arg2) + 20. + np.e
bounds = [(-5, 5), (-5, 5)]
result = differential_evolution(ackley, bounds)
result.x, result.fun

最小二乘與曲線擬合

Nonlinear least-squares

`least_squares: Solve a nonlinear least-squares problem with bounds on the variables.

Linear least-squares

nnls: Solve argmin_x || Ax - b ||_2 for x>=0.

lsq_linear: Solve a linear least-squares problem with bounds on the variables.

Curve fitting

curve_fit: Use non-linear least squares to fit a function, f, to data.

import matplotlib.pyplot as plt
from scipy.optimize import curve_fit

def func(x, a, b, c):
return a * np.exp(-b * x) + c

xdata = np.linspace(0, 4, 50)
y = func(xdata, 2.5, 1.3, 0.5)
np.random.seed(1729)
y_noise = 0.2 * np.random.normal(size=xdata.size)
ydata = y + y_noise
_= plt.plot(xdata, ydata, 'b-', label='data')

popt, pcov = curve_fit(func, xdata, ydata)
popt

_= plt.plot(xdata, func(xdata, *popt), 'r-', label='fit: a=%5.3f, b=%5.3f, c=%5.3f' % tuple(popt))

popt, pcov = curve_fit(func, xdata, ydata, bounds=(0, [3., 1., 0.5]))
popt

_= plt.plot(xdata, func(xdata, *popt), 'g--', label='fit: a=%5.3f, b=%5.3f, c=%5.3f' % tuple(popt))

_= plt.xlabel('x')
_= plt.ylabel('y')
_= plt.legend()
_= plt.show()

求根(Root)

from scipy import optimize

def fun(x):
return [x[0] + 0.5 * (x[0] - x[1])**3 - 1.0,
0.5 * (x[1] - x[0])**3 + x[1]]

def jac(x):
return np.array([[1 + 1.5 * (x[0] - x[1])**2,
-1.5 * (x[0] - x[1])**2],
[-1.5 * (x[1] - x[0])**2,
1 + 1.5 * (x[1] - x[0])**2]])

sol = optimize.root(fun, [0, 0], jac=jac, method='hybr')
sol.x

線性規劃

scipy.optimize.linprog

c = [-1, 4]
A = [[-3, 1], [1, 2]]
b = [6, 4]
x0_bounds = (None, None)
x1_bounds = (-3, None)
from scipy.optimize import linprog
res = linprog(c, A_ub=A, b_ub=b, bounds=[x0_bounds, x1_bounds])
res

res = linprog(c, A_ub=A, b_ub=b, bounds=[x0_bounds, x1_bounds], method='revised simplex')
print(res)

計算幾何

Spatial data structures and algorithms (scipy.spatial)

triangulations, Voronoi diagrams, and convex hulls

KDTree: nearest-neighbor point queries,

utilities for distance computations in various metrics.

from scipy.spatial import ConvexHull
points = np.random.rand(30, 2) # 30 random points in 2-D
hull = ConvexHull(points)
import matplotlib.pyplot as plt
_= plt.plot(points[:,0], points[:,1], 'o')
for simplex in hull.simplices:
_= plt.plot(points[simplex,0], points[simplex,1], 'k-')
_= plt.show()

信號處理

Signal Processing (scipy.signal)

some filtering functions, a limited set of filter design tools, and

a few B-spline interpolation algorithms for 1- and 2-D data.

sepfir2d: apply a separable 2-D FIR filter with mirror-symmetric boundary conditions to the spline coefficients.

import numpy as np
from scipy import signal, misc
import matplotlib.pyplot as plt

image = misc.ascent()

_= plt.figure()
_= plt.imshow(image)
_= plt.gray()
_= plt.title('Original image')
_= plt.show()

w = signal.gaussian(50, 10.0) # Return a Gaussian window
image_new = signal.sepfir2d(image, w, w)

_= plt.figure()
_= plt.imshow(image_new)
_= plt.gray()
_= plt.title('Filtered image')
_= plt.show()

傅立葉變換

Fourier Transforms (scipy.fft)

統計

Statistics (scipy.stats)



相關

定量分析方法第01講:課程概況

定量分析方法第02講:Python基礎

定量分析方法第03講:Numpy基礎

主題

優化問題、模型與算法

旅行商問題(Traveling Salesman Problem)求解算法

[公開課] 物流系統優化與決策: 旅行商問題

[公開課] 物流系統優化與決策: 旅行商問題

[公開課] 物流系統優化與決策: 無容量約束倉庫選址

[公開課] 物流系統優化與決策: 容量約束倉庫選址

[公開課] 物流系統優化與決策: 無容量約束p-median選址

[公開課] 物流系統優化與決策: 容量約束p-median選址

[公開課] 物流系統優化與決策: 多源Weber選址

[公開課] 物流系統優化與決策: p-hub選址


機器學習

機器學習: 鳶尾花數據集

機器學習: Scikit-learn Getting Started

機器學習: An introduction to machine learning with scikit-learn

機器學習: 手寫數字識別

機器學習: 人臉補全

Python普通最小二乘法

[公開課]機器學習(01-04): 四個例子

[公開課]機器學習(05-06): 分類結果的評價

[公開課]機器學習(07): 從Scikit-learn看機器學習

[公開課]機器學習(08): 機器學習概念解讀

[公開課]機器學習(09):統計學習及監督學習概論

[公開課]機器學習(10): 感知機

[公開課]機器學習(11):k近鄰法

[公開課]機器學習(12):樸素貝葉斯法

[公開課]機器學習(13):樸素貝葉斯法重述、第10-12講的Python算法

[公開課]機器學習(14):梯度下降法

[公開課]機器學習(15):拉格朗日對偶

[公開課]機器學習(16):決策樹

[公開課]機器學習(17): 邏輯斯特回歸

[公開課]機器學習(18): 最大熵模型

[公開課]機器學習(19): 線性可分支持向量機

[公開課]機器學習(20): 線性支持向量機

[公開課]機器學習(21): 非線性支持向量機

[公開課]機器學習(22): 支持向量機實驗

[公開課]機器學習(23): 提升方法Adaboost

[公開課]機器學習(24): 隱馬爾科夫模型

[公開課]機器學習(25): 聚類方法

[公開課]機器學習(26): 主成分分析

[公開課]機器學習(27): 神經網絡

[公開課]機器學習(28): 集成學習


機器學習28講視頻合集

[公開課]機器學習28講視頻合集01-10

[公開課]機器學習28講視頻合集11-20

[公開課]機器學習28講視頻合集21-28


ALNS自適應大規模鄰域搜索

ALNS自適應大規模鄰域搜索: 套裁問題

ALNS自適應大規模鄰域搜索: 旅行商問題


SCIP數學規劃

SCIP數學規劃求解器: PySCIPOpt

SCIP: 奇數還是偶數

SCIP: 邏輯約束

SCIP: 四個ATSP模型

SCIP: 1D裝箱問題的算法與模型

SCIP: 多商品經濟批量訂貨模型(MEOQ)線性化

SCIP: 選址問題(k-median)

SCIP: 容量約束下多分配選址問題

SCIP: 圖著色問題(限定色數)

SCIP: 批量(lot-sizing)優化問題與割平面

SCIP: 最大穩定集問題

SCIP: permutation flow shop

SCIP: 多商品經濟批量訂貨模型(MEOQ)線性化

SCIP: 資源約束調度問題RCSP

SCIP: 魯棒生產模型(SOCP)

SCIP 05: 整數規劃例子

SCIP: 圖著色的三個模型

SCIP: Weber問題的二階錐模型

SCIP: 設施選址問題的分解模型

SCIP: 數獨(sudoku)整數規劃模型

SCIP: 割平面求解TSP的算法


Python進化計算

Python進化計算Geatpy要點

單目標單連續變量函數二進位編碼進化算法

單目標多連續變量帶約束實數編碼進化算法

帶約束的單目標旅行商問題進化算法

句子匹配單目標進化算法

混合編碼單目標進化算法

離散變量雙目標進化算法

連續變量雙目標進化算法

多目標背包進化算法

混合編碼多目標背包進化算法



Python優化

Python無約束非線性優化

Python差分進化算法

Python線性規劃



Python 數學規劃

Python數學規劃案例:單分配多樞紐站選址

Python數學規劃案例:單源設施選址

Python數學規劃案例:路徑優化CVRP

Python數學規劃案例:一維裝箱

Python數學規劃案例四:資源約束的最短路徑

Python數學規劃案例三:最短路徑

Python數學規劃案例二

Python數學規劃之Cplex之旅

Python數學規劃案例一

Python數學規劃案例一模型

Python: 數學規劃


數學規划算法十二講

單純型算法第1-4講

單純型算法第1-4講視頻

單純型算法第5-8講

單純型算法第9-10講

單純型算法第11-12講


Python數據結構

Python數據結構

Python圖

Python二叉樹

Python排序

Python查找算法

Python遞歸

Python鍊表

Python棧

Python圖(csgraph)


Python數據

Python: 資料庫之SQLite

Python: Pandas

Python資料庫

Numpy快速入門

Pandas入門


Python Web

幾分鐘做個Web應用

Python信息系統實驗:倉庫管理


Python基礎

Python基礎:沒有更簡單

Python利器

Python快速入門

Python 入門


程序設計

如何學習程序設計


Python技術


複雜性



相關焦點

  • [公開課]《Python:從計算到算計》第04講: 科學計算(Scipy)
    提綱[公開課]《Python:從計算到算計》第01講:《程序設計》[公開課]《Python:從計算到算計》第02講:Python語言[公開課]《Python:從計算到算計》第03講: 矩陣(Numpy)主題優化問題、模型與算法旅行商問題(Traveling Salesman
  • 物有所值定量評價方法及流程分析
    物有所值為量化合作優勢提供了一種技術衡量手段,讓政府和社會資本互動結合的綜合優勢瞭然深刻;物有所值為各參與主體的行為路徑提供了一種可預測、可分析、可對比、可改進的分析框架,讓各方更好辨識PPP全生命周期各階段的發展環境,為制定最佳行動策略提供依據;物有所值為研究PPP模式下的交易成本提供了一種思考方式和約束模式,以先進的理念、科學的方法將傳統模式中隱藏的成本曝光於公眾,將契約精神與績效評價以更深邃的方式成為各方行動的指向標
  • 23 種定量研究方法,你會幾種?
    ∆研究方法的三個層次下面給出23種具體定量研究方法的名稱:01. 社會科學應用統計學原理02. 社會測量方法03. 實驗設計方法04. 抽樣調查方法05. 儘管這屬於一類方法,其中還有很多具體的研究方法,但目前還很少有學校把每一種具體方法設置為一門課。學習定性研究方法,通常不需要任何前修課,但最好能夠有過一些研究的經歷,並掌握一定的社會科學理論。對從來沒有學過定量分析方法特別是統計學方法的人來說,最好從統計學基礎課開始學。「社會科學應用統計學原理」被稱為應用統計學或定量研究方法的第一門課。
  • 運用好定性研究與定量研究相得益彰的方法
    威廉·配第、奧古斯特·孔德、埃米爾·迪爾凱姆等均在其著作中大量運用定量的方法分析經濟社會等現象,尤其是經濟學的後邊際革命爆發,越來越多的定量分析被應用到經濟理論研究中;薩繆爾森將數學分析方法引入經濟學,其影響延續至今。這些研究方法為後來社會科學的研究和學科建立,提供了許多有價值可借鑑的具體定量研究方法。
  • 定性定量分析,調查研究方法知多少
    封城的第52天,天氣回暖,樓下的聲音多了起來。今天分享一下調查研究要用到的方法。方法是為了達到某種目的(解決某個問題)而採取的測量手段,如購物網站、點評平臺用到的星級評定。以這麼一個問題為例,玩暴力遊戲會讓人變得暴力嗎?
  • 是什麼定量分析方法
    (-)三標準試法三標準試樣法是光譜定量分析最基本的方法,它準確度高,重現性好,適用於成品分析。它的缺點是,分析時間長,用感光板多,消耗標樣多,不適於快速分析。(二)控制試樣法該方法是在持久曲線法的基礎上(持久曲線法就是5個以上譜片的黑度差乘換算因素,求出平均值,再按三標準法繪製工作曲線,然後以這條曲線作為為固定曲線,求得分析試樣的未知含量量),以一個標樣來控制持久曲線的移動,並用該標樣來計算出分析試樣的含量。
  • Scipy使用簡介
    349.13579066361183 lowest_optimization_result: fun: 349.13579066361183 hess_inv: <3x3 LbfgsInvHessProduct with dtype=float64> jac: array([-2.27373675e-05, 6.53699317e-03, 2.16004992e-04
  • 謝宇:漫談定量與定性研究方法
    生:老師,我想問一下那個定量和定性這兩種方法您怎麼看。比如說現在社會學研究範圍之內分成兩派,一派就是在《社會學研究》這樣權威的雜誌上發表文章,基本上就是抽樣、問卷,然後統計研究,這樣子的思路,就是定量的分析。另外一個就是出專著,他們通過一本本書來說明自己偏向於根歷史學的結合,通過對文本的一種敘述哇,就是敘述性的一種,質的分析吧。
  • PVC材料及其製品的快速定性定量分析方法
    其方法是:將樣品直接熱裂解或刮下少量粉末用KBr壓片進行FTIR初步定性分析,再用DSC測其熔點或玻璃化轉變溫度證實定性分析結果,然後用TG定量分析。定性定量分析的結果基本上能滿足產品開發工作的需要。(HCl)氣體揮發出來,這給定量分析帶來了困難。
  • 【圖文專輯】第十二講:分光光度法基礎知識與應用
    一、分光光度法基本原理     在光譜分析中,依據物質對光的選擇性吸收而建立起來的分析方法稱為吸光光度法
  • 國科大MBA「定性與定量分析綜合集成」講座圓滿結束
    【MBA中國網訊】6月1日晚,中國科學院大學經濟與管理學院院長汪壽陽院士做客傑出科學家系列講座,為大家帶來了主題為「定性與定量分析綜合集成」的精彩演講。  講座伊始,汪院長用講故事般輕鬆有趣的語言,帶大家推開「定性與定量分析綜合集成」的神秘大門。這個讓我們耳目一新的概念,其實已有多年歷史。
  • 羽絨(毛)與聚酯纖維填充物的定量化學分析方法
    羽絨(毛)與聚酯纖維填充物的定量化學分析方法 2010-11-11 00:00:00 來源:全球紡織網     羽絨以其輕、柔、軟、暖等優點被廣泛應用
  • (初中、高中基礎)英語長難句精講04-2020福建省中考題
    分析下句式結構。Part of Chang'e 4's mission(使命)is to see,這裡是 n(名詞) is(are) to do sth的結構,經常表達的是將來的意思。類似的n(名詞)有goal目標,purpose目的,dream夢想,等。 例如,My dream is to be a doctor.
  • 晶型研究 | 晶型定量分析方法介紹
    藥物的晶型對製劑的穩定性、溶出度及生物利用度等有著重大的影響,是影響藥品質量的重要因素之一,僅定性分析原料藥或製劑中的晶型不可以滿足藥品的質量控制要求,為了測定原料藥或製劑中有效晶型的含量(特別是容易發生轉晶變化的晶型),從而更為精準的控制藥品的質量,對於晶型藥品質量控制應優先選擇定量分析方法。
  • Glyco-DIA:定量分析O-糖蛋白的新方法
    Glyco-DIA:定量分析O-糖蛋白的新方法 作者:小柯機器人 發布時間:2019/9/1 17:21:15 丹麥哥本哈根大學Sergey Y.
  • 核酸定量分析方法 - 專區 - 生物谷
    核酸定量分析方法 來源:來源網絡 2007-03-26 23:03 核酸定量分析 DNA 或 RNA(以260nm處的吸光值為基礎
  • 定性分析or定量分析的7種研究方法
    今天繼續教大家寫留學論文,選擇定性分析還是定量分析?1什麼是定性分析?分析方向:---定義---得出的數據方向---如何採集---是否具有目的性---研究類型---主客觀---數據類型2什麼是定量分析?
  • 大化所高通量多重蛋白質組定量分析方法研究獲進展
    近日,中科院大連化學物理研究所王方軍博士、鄒漢法研究員等人在高通量多重蛋白質組定量分析方法研究方面取得新進展,發展了一級質譜(MS1)譜圖中六種不同蛋白質樣品同時規模化定量分析的同位素標記方法,並將該方法應用於細胞蛋白質合成-降解周轉更新分析,分析通量是常規同位素標記方法的三倍,研究成果發表在自然出版社新創立的綜合性刊物《科學報告》(Scientific Reports
  • SPSSAU數據分析思維培養系列2:分析方法
    在完成數據準備和清理工作後,就要進入到正式分析階段,而選擇什麼樣的數據分析方法進行分析是關鍵。想要進行科學和系統化的數據分析,分析方法的思維是必備項。本文為SPSSAU數據分析思維培養的第2篇文章,將分別從數據類型談起,剖析數據應該如何分析,包括數據的基礎描述,數據質量的判斷。
  • 1.5w字,Scipy使用簡介,碼住!
    349.13579066361183 lowest_optimization_result: fun: 349.13579066361183 hess_inv: <3x3 LbfgsInvHessProduct with dtype=float64> jac: array([-2.27373675e-05, 6.53699317e-03, 2.16004992e-04