I'm trying to use code from here: 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)
. 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.
Link to solution: 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. It was solved by labelencoding that vector. On your non-numeric y column:
from sklearn import preprocessing
le = preprocessing.LabelEncoder()
df['column_name']=le.fit_transform(df['column_name'])
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.