>>> save_model('heart_scale.model', m)
>>> m = load_model('heart_scale.model')
>>> p_label, p_acc, p_val = predict(y, x, m, '-b 1')
->>> ACC, MSE, SCC = evaluations(y, p_val)
+>>> ACC, MSE, SCC = evaluations(y, p_label)
# Getting online help
>>> help(train)
>>> prob = problem([1,-1], [{1:1, 3:1}, {1:-1,3:-1}])
>>> param = parameter('-c 4')
>>> m = liblinear.train(prob, param) # m is a ctype pointer to a model
-# Convet a Python-fromat instance to feature_nodearray, a ctypes structure
+# Convert a Python-format instance to feature_nodearray, a ctypes structure
>>> x0, max_idx = gen_feature_nodearray({1:1, 3:1})
>>> label = liblinear.predict(m, x0)
- class feature_node:
- Construct an feature_node.
+ Construct a feature_node.
>>> node = feature_node(idx, val)
- class problem:
- Construct an problem instance
+ Construct a problem instance
- >>> prob = problem(y, x, [bias=-1])
+ >>> prob = problem(y, x [,bias=-1])
y: a Python list/tuple of l labels (type must be int/double).
bias: if bias >= 0, instance x becomes [x; bias]; if < 0, no bias term
added (default -1)
- You can alos modify the bias value by
+ You can also modify the bias value by
>>> prob.set_bias(1)
- class parameter:
- Construct an parameter instance
+ Construct a parameter instance
>>> param = parameter('training_options')
>>> from liblinearutil import *
The above command loads
- train() : train an linear model
+ train() : train a linear model
predict() : predict testing data
svm_read_problem() : read the data from a LIBSVM-format file.
load_model() : load a LIBLINEAR model.
training_options: a string in the same form as that for LIBLINEAR command
mode.
- prob: an problem instance generated by calling
+ prob: a problem instance generated by calling
problem(y, x).
- param: an parameter instance generated by calling
+ param: a parameter instance generated by calling
parameter('training_options')
model: the returned model instance. See linear.h for details of this
predicting_options: a string of predicting options in the same format as
that of LIBLINEAR.
- model: an model instance.
+ model: a model instance.
p_labels: a list of predicted labels
p_vals: a list of decision values or probability estimates (if '-b 1'
is specified). If k is the number of classes, for decision values,
each element includes results of predicting k binary-class
- SVMs. if k = 2 and solver is not MCSVM_CS, only one decision value
+ SVMs. If k = 2 and solver is not MCSVM_CS, only one decision value
is returned. For probabilities, each element contains k values
indicating the probability that the testing instance is in each class.
Note that the order of classes here is the same as 'model.label'