Documentation ¶
Index ¶
- Constants
- func Accuracy(y_true, y_pred *mat64.Dense) float64
- func Predict(model *Model, X *mat64.Dense) *mat64.Dense
- func PredictProba(model *Model, X *mat64.Dense) *mat64.Dense
- func ReadLibsvm(filepath string, oneBased bool) (X, y *mat64.Dense)
- func SaveModel(model *Model, filename string)
- type Model
Constants ¶
const ( // Solver Type L2R_LR = int(C.L2R_LR) L2R_L2LOSS_SVC_DUAL = int(C.L2R_L2LOSS_SVC_DUAL) L2R_L2LOSS_SVC = int(C.L2R_L2LOSS_SVC) L2R_L1LOSS_SVC_DUAL = int(C.L2R_L1LOSS_SVC_DUAL) MCSVM_CS = int(C.MCSVM_CS) L1R_L2LOSS_SVC = int(C.L1R_L2LOSS_SVC) L1R_LR = int(C.L1R_LR) L2R_LR_DUAL = int(C.L2R_LR_DUAL) L2R_L2LOSS_SVR = int(C.L2R_L2LOSS_SVR) L2R_L2LOSS_SVR_DUAL = int(C.L2R_L2LOSS_SVR_DUAL) L2R_L1LOSS_SVR_DUAL = int(C.L2R_L1LOSS_SVR_DUAL) )
Variables ¶
This section is empty.
Functions ¶
func PredictProba ¶
double predict_probability(const struct model *model_, const struct feature_node *x, double* prob_estimates);
func ReadLibsvm ¶
ReadLibsvm reads libsvm format data from `filepath`. `oneBased` denotes the index of data stored in the file starts from 1 (`oneBased=true`) or 0 (`oneBased=false`). Returned X, y is of dimension (nSamples, nFeatures) and (nSamples, 1) respectively.
Types ¶
type Model ¶
type Model struct {
// contains filtered or unexported fields
}
Model contains a pointer to C's struct model (i.e., `*C.struct_model`). It is returned after training and used for predicting.
func Train ¶
func Train(X, y *mat64.Dense, bias float64, solverType int, c_, p, eps float64, classWeights map[int]float64) *Model
Wrapper for the `train` function in liblinear.
`model* train(const struct problem *prob, const struct parameter *param);`
The explanation of parameters are:
solverType:
for multi-class classification 0 -- L2-regularized logistic regression (primal) 1 -- L2-regularized L2-loss support vector classification (dual) 2 -- L2-regularized L2-loss support vector classification (primal) 3 -- L2-regularized L1-loss support vector classification (dual) 4 -- support vector classification by Crammer and Singer 5 -- L1-regularized L2-loss support vector classification 6 -- L1-regularized logistic regression 7 -- L2-regularized logistic regression (dual) for regression 11 -- L2-regularized L2-loss support vector regression (primal) 12 -- L2-regularized L2-loss support vector regression (dual) 13 -- L2-regularized L1-loss support vector regression (dual)
eps is the stopping criterion.
C_ is the cost of constraints violation.
p is the sensitiveness of loss of support vector regression.
classWeights is a map from int to float64, with the key be the class and the value be the weight. For example, {1: 10, -1: 0.5} means giving weight=10 for class=1 while weight=0.5 for class=-1
If you do not want to change penalty for any of the classes, just set classWeights to nil.