MCPcopy Index your code
hub / github.com/clips/pattern / svm_read_problem

Function svm_read_problem

pattern/vector/svm/libsvmutil.py:8–28  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

6sys.path = [os.path.dirname(os.path.abspath(__file__))] + sys.path
7
8def svm_read_problem(data_file_name):
9 """
10 svm_read_problem(data_file_name) -> [y, x]
11
12 Read LIBSVM-format data from data_file_name and return labels y
13 and data instances x.
14 """
15 prob_y = []
16 prob_x = []
17 for line in open(data_file_name):
18 line = line.split(None, 1)
19 # In case an instance with all zero features
20 if len(line) == 1: line += ['']
21 label, features = line
22 xi = {}
23 for e in features.split():
24 ind, val = e.split(":")
25 xi[int(ind)] = float(val)
26 prob_y += [float(label)]
27 prob_x += [xi]
28 return (prob_y, prob_x)
29
30def svm_load_model(model_file_name):
31 """

Callers

nothing calls this directly

Calls 2

lenFunction · 0.85
splitMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…