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

Function train

pattern/vector/svm/liblinearutil.py:79–163  ·  view source on GitHub ↗

train(y, x [, options]) -> model | ACC train(prob [, options]) -> model | ACC train(prob, param) -> model | ACC 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) either accuracy (ACC) or mean-squ

(arg1, arg2=None, arg3=None)

Source from the content-addressed store, hash-verified

77 return (ACC, MSE, SCC)
78
79def train(arg1, arg2=None, arg3=None):
80 """
81 train(y, x [, options]) -> model | ACC
82 train(prob [, options]) -> model | ACC
83 train(prob, param) -> model | ACC
84
85 Train a model from data (y, x) or a problem prob using
86 'options' or a parameter param.
87 If '-v' is specified in 'options' (i.e., cross validation)
88 either accuracy (ACC) or mean-squared error (MSE) is returned.
89
90 options:
91 -s type : set type of solver (default 1)
92 for multi-class classification
93 0 -- L2-regularized logistic regression (primal)
94 1 -- L2-regularized L2-loss support vector classification (dual)
95 2 -- L2-regularized L2-loss support vector classification (primal)
96 3 -- L2-regularized L1-loss support vector classification (dual)
97 4 -- support vector classification by Crammer and Singer
98 5 -- L1-regularized L2-loss support vector classification
99 6 -- L1-regularized logistic regression
100 7 -- L2-regularized logistic regression (dual)
101 for regression
102 11 -- L2-regularized L2-loss support vector regression (primal)
103 12 -- L2-regularized L2-loss support vector regression (dual)
104 13 -- L2-regularized L1-loss support vector regression (dual)
105 -c cost : set the parameter C (default 1)
106 -p epsilon : set the epsilon in loss function of SVR (default 0.1)
107 -e epsilon : set tolerance of termination criterion
108 -s 0 and 2
109 |f'(w)|_2 <= eps*min(pos,neg)/l*|f'(w0)|_2,
110 where f is the primal function, (default 0.01)
111 -s 11
112 |f'(w)|_2 <= eps*|f'(w0)|_2 (default 0.001)
113 -s 1, 3, 4, and 7
114 Dual maximal violation <= eps; similar to liblinear (default 0.)
115 -s 5 and 6
116 |f'(w)|_inf <= eps*min(pos,neg)/l*|f'(w0)|_inf,
117 where f is the primal function (default 0.01)
118 -s 12 and 13
119 |f'(alpha)|_1 <= eps |f'(alpha0)|,
120 where f is the dual function (default 0.1)
121 -B bias : if bias >= 0, instance x becomes [x; bias]; if < 0, no bias term added (default -1)
122 -wi weight: weights adjust the parameter C of different classes (see README for details)
123 -v n: n-fold cross validation mode
124 -q : quiet mode (no outputs)
125 """
126 prob, param = None, None
127 if isinstance(arg1, (list, tuple)):
128 assert isinstance(arg2, (list, tuple))
129 y, x, options = arg1, arg2, arg3
130 prob = problem(y, x)
131 param = parameter(options)
132 elif isinstance(arg1, problem):
133 prob = arg1
134 if isinstance(arg2, parameter):
135 param = arg2
136 else :

Callers

nothing calls this directly

Calls 7

problemClass · 0.85
parameterClass · 0.85
printFunction · 0.85
set_biasMethod · 0.80
evaluationsFunction · 0.70
toPyModelFunction · 0.70
trainMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…