Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem running the example for testing LIBLINEAR with instance weight support #83

Closed
ksong4 opened this issue Aug 24, 2022 · 2 comments

Comments

@ksong4
Copy link

ksong4 commented Aug 24, 2022

I recently installed the LIBLINEAR and was testing the example scripts that were part of the README.weight

The following codes work until the problem() command

from liblinear.liblinearutil import *
import csv
y, x = svm_read_problem('./heart_scale', return_scipy=True)
W = [1] * len(y)
W[0] = 10
prob = problem(W, y, x) # Error occurs here 

The error code is shown here:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/ksong4/miniconda3/lib/python3.7/site-packages/liblinear/liblinear.py", line 194, in __init__
    tmp_xi, tmp_idx = gen_feature_nodearray(xi)
  File "/home/ksong4/miniconda3/lib/python3.7/site-packages/liblinear/liblinear.py", line 106, in gen_feature_nodearray
    raise TypeError('xi should be a dictionary, list, tuple, 1-d numpy array, or tuple of (index, data)')
TypeError: xi should be a dictionary, list, tuple, 1-d numpy array, or tuple of (index, data)

The imported x and y are both lists using the provided example heart_scale file.

@cjlin1
Copy link
Owner

cjlin1 commented Aug 24, 2022 via email

@ksong4
Copy link
Author

ksong4 commented Aug 24, 2022

Thank you so much for your prompt and helpful commands; I was indeed in the wrong directory when running the example.

@ksong4 ksong4 closed this as completed Aug 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants