• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python sg.sg函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中sg.sg函数的典型用法代码示例。如果您正苦于以下问题:Python sg函数的具体用法?Python sg怎么用?Python sg使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了sg函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: multiplicity

def multiplicity(hkls, sgname=None, sgno=None, cell_choice="standard"):
    """
    Calculate the powder diffraction multiplicity of a set of reflections
	

    INPUT:  hkls          : HKLs for the reflections
            sgno/sgname   : provide either the space group number or its name 
                            e.g. sgno=225 or equivalently
                                 sgname='Fm-3m'

    OUTPUT: array of multiplicities

    """

    if sgname != None:
        spg = sg.sg(sgname=sgname, cell_choice=cell_choice)
    elif sgno != None:
        spg = sg.sg(sgno=sgno, cell_choice=cell_choice)
    else:
        raise ValueError, "No space group information given"

    # Making sure that the inversion element also for non-centrosymmetric space groups
    Rots = np.concatenate((spg.rot[: spg.nuniq], -spg.rot[: spg.nuniq]))
    (dummy, rows) = np.unique((Rots * np.random.rand(3, 3)).sum(axis=2).sum(axis=1), return_index=True)
    Rots = Rots[np.sort(rows)]

    M = []
    for refl in hkls:
        a = np.array([np.dot(refl[:3], R) for R in Rots])

        (dummy, rows) = np.unique((a * np.random.rand(3)).sum(axis=1), return_index=True)

        M.append(a[rows].shape[0])
    return np.array(M)
开发者ID:matthewjpeel,项目名称:edxrd,代码行数:34,代码来源:unitcell.py


示例2: _get_alpha_and_sv

def _get_alpha_and_sv(indata, prefix):
	if not indata.has_key(prefix+'alpha_sum') and \
		not indata.has_key(prefix+'sv_sum'):
		return None, None

	a=0
	sv=0
	if indata.has_key(prefix+'label_type') and \
		indata[prefix+'label_type']=='series':
		for i in xrange(sg('get_num_svms')):
			[dump, weights]=sg('get_svm', i)
			weights=weights.T
			for item in weights[0].tolist():
				a+=item
			for item in weights[1].tolist():
				sv+=item
		a=abs(a-indata[prefix+'alpha_sum'])
		sv=abs(sv-indata[prefix+'sv_sum'])
	else:
		[dump, weights]=sg('get_svm')
		weights=weights.T
		for item in weights[0].tolist():
			a+=item
		a=abs(a-indata[prefix+'alpha_sum'])
		for item in weights[1].tolist():
			sv+=item
		sv=abs(sv-indata[prefix+'sv_sum'])

	return a, sv
开发者ID:42MachineLearning,项目名称:shogun,代码行数:29,代码来源:classifier.py


示例3: multiplicity

def multiplicity(position, sgname=None, sgno=None, cell_choice='standard'):
    """
    Calculates the multiplicity of a fractional position in the unit cell.
    If called by sgno, cell_choice is necessary for eg rhombohedral space groups.

    """

    if sgname != None:
        mysg = sg.sg(sgname=sgname, cell_choice=cell_choice)
    elif sgno !=None:
        mysg = sg.sg(sgno=sgno, cell_choice=cell_choice)
    else:
        raise ValueError, 'No space group information provided'

    lp = n.zeros((mysg.nsymop, 3))

    for i in range(mysg.nsymop):
        lp[i, :] = n.dot(position, mysg.rot[i]) + mysg.trans[i]

    lpu = n.array([lp[0, :]])
    multi = 1

    for i in range(1, mysg.nsymop):
        for j in range(multi):
            t = lp[i]-lpu[j]
            if n.sum(n.mod(t, 1)) < 0.00001:
                break
            else:
                if j == multi-1:
                    lpu = n.concatenate((lpu, [lp[i, :]]))
                    multi += 1
    return multi
开发者ID:matthewjpeel,项目名称:edxrd,代码行数:32,代码来源:structure.py


示例4: _set_distribution

def _set_distribution (indata):
	prefix='distribution_'
	if indata[prefix+'name']=='HMM':
		sg('new_hmm', indata[prefix+'N'], indata[prefix+'M'])
		sg('bw')
	else:
		raise NotImplementedError, 'Can\'t yet train other distributions than HMM in static interface.'
开发者ID:42MachineLearning,项目名称:shogun,代码行数:7,代码来源:distribution.py


示例5: _evaluate

