简体   繁体   English

PyStruct - 找不到匹配的签名

[英]PyStruct - No matching signature find

I'm trying to use code from here: https://github.com/pystruct/pystruct/blob/master/examples/multi_label.py我正在尝试使用这里的代码: https : //github.com/pystruct/pystruct/blob/master/examples/multi_label.py

I have X_train with shape (2591, 256) and y_train with shape (2591, 175) .我有形状为(2591, 256) X_train 和形状为(2591, 175) y_train 。 When I run this:当我运行这个:

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)

I got this:我懂了:

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 loss_augmented_inference
    loss_augment_unaries(unary_potentials, np.asarray(y), self.class_weight)
  File "utils.pyx", line 21, in utils.__pyx_fused_cpdef (src/utils.c:4341)
TypeError: No matching signature found

When I run code directly from the link, it works (with their dataset).当我直接从链接运行代码时,它可以工作(使用他们的数据集)。 Does anybody know what should be the problem?有谁知道应该是什么问题?

In case somebody will get that error too, y must be of type int - I got float.万一有人也会得到那个错误, y必须是 int 类型 - 我得到了浮点数。

Link to solution: https://groups.google.com/forum/#!searchin/pystruct/matching/pystruct/T6UKEgZLmxY/297oLYQL8U8J解决方案链接: https : //groups.google.com/forum/#!searchin/pystruct/matching/pystruct/T6UKEgZLmxY/297oLYQL8U8J

While using Catboost, I got the error:"typeerror: no matching signature found" As the previous post correctly mentions, it is due to ay vector that is not numeric.使用 Catboost 时,出现错误:“typeerror: no matching signature found” 正如上一篇文章正确提到的,这是由于 ay 向量不是数字。 It was solved by labelencoding that vector.它是通过对该向量进行标签编码来解决的。 On your non-numeric y column:在您的非数字 y 列上:

from sklearn import preprocessing

le = preprocessing.LabelEncoder()

df['column_name']=le.fit_transform(df['column_name'])

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM