svm_read_problem(data_file_name) -> [y, x] Read LIBSVM-format data from data_file_name and return labels y and data instances x.
(data_file_name)
| 59 | thundersvm.thundersvm_predict(len(param_list), param_array) |
| 60 | ''' |
| 61 | def svm_read_problem(data_file_name): |
| 62 | """ |
| 63 | svm_read_problem(data_file_name) -> [y, x] |
| 64 | |
| 65 | Read LIBSVM-format data from data_file_name and return labels y |
| 66 | and data instances x. |
| 67 | """ |
| 68 | prob_y = [] |
| 69 | prob_x = [] |
| 70 | file_path = data_file_name |
| 71 | for line in open(file_path): |
| 72 | line = line.split(None, 1) |
| 73 | # In case an instance with all zero features |
| 74 | if len(line) == 1: line += [''] |
| 75 | label, features = line |
| 76 | xi = features.encode('utf-8')[:-1] |
| 77 | #for e in features.split(): |
| 78 | # ind, val = e.split(":") |
| 79 | # xi[int(ind)] = float(val) |
| 80 | prob_y += [float(label)] |
| 81 | prob_x += [xi] |
| 82 | return (prob_y, prob_x) |
| 83 | |
| 84 | def svm_train(arg1, arg2 = None, arg3 = None, arg4 = None): |
| 85 | if arg2: |
nothing calls this directly
no outgoing calls
no test coverage detected