This function returns a pointer to the model read from the file,
or a null pointer if the model could not be loaded.
-- Function: void free_model_contents(struct model *model_ptr);
+- Function: void free_model_content(struct model *model_ptr);
This function frees the memory used by the entries in a model structure.
>>> p_label, p_acc, p_val = predict(y[200:], x[200:], m)
# Construct problem in python format
-# Dense data, the first element of the dense data must be 0
+# Dense data
>>> y, x = [1,-1], [[1,0,1], [-1,0,-1]]
# Sparse data
>>> y, x = [1,-1], [{1:1, 3:1}, {1:-1,3:-1}]
You can alos modify the bias value by
- >>> prob.setBias(1)
+ >>> prob.set_bias(1)
Note that if your x contains sparse data (i.e., dictionary), the internal
ctypes data format is still sparse.
The above command loads
train() : train an linear model
predict() : predict testing data
- svm_read_problem() : read the data from a LIBLINEAR-format file.
+ svm_read_problem() : read the data from a LIBSVM-format file.
load_model() : load a LIBLINEAR model.
save_model() : save model to a file.
evaluations() : evaluate prediction results.
self.x = (POINTER(feature_node) * l)()
for i, xi in enumerate(self.x_space): self.x[i] = xi
- self.setBias(bias)
+ self.set_bias(bias)
- def setBias(self, bias):
+ def set_bias(self, bias):
if self.bias == bias:
return
if bias >= 0 and self.bias < 0:
"""
save_model(model_file_name, model) -> None
- Save a LIBLINEAR model model to the file model_file_name.
+ Save a LIBLINEAR model to the file model_file_name.
"""
liblinear.save_model(model_file_name, model)
train(prob, [, 'options']) -> model | ACC
train(prob, param) -> model | ACC
- Train an SVM linear model from data (y, x) or a problem prob using
+ Train a model from data (y, x) or a problem prob using
'options' or a parameter param.
If '-v' is specified in 'options' (i.e., cross validation)
accuracy (ACC) is returned.
if prob == None or param == None :
raise TypeError("Wrong types for the arguments")
- prob.setBias(param.bias)
+ prob.set_bias(param.bias)
liblinear.set_print_string_function(param.print_func)
err_msg = liblinear.check_parameter(prob, param)
if err_msg :