如果表中已存在某个数字,则我想返回1,否则返回0.
我尝试了一些但它不起作用:
select
case when 100 in (select distinct id from test) then '1'
else '0'
from test
Run Code Online (Sandbox Code Playgroud)
我想要的东西,类似存在已经存在于PostgreSQL的功能,但不是true和false我想要1或0.
我正在尝试使用此处的代码:https://github.com/pystruct/pystruct/blob/master/examples/multi_label.py
我有X_train的形状(2591, 256)和y_train的形状(2591, 175).当我运行这个:
tree = chow_liu_tree(y_train)
tree_model = MultiLabelClf(edges=tree, inference_method="max-product")
tree_ssvm = OneSlackSSVM(tree_model, inference_cache=50, C=.1, tol=0.01)
print("fitting tree model...")
tree_ssvm.fit(X_train, y_train)
Run Code Online (Sandbox Code Playgroud)
我懂了:
Traceback (most recent call last):
File "classifiers.py", line 173, in <module>
tree_ssvm.fit(X_train, y_train)
File "/usr/local/lib/python2.7/dist-packages/pystruct/learners/one_slack_ssvm.py", line 448, in fit
X, Y, joint_feature_gt, constraints)
File "/usr/local/lib/python2.7/dist-packages/pystruct/learners/one_slack_ssvm.py", line 348, in _find_new_constraint
X, Y, self.w, relaxed=True)
File "/usr/local/lib/python2.7/dist-packages/pystruct/models/base.py", line 95, in batch_loss_augmented_inference
for x, y in zip(X, Y)]
File "/usr/local/lib/python2.7/dist-packages/pystruct/models/crf.py", line 106, in …Run Code Online (Sandbox Code Playgroud) 我在表格中有一些ID,但两者之间存在差距.我想选择这些差距.
例如,我表中的整数是:
1
2
5
9
15
Run Code Online (Sandbox Code Playgroud)
我想选择:
3
4
6
7
8
10
11
12
13
14
Run Code Online (Sandbox Code Playgroud)
我的PostgreSQL版本是9.1.1,所以我不能使用int4range.