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)
| 77 | return (ACC, MSE, SCC) |
| 78 | |
| 79 | def 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 : |
nothing calls this directly
no test coverage detected
searching dependent graphs…