本文整理汇总了Python中scipy.dot方法的典型用法代码示例。如果您正苦于以下问题:Python scipy.dot方法的具体用法?Python scipy.dot怎么用?Python scipy.dot使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类scipy
的用法示例。
在下文中一共展示了scipy.dot方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: b_orthonormalize
# 需要导入模块: import scipy [as 别名]
# 或者: from scipy import dot [as 别名]
def b_orthonormalize(B, blockVectorV,
blockVectorBV=None, retInvR=False):
"""Internal."""
import scipy.linalg as sla
if blockVectorBV is None:
if B is not None:
blockVectorBV = B(blockVectorV)
else:
blockVectorBV = blockVectorV # Shared data!!!
gramVBV = sp.dot(blockVectorV.T, blockVectorBV)
gramVBV = sla.cholesky(gramVBV)
gramVBV = sla.inv(gramVBV, overwrite_a=True)
# gramVBV is now R^{-1}.
blockVectorV = sp.dot(blockVectorV, gramVBV)
if B is not None:
blockVectorBV = sp.dot(blockVectorBV, gramVBV)
if retInvR:
return blockVectorV, blockVectorBV, gramVBV
else:
return blockVectorV, blockVectorBV
示例2: coupling_optim_garrick
# 需要导入模块: import scipy [as 别名]
# 或者: from scipy import dot [as 别名]
def coupling_optim_garrick(y,t):
creation=s.zeros(n_bin)
destruction=s.zeros(n_bin)
#now I try to rewrite this in a more optimized way
destruction = -s.dot(s.transpose(kernel),y)*y #much more concise way to express\
#the destruction of k-mers
for k in xrange(n_bin):
kyn = (kernel*f_garrick[:,:,k])*y[:,s.newaxis]*y[s.newaxis,:]
creation[k] = s.sum(kyn)
creation=0.5*creation
out=creation+destruction
return out
#Now I work with the function for espressing smoluchowski equation when a uniform grid is used
示例3: coupling_optim
# 需要导入模块: import scipy [as 别名]
# 或者: from scipy import dot [as 别名]
def coupling_optim(y,t):
creation=s.zeros(n_bin)
destruction=s.zeros(n_bin)
#now I try to rewrite this in a more optimized way
destruction = -s.dot(s.transpose(kernel),y)*y #much more concise way to express\
#the destruction of k-mers
kyn = kernel*y[:,s.newaxis]*y[s.newaxis,:]
for k in xrange(n_bin):
creation[k] = s.sum(kyn[s.arange(k),k-s.arange(k)-1])
creation=0.5*creation
out=creation+destruction
return out
#Now I go for the optimal optimization of the chi_{i,j,k} coefficients used by Garrick for
# dealing with a non-uniform grid.
示例4: generate_data
# 需要导入模块: import scipy [as 别名]
# 或者: from scipy import dot [as 别名]
def generate_data(N, S, L):
# generate genetics
G = 1.0 * (sp.rand(N, S) < 0.2)
G -= G.mean(0)
G /= G.std(0) * sp.sqrt(G.shape[1])
# generate latent phenotypes
Zg = sp.dot(G, sp.randn(G.shape[1], L))
Zn = sp.randn(N, L)
# generate variance exapleind
vg = sp.linspace(0.8, 0, L)
# rescale and sum
Zg *= sp.sqrt(vg / Zg.var(0))
Zn *= sp.sqrt((1 - vg) / Zn.var(0))
Z = Zg + Zn
return Z, G
示例5: CalculateSchiultz
# 需要导入模块: import scipy [as 别名]
# 或者: from scipy import dot [as 别名]
def CalculateSchiultz(mol):
"""
#################################################################
Calculation of Schiultz number
---->Tsch(log value)
Usage:
result=CalculateSchiultz(mol)
Input: mol is a molecule object
Output: result is a numeric value
#################################################################
"""
Distance = numpy.array(Chem.GetDistanceMatrix(mol), "d")
Adjacent = numpy.array(Chem.GetAdjacencyMatrix(mol), "d")
VertexDegree = sum(Adjacent)
return sum(scipy.dot((Distance + Adjacent), VertexDegree))
示例6: _quartimax_obj
# 需要导入模块: import scipy [as 别名]
# 或者: from scipy import dot [as 别名]
def _quartimax_obj(self, loadings):
"""
Quartimax function objective.
Parameters
----------
loadings : array-like
The loading matrix
Returns
-------
gradient_dict : dict
A dictionary with
- grad : np.array
The gradient.
- criterion : float
The value of the criterion for the objective.
"""
gradient = -loadings**3
criterion = -np.sum(np.diag(np.dot((loadings**2).T, loadings**2))) / 4
return {'grad': gradient, 'criterion': criterion}
示例7: _oblimin_obj
# 需要导入模块: import scipy [as 别名]
# 或者: from scipy import dot [as 别名]
def _oblimin_obj(self, loadings):
"""
The Oblimin function objective.
Parameters
----------
loadings : array-like
The loading matrix
Returns
-------
gradient_dict : dict
A dictionary with
- grad : np.array
The gradient.
- criterion : float
The value of the criterion for the objective.
"""
X = np.dot(loadings**2, np.eye(loadings.shape[1]) != 1)
if (self.gamma != 0):
p = loadings.shape[0]
X = np.diag(np.full(1, p)) - np.dot(np.zeros((p, p)), X)
gradient = loadings * X
criterion = np.sum(loadings**2 * X) / 4
return {'grad': gradient, 'criterion': criterion}
示例8: _quartimin_obj
# 需要导入模块: import scipy [as 别名]
# 或者: from scipy import dot [as 别名]
def _quartimin_obj(self, loadings):
"""
Quartimin function objective.
Parameters
----------
loadings : array-like
The loading matrix
Returns
-------
gradient_dict : dict
A dictionary with
- grad : np.array
The gradient.
- criterion : float
The value of the criterion for the objective.
"""
X = np.dot(loadings**2, np.eye(loadings.shape[1]) != 1)
gradient = loadings * X
criterion = np.sum(loadings**2 * X) / 4
return {'grad': gradient, 'criterion': criterion}
示例9: apply_givens
# 需要导入模块: import scipy [as 别名]
# 或者: from scipy import dot [as 别名]
def apply_givens(Q, v, k):
"""
Apply the first k Givens rotations in Q to the vector v.
Arguments
---------
Q: list, list of consecutive 2x2 Givens rotations
v: array, vector to apply the rotations to
k: int, number of rotations to apply
Returns
-------
v: array, that is changed in place.
"""
for j in range(k):
Qloc = Q[j]
v[j:j+2] = scipy.dot(Qloc, v[j:j+2])
示例10: applyConstraints
# 需要导入模块: import scipy [as 别名]
# 或者: from scipy import dot [as 别名]
def applyConstraints(blockVectorV, factYBY, blockVectorBY, blockVectorY):
"""Internal. Changes blockVectorV in place."""
gramYBV = sp.dot(blockVectorBY.T, blockVectorV)
import scipy.linalg as sla
tmp = sla.cho_solve(factYBY, gramYBV)
blockVectorV -= sp.dot(blockVectorY, tmp)
示例11: dir_cosines
# 需要导入模块: import scipy [as 别名]
# 或者: from scipy import dot [as 别名]
def dir_cosines(dir,coords=sp.identity(3)):
"""Returns a vector containing the direction cosines between vector dir, and
the coordinate system coords. Default coordinate system is an orthonormal
cartesian coordinate system."""
cosines = sp.dot(coords,dir)/linalg.norm(dir)
return cosines
示例12: _auc_loss
# 需要导入模块: import scipy [as 别名]
# 或者: from scipy import dot [as 别名]
def _auc_loss(self, coef, X, y):
fpr, tpr, _ = metrics.roc_curve(y, sp.dot(X, coef))
return -metrics.auc(fpr, tpr)
示例13: predict
# 需要导入模块: import scipy [as 别名]
# 或者: from scipy import dot [as 别名]
def predict(self, X):
return sp.dot(X, self.coef_)
示例14: score
# 需要导入模块: import scipy [as 别名]
# 或者: from scipy import dot [as 别名]
def score(self, X, y):
fpr, tpr, _ = metrics.roc_curve(y, sp.dot(X, self.coef_))
return metrics.auc(fpr, tpr)
示例15: cosine_similarity
# 需要导入模块: import scipy [as 别名]
# 或者: from scipy import dot [as 别名]
def cosine_similarity(a,b):
a = mat(a)
b = mat(b)
c = dot(a,b.T)/linalg.norm(a)/linalg.norm(b)
return c[0,0]