【问题标题】:PyStruct - No matching signature findPyStruct - 找不到匹配的签名
【发布时间】:2015-11-24 18:11:26
【问题描述】:

我正在尝试使用此处的代码:https://github.com/pystruct/pystruct/blob/master/examples/multi_label.py

我有形状为(2591, 256) 的X_train 和形状为(2591, 175) 的y_train。当我运行这个时:

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)

我知道了:

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

当我直接从链接运行代码时,它可以工作(使用他们的数据集)。有人知道应该是什么问题吗?

【问题讨论】:

    标签: python python-2.7 multilabel-classification


    【解决方案1】:

    如果有人也遇到这个错误,y 必须是 int 类型 - 我得到了 float。

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

    【讨论】:

    • 还有,从0开始,以防其他人需要
    【解决方案2】:

    在使用 Catboost 时,我收到错误消息:“typeerror: no matching signature found” 正如上一篇文章正确提到的,这是由于 y 向量不是数字的。它是通过标记该向量来解决的。 在您的非数字 y 列上:

    from sklearn import preprocessing
    
    le = preprocessing.LabelEncoder()
    
    df['column_name']=le.fit_transform(df['column_name'])
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-09-04
      • 2020-10-08
      • 2014-02-09
      • 1970-01-01
      • 2014-09-01
      相关资源
      最近更新 更多