def _evaluate (indata, prefix):
	dmatrix=sg('get_distance_matrix', 'TRAIN')
	dm_train=max(abs(indata['distance_matrix_train']-dmatrix).flat)

	dmatrix=sg('get_distance_matrix', 'TEST')
	dm_test=max(abs(indata['distance_matrix_test']-dmatrix).flat)

	return util.check_accuracy(
		indata[prefix+'accuracy'], dm_train=dm_train, dm_test=dm_test)
开发者ID:42MachineLearning,项目名称:shogun,代码行数:9,代码来源:distance.py


示例6: _train

def _train (indata):
	if indata['regression_type']=='svm':
		sg('c', double(indata['regression_C']))
		sg('svm_epsilon', indata['regression_epsilon'])
		sg('svr_tube_epsilon', indata['regression_tube_epsilon'])
	elif indata['regression_type']=='kernelmachine':
		sg('krr_tau', indata['regression_tau'])
	else:
		raise StandardError, 'Incomplete regression data.'

	sg('train_regression')
开发者ID:42MachineLearning,项目名称:shogun,代码行数:11,代码来源:regression.py


示例7: predict

    def predict(self, testPoints):
        """Predicts performance using previously learned model.
        self.train() must be called before this!"""

        if len(testPoints.shape) < 2:
            testPoints = array([testPoints])

        sg("set_features", "TEST", phys2unif(testPoints, self.ranges).T)
        predictions = sg("classify")

        return predictions
开发者ID:yosinski,项目名称:QuadraTot,代码行数:11,代码来源:SVMStrategy.py


示例8: predict

    def predict(self, testPoints):
        '''Predicts performance using previously learned model.
        self.train() must be called before this!'''

        if len(testPoints.shape) < 2:
            testPoints = array([testPoints])

        sg('set_features', 'TEST', phys2unif(testPoints,self.ranges).T)
        predictions = sg('classify')

        return predictions
开发者ID:elgold92,项目名称:QuadraTot,代码行数:11,代码来源:SVMStrategy.py


示例9: _evaluate

def _evaluate (indata, prefix):
	util.set_and_train_kernel(indata)

	kmatrix=sg('get_kernel_matrix', 'TRAIN')
	km_train=max(abs(indata['kernel_matrix_train']-kmatrix).flat)

	kmatrix=sg('get_kernel_matrix', 'TEST')
	km_test=max(abs(indata['kernel_matrix_test']-kmatrix).flat)

	return util.check_accuracy(
		indata[prefix+'accuracy'], km_train=km_train, km_test=km_test)
开发者ID:AsherBond,项目名称:shogun,代码行数:11,代码来源:preproc.py


示例10: clustering_kmeans

def clustering_kmeans (fm_train=traindat, size_cache=10,k=3,iter=1000):
	sg('set_features', 'TRAIN', fm_train)
	sg('set_distance', 'EUCLIDIAN', 'REAL')
	sg('new_clustering', 'KMEANS')
	sg('train_clustering', k, iter)

	[radi, centers]=sg('get_clustering')
	return [radi, centers]
开发者ID:behollis,项目名称:muViewBranch,代码行数:8,代码来源:clustering_kmeans.py


示例11: clustering_hierarchical

def clustering_hierarchical (fm_train=traindat, size_cache=10,merges=3):

	sg('set_features', 'TRAIN', fm_train)
	sg('set_distance', 'EUCLIDIAN', 'REAL')
	sg('new_clustering', 'HIERARCHICAL')
	sg('train_clustering', merges)

	[merge_distance, pairs]=sg('get_clustering')
	return [merge_distance, pairs]
开发者ID:behollis,项目名称:muViewBranch,代码行数:9,代码来源:clustering_hierarchical.py


示例12: kernel_const

def kernel_const(fm_train_real=traindat, fm_test_real=testdat, c=23.0, size_cache=10):
    sg("set_features", "TRAIN", fm_train_real)
    sg("set_features", "TEST", fm_test_real)
    sg("set_kernel", "CONST", "REAL", size_cache, c)
    km = sg("get_kernel_matrix", "TRAIN")
    km = sg("get_kernel_matrix", "TEST")
    return km
开发者ID:JackieXie168,项目名称:shogun,代码行数:7,代码来源:kernel_const.py


示例13: distance_chisquare

