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

Function svm_read_problem

pattern/vector/svm/liblinearutil.py:7–27  ·  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

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

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…