我怎样才能qstat
给我完整的工作名称?
我知道qstat -r
提供有关任务的详细信息,但它太多了,并且包含了资源要求.
该qstat -r
输出是这样的:
131806 0.25001 tumor_foca ajalali qw 09/29/2014 15:49:41 1 2-100:1
Full jobname: tumor_focality-TCGA-THCA-ratboost_linear_svc
Hard Resources: distribution=wheezy (0.000000)
h_rt=72000 (0.000000)
mem_free=15G (0.000000)
h_vmem=15G (0.000000)
h_stack=256M (0.000000)
Soft Resources:
131807 0.25001 vital_stat ajalali qw 09/29/2014 15:49:41 1 2-100:1
Full jobname: vital_status-TCGA-LGG-ratboost_linear_svc
Hard Resources: distribution=wheezy (0.000000)
h_rt=72000 (0.000000)
mem_free=15G (0.000000)
h_vmem=15G (0.000000)
h_stack=256M (0.000000)
Soft Resources:
Run Code Online (Sandbox Code Playgroud)
现在我唯一的选择就是根据grep
需要输出:
$ qstat -r | grep "Full jobname" -B1
--
131806 0.25001 tumor_foca ajalali qw …
Run Code Online (Sandbox Code Playgroud) 有没有办法在使用ipython时通过命令行将参数传递给我的python脚本?理想情况下,我想将我的脚本称为:
ipython -i script.py --argument blah
Run Code Online (Sandbox Code Playgroud)
我希望能够拥有--argument
并blah
列入我的sys.argv
.
假设我们有一个numpy.ndarray数据,比如说有形状(100,200),你还有一个要从数据中排除的索引列表.你会怎么做?像这样的东西:
a = numpy.random.rand(100,200)
indices = numpy.random.randint(100,size=20)
b = a[-indices,:] # imaginary code, what to replace here?
Run Code Online (Sandbox Code Playgroud)
谢谢.
我应该如何使用python中的图形工具从邻接矩阵中创建图形?假设我们有adj
矩阵作为邻接矩阵.
我现在做的是这样的:
g = graph_tool.Graph(directed = False)
g.add_vertex(len(adj))
edge_weights = g.new_edge_property('double')
for i in range(adj.shape[0]):
for j in range(adj.shape[1]):
if i > j and adj[i,j] != 0:
e = g.add_edge(i, j)
edge_weights[e] = adj[i,j]
Run Code Online (Sandbox Code Playgroud)
但它感觉不对,我们有更好的解决方案吗?
(我想这是一个合适的标签graph-tool
,但是我无法添加它,某些具有足够权限的人可以制作标签?)
假设以下代码具有xarray.DataArray
二维和坐标:
import numpy as np
from xarray import DataArray
data = np.random.rand(10, 4)
f_names = ['a', 'b', 'c', 'd']
sample_weights = np.random.rand(10)
rows = list(range(len(data)))
coords={'samples': rows,
'features': f_names,
'sample_weights': ('samples', sample_weights)}
xdata = DataArray(data, coords=coords,
dims=['samples', 'features'])
subset = xdata[::2]
Run Code Online (Sandbox Code Playgroud)
现在我想添加另一个坐标,alternate_sample_weights
例如subset
. 我尝试:
subset.assign_coords(alternate_sample_weights=np.zeros(5)
Run Code Online (Sandbox Code Playgroud)
这会导致以下错误:
ValueError: cannot add coordinates with new dimensions to a DataArray
Run Code Online (Sandbox Code Playgroud)
API 文档非常稀疏,不知道我做错了什么。
如何在scikit-learn中生成交叉验证的随机折叠?
想象一下,我们有一个类的20个样本,另外80个样本,我们需要生成N个训练集和测试集,每个训练集大小为30,在每个训练集的约束条件下,我们有50%的类2级中的1%和50%.
我发现了这个讨论(https://github.com/scikit-learn/scikit-learn/issues/1362),但我不明白如何获得折叠.理想情况下,我认为我需要这样一个功能:
cfolds = np.cross_validation.imaginaryfunction(
[list(itertools.repeat(1,20)), list(itertools.repeat(2,80))],
n_iter=100, test_size=0.70)
Run Code Online (Sandbox Code Playgroud)
我错过了什么?
嗨,我正在尝试从ndarray派生一个类.我坚持在docs中找到的配方,但当我遇到一个getiem()函数时,我得到一个我不明白的错误.我确定这是应该如何工作但我不明白如何正确地做到这一点.基本上添加"dshape"属性的我的类看起来像:
class Darray(np.ndarray):
def __new__(cls, input_array, dshape, *args, **kwargs):
obj = np.asarray(input_array).view(cls)
obj.SelObj = SelObj
obj.dshape = dshape
return obj
def __array_finalize__(self, obj):
if obj is None: return
self.info = getattr(obj, 'dshape', 'N')
def __getitem__(self, index):
return self[index]
Run Code Online (Sandbox Code Playgroud)
当我现在尝试做的时候:
D = Darray( ones((10,10)), ("T","N"))
Run Code Online (Sandbox Code Playgroud)
解释器将以最大深度递归失败,因为他一遍又一遍地调用getitem.
有人可以向我解释为什么以及如何实现getitem功能?
欢呼,大卫
参考Sorting的文档,地理距离排序一节,问题如下:
给出的例子如下:
GET /_search
{
"sort" : [
{
"_geo_distance" : {
"pin.location" : [-70, 40],
"order" : "asc",
"unit" : "km",
"mode" : "min",
"distance_type" : "sloppy_arc"
}
}
],
"query" : {
"term" : { "user" : "kimchy" }
}
}
Run Code Online (Sandbox Code Playgroud)
映射中的字段是否pin.location
包含地理位置?或者它是搜索 API 理解为包含基本位置的关键字吗?如果它是一个应该包含位置的字段,那么排序项不应该包含设置nested_path
为吗pin
?如果它是一个参数,那么elasticsearch从哪里获取项目的位置?
另外,文档提到sort_mode
作为参数,但代码使用mode
,我想这是一个拼写错误?
假设您有一个 pandas 数据框输入和一个列名称列表。获取这些名称表示的列的索引(列号)列表的好方法是什么?
我认为它会是这样的:
def get_col_indices(df, names):
return [df.columns.index(name) for name in names]
Run Code Online (Sandbox Code Playgroud) 使用 python 和 scikit-learn,我想进行网格搜索。但我的一些模型最终是空的。如何使网格搜索功能忽略这些模型?
我想我可以有一个评分函数,如果模型为空,它会返回 0,但我不确定如何实现。
predictor = sklearn.svm.LinearSVC(penalty='l1', dual=False, class_weight='auto')
param_dist = {'C': pow(2.0, np.arange(-10, 11))}
learner = sklearn.grid_search.GridSearchCV(estimator=predictor,
param_grid=param_dist,
n_jobs=self.n_jobs, cv=5,
verbose=0)
learner.fit(X, y)
Run Code Online (Sandbox Code Playgroud)
我的数据的方式是该learner
对象将选择C
与空模型相对应的数据。知道如何确保模型不为空吗?
编辑:“空模型”是指选择了 0 个要使用的特征的模型。特别是对于l1
正则化模型,这种情况很容易发生。所以在这种情况下,如果C
SVM中的 足够小,优化问题就会找到0向量作为系数的最优解。因此predictor.coef_
将是 s 的向量0
。
python ×8
numpy ×2
scikit-learn ×2
bash4 ×1
graph ×1
graph-tool ×1
grid-search ×1
ipython ×1
linux ×1
pandas ×1
python-3.x ×1