def distance_chisquare (fm_train_real=traindat,fm_test_real=testdat):
	sg('set_distance', 'CHISQUARE', 'REAL')
	sg('set_features', 'TRAIN', fm_train_real)
	dm=sg('get_distance_matrix', 'TRAIN')
	sg('set_features', 'TEST', fm_test_real)
	dm=sg('get_distance_matrix', 'TEST')
	return dm
开发者ID:behollis,项目名称:muViewBranch,代码行数:7,代码来源:distance_chisquare.py


示例14: distance_braycurtis

def distance_braycurtis (fm_train_real=traindat,fm_test_real=testdat):
	sg('set_distance', 'BRAYCURTIS', 'REAL')
	sg('set_features', 'TRAIN', fm_train_real)
	dm=sg('get_distance_matrix', 'TRAIN')
	sg('set_features', 'TEST', fm_test_real)
	dm=sg('get_distance_matrix', 'TEST')
	return dm
开发者ID:42MachineLearning,项目名称:shogun,代码行数:7,代码来源:distance_braycurtis.py


示例15: distance_cosine

def distance_cosine (fm_train_real=traindat,fm_test_real=testdat):
	sg('set_distance', 'COSINE', 'REAL')
	sg('set_features', 'TRAIN', fm_train_real)
	dm=sg('get_distance_matrix', 'TRAIN')
	sg('set_features', 'TEST', fm_test_real)
	dm=sg('get_distance_matrix', 'TEST')
	return dm
开发者ID:harshitsyal,项目名称:gsoc,代码行数:7,代码来源:distance_cosine.py


示例16: distance_chebyshew

def distance_chebyshew (fm_train_real=traindat,fm_test_real=testdat):
	sg('set_distance', 'CHEBYSHEW', 'REAL')
	sg('set_features', 'TRAIN', fm_train_real)
	dm=sg('get_distance_matrix', 'TRAIN')
	sg('set_features', 'TEST', fm_test_real)
	dm=sg('get_distance_matrix', 'TEST')
	return dm
开发者ID:behollis,项目名称:muViewBranch,代码行数:7,代码来源:distance_chebyshew.py


示例17: distance_jensen

def distance_jensen (fm_train_real=traindat,fm_test_real=testdat):
	sg('set_distance', 'JENSEN', 'REAL')
	sg('set_features', 'TRAIN', fm_train_real)
	dm=sg('get_distance_matrix', 'TRAIN')
	sg('set_features', 'TEST', fm_test_real)
	dm=sg('get_distance_matrix', 'TEST')
	return dm
开发者ID:42MachineLearning,项目名称:shogun,代码行数:7,代码来源:distance_jensen.py


示例18: kernel_const

def kernel_const (fm_train_real=traindat,fm_test_real=testdat,c=23.,size_cache=10):
	sg('set_features', 'TRAIN', fm_train_real)
	sg('set_features', 'TEST', fm_test_real)
	sg('set_kernel', 'CONST', 'REAL', size_cache, c)
	km=sg('get_kernel_matrix', 'TRAIN')
	km=sg('get_kernel_matrix', 'TEST')
	return km
开发者ID:Anshul-Bansal,项目名称:gsoc,代码行数:7,代码来源:kernel_const.py


示例19: distance_euclidean

def distance_euclidean (fm_train_real=traindat,fm_test_real=testdat):
	sg('set_distance', 'EUCLIDEAN', 'REAL')
	sg('set_features', 'TRAIN', fm_train_real)
	dm=sg('get_distance_matrix', 'TRAIN')
	sg('set_features', 'TEST', fm_test_real)
	dm=sg('get_distance_matrix', 'TEST')
	return dm
开发者ID:42MachineLearning,项目名称:shogun,代码行数:7,代码来源:distance_euclidian.py


示例20: _train

def _train (indata, prefix):
	if indata.has_key(prefix+'max_iter'):
		max_iter=indata[prefix+'max_iter']
	else:
		max_iter=1000

	if indata.has_key(prefix+'k'):
		first_arg=indata[prefix+'k']
	elif indata.has_key(prefix+'merges'):
		first_arg=indata[prefix+'merges']
	else:
		raise StandardError, 'Incomplete clustering data.'

	sg('train_clustering', first_arg, max_iter)
开发者ID:42MachineLearning,项目名称:shogun,代码行数:14,代码来源:clustering.py



注:本文中的sg.sg函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python core.Gcore类代码示例发布时间:2022-05-27
下一篇:
Python sflib.SpiderFoot类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap