{"id":15523774,"url":"https://github.com/bwaldvogel/liblinear-java","last_synced_at":"2025-05-15T23:06:46.237Z","repository":{"id":443044,"uuid":"65312","full_name":"bwaldvogel/liblinear-java","owner":"bwaldvogel","description":"Java version of LIBLINEAR","archived":false,"fork":false,"pushed_at":"2024-12-31T13:57:43.000Z","size":3303,"stargazers_count":305,"open_issues_count":7,"forks_count":138,"subscribers_count":34,"default_branch":"main","last_synced_at":"2025-04-08T04:15:36.376Z","etag":null,"topics":["java","liblinear","logistic-regression","svm"],"latest_commit_sha":null,"homepage":"https://liblinear.bwaldvogel.de","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bwaldvogel.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2008-10-20T12:33:23.000Z","updated_at":"2025-02-27T19:58:02.000Z","dependencies_parsed_at":"2025-01-19T11:00:52.156Z","dependency_job_id":"7cec2c00-5f6a-4fea-a673-aabb96787a3b","html_url":"https://github.com/bwaldvogel/liblinear-java","commit_stats":{"total_commits":328,"total_committers":11,"mean_commits":"29.818181818181817","dds":0.3597560975609756,"last_synced_commit":"d52c06d5f56e1608142ad741f1b13116820127c7"},"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bwaldvogel%2Fliblinear-java","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bwaldvogel%2Fliblinear-java/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bwaldvogel%2Fliblinear-java/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bwaldvogel%2Fliblinear-java/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bwaldvogel","download_url":"https://codeload.github.com/bwaldvogel/liblinear-java/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254436944,"owners_count":22070946,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["java","liblinear","logistic-regression","svm"],"created_at":"2024-10-02T10:46:56.104Z","updated_at":"2025-05-15T23:06:41.053Z","avatar_url":"https://github.com/bwaldvogel.png","language":"Java","readme":"[![CI](https://github.com/bwaldvogel/liblinear-java/workflows/CI/badge.svg)](https://github.com/bwaldvogel/liblinear-java/actions)\n[![Maven Central](https://maven-badges.herokuapp.com/maven-central/de.bwaldvogel/liblinear/badge.svg)](http://maven-badges.herokuapp.com/maven-central/de.bwaldvogel/liblinear)\n[![codecov](https://codecov.io/gh/bwaldvogel/liblinear-java/branch/main/graph/badge.svg?token=Scy4yJzBf7)](https://codecov.io/gh/bwaldvogel/liblinear-java)\n[![BSD 3-Clause License](https://img.shields.io/github/license/bwaldvogel/liblinear-java.svg)](https://opensource.org/licenses/BSD-3-Clause)\n[![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.me/BenediktWaldvogel)\n\nThis is the Java version of LIBLINEAR.\n\nThe project site of the original `C++` version is located at\n       http://www.csie.ntu.edu.tw/~cjlin/liblinear/\n\nThe upstream changelog can be found at\n       http://www.csie.ntu.edu.tw/~cjlin/liblinear/log\n\nThe upstream GitHub project can be found at\n       https://github.com/cjlin1/liblinear\n\n## Dependencies ##\n\nThe only requirement is Java 11 or later.\n\n## Usage ##\n\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003ede.bwaldvogel\u003c/groupId\u003e\n    \u003cartifactId\u003eliblinear\u003c/artifactId\u003e\n    \u003cversion\u003e2.44\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\nPlease be aware that the code would be written differently at various places, i.e.\n\n- Java coding style,\n- less static functions and state,\n- smaller classes and methods,\n\nif it would be a pure Java project.\n\nHowever, I tried to stick as close as possible to the original C++ source code\nfor the following reasons:\n\n- **Maintainability**:\n        Patches for the original C++ version can often be applied easily\n\n- **Probability of translation errors**:\n        Sticking to the original source code makes it less likely to introduce\n        new bugs that are caused by porting to Java.\n\n- **Code Reviews**:\n        It should be easier to conduct code reviews since the sources can be compared to the original version.\n\n\nBelow follows a slightly modified version of the original README file.\nPlease note that the README refers to the C++ version.\nAs afore mentioned, the Java version is almost identical to use.\n\nThe three most important methods for programmatic usage that you might be interested in are:\n\n- `Linear.train(…)`\n- `Linear.predict(…)`\n- `Linear.predictProbability(…)`\n\n## Contributing ##\n\nPlease read the [contributing guidelines](CONTRIBUTING.md) if you want to contribute code to the project.\n\nIf you want to thank the author for this library or want to support the maintenance work,\nwe are happy to receive a donation.\n\n[![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.me/BenediktWaldvogel)\n\n-------------------------------------------------------------------------------\n\nLIBLINEAR is a simple package for solving large-scale regularized linear\nclassification, regression and outlier detection. It currently supports\n- L2-regularized logistic regression/L2-loss support vector classification/L1-loss support vector classification\n- L1-regularized L2-loss support vector classification/L1-regularized logistic regression\n- L2-regularized L2-loss support vector regression/L1-loss support vector regression\n- one-class support vector machine.\nThis document explains the usage of LIBLINEAR.\n\nTo get started, please read the **Quick Start** section first.\nFor developers, please check the **Library Usage** section to learn\nhow to integrate LIBLINEAR in your software.\n\nTable of Contents\n=================\n\n- When to use LIBLINEAR but not LIBSVM\n- Quick Start\n- `train` Usage\n- `predict` Usage\n- Examples\n- Library Usage\n- Additional Information\n\nWhen to use LIBLINEAR but not LIBSVM\n====================================\n\nThere are some large data for which with/without nonlinear mappings\ngives similar performances.  Without using kernels, one can\nefficiently train a much larger set via linear classification/regression.\nThese data usually have a large number of features. Document classification\nis an example.\n\nWarning: While generally liblinear is very fast, its default solver\nmay be slow under certain situations (e.g., data not scaled or C is\nlarge).\nSee Appendix B of our SVM guide about how to handle such cases.\n\nhttp://www.csie.ntu.edu.tw/~cjlin/papers/guide/guide.pdf\n\nWarning: If you are a beginner and your data sets are not large, you\nshould consider LIBSVM first.\n\nLIBSVM page:\nhttp://www.csie.ntu.edu.tw/~cjlin/libsvm\n\n\nQuick Start\n===========\n\nSee the section **Installation** for installing LIBLINEAR.\n\nAfter installation, there are programs `train` and `predict` for\ntraining and testing, respectively.\n\nAbout the data format, please check the README file of LIBSVM. Note\nthat feature index must start from 1 (but not 0).\n\nA sample classification data included in this package is `heart_scale`.\n\nType `train heart_scale`, and the program will read the training\ndata and output the model file `heart_scale.model`. If you have a test\nset called `heart_scale.t`, then type `predict heart_scale.t heart_scale.model output`\nto see the prediction accuracy. The `output` file contains the predicted class labels.\n\nFor more information about `train` and `predict`, see the sections\n`train` Usage and `predict` Usage.\n\nTo obtain good performances, sometimes one needs to scale the\ndata. Please check the program `svm-scale` of LIBSVM. For large and\nsparse data, use `-l 0` to keep the sparsity.\n\n`train` Usage\n=============\n\n    Usage: train [options] training_set_file [model_file]\n    options:\n    -s type : set type of solver (default 1)\n      for multi-class classification\n         0 -- L2-regularized logistic regression (primal)\n         1 -- L2-regularized L2-loss support vector classification (dual)\n         2 -- L2-regularized L2-loss support vector classification (primal)\n         3 -- L2-regularized L1-loss support vector classification (dual)\n         4 -- support vector classification by Crammer and Singer\n         5 -- L1-regularized L2-loss support vector classification\n         6 -- L1-regularized logistic regression\n         7 -- L2-regularized logistic regression (dual)\n      for regression\n        11 -- L2-regularized L2-loss support vector regression (primal)\n        12 -- L2-regularized L2-loss support vector regression (dual)\n        13 -- L2-regularized L1-loss support vector regression (dual)\n      for outlier detection\n        21 -- one-class support vector machine (dual)\n    -c cost : set the parameter C (default 1)\n    -p epsilon : set the epsilon in loss function of epsilon-SVR (default 0.1)\n    -n nu : set the parameter nu of one-class SVM (default 0.5)\n    -e epsilon : set tolerance of termination criterion\n        -s 0 and 2\n            |f'(w)|_2 \u003c= eps*min(pos,neg)/l*|f'(w0)|_2,\n            where f is the primal function and pos/neg are # of\n            positive/negative data (default 0.01)\n        -s 11\n            |f'(w)|_2 \u003c= eps*|f'(w0)|_2 (default 0.0001)\n        -s 1, 3, 4, 7, and 21\n            Dual maximal violation \u003c= eps; similar to libsvm (default 0.1 except 0.01 for -s 21)\n        -s 5 and 6\n            |f'(w)|_1 \u003c= eps*min(pos,neg)/l*|f'(w0)|_1,\n            where f is the primal function (default 0.01)\n        -s 12 and 13\n            |f'(alpha)|_1 \u003c= eps |f'(alpha0)|,\n            where f is the dual function (default 0.1)\n    -B bias : if bias \u003e= 0, instance x becomes [x; bias]; if \u003c 0, no bias term added (default -1)\n    -R : not regularize the bias; must with -B 1 to have the bias; DON'T use this unless you know what it is\n    \t(for -s 0, 2, 5, 6, 11)\n    -wi weight: weights adjust the parameter C of different classes (see README for details)\n    -v n: n-fold cross validation mode\n    -C : find parameters (C for -s 0, 2 and C, p for -s 11)\n    -q : quiet mode (no outputs)\n\nOption -v randomly splits the data into n parts and calculates cross\nvalidation accuracy on them.\n\nOption -C conducts cross validation under different parameters and finds\nthe best one. This option is supported only by -s 0, -s 2 (for finding\nC) and -s 11 (for finding C, p). If the solver is not specified, -s 2\nis used.\n\nFormulations:\n\nFor L2-regularized logistic regression (-s 0), we solve\n\n    min_w w^Tw/2 + C \\sum log(1 + exp(-y_i w^Tx_i))\n\nFor L2-regularized L2-loss SVC dual (-s 1), we solve\n\n    min_alpha  0.5(alpha^T (Q + I/2/C) alpha) - e^T alpha\n        s.t.   0 \u003c= alpha_i,\n\nFor L2-regularized L2-loss SVC (-s 2), we solve\n\n    min_w w^Tw/2 + C \\sum max(0, 1- y_i w^Tx_i)^2\n\nFor L2-regularized L1-loss SVC dual (-s 3), we solve\n\n    min_alpha  0.5(alpha^T Q alpha) - e^T alpha\n        s.t.   0 \u003c= alpha_i \u003c= C,\n\nFor L1-regularized L2-loss SVC (-s 5), we solve\n\n    min_w \\sum |w_j| + C \\sum max(0, 1- y_i w^Tx_i)^2\n\nFor L1-regularized logistic regression (-s 6), we solve\n\n    min_w \\sum |w_j| + C \\sum log(1 + exp(-y_i w^Tx_i))\n\nFor L2-regularized logistic regression (-s 7), we solve\n\n    min_alpha  0.5(alpha^T Q alpha) + \\sum alpha_i*log(alpha_i) + \\sum (C-alpha_i)*log(C-alpha_i) - a constant\n        s.t.   0 \u003c= alpha_i \u003c= C,\n\nwhere\n\n    Q is a matrix with Q_ij = y_i y_j x_i^T x_j.\n\nFor L2-regularized L2-loss SVR (-s 11), we solve\n\n    min_w w^Tw/2 + C \\sum max(0, |y_i-w^Tx_i|-epsilon)^2\n\nFor L2-regularized L2-loss SVR dual (-s 12), we solve\n\n    min_beta  0.5(beta^T (Q + lambda I/2/C) beta) - y^T beta + \\sum |beta_i|\n\nFor L2-regularized L1-loss SVR dual (-s 13), we solve\n\n    min_beta  0.5(beta^T Q beta) - y^T beta + \\sum |beta_i|\n        s.t.   -C \u003c= beta_i \u003c= C,\n\nwhere\n\n    Q is a matrix with Q_ij = x_i^T x_j.\n\nFor one-class SVM dual (-s 21), we solve\n\n    min_alpha 0.5(alpha^T Q alpha)\n        s.t.   0 \u003c= alpha_i \u003c= 1 and \\sum alpha_i = nu*l,\n\nwhere\n\n    Q is a matrix with Q_ij = x_i^T x_j.\n\nIf `bias \u003e= 0`, w becomes `[w; w_{n+1}]` and x becomes `[x; bias]`.  For\nexample, L2-regularized logistic regression (-s 0) becomes\n\n    min_w w^Tw/2 + (w_{n+1})^2/2 + C \\sum log(1 + exp(-y_i [w; w_{n+1}]^T[x_i; bias]))\n\nSome may prefer not having `(w_{n+1})^2/2` (i.e., bias variable not\nregularized). For primal solvers (-s 0, 2, 5, 6, 11), we provide an\noption -R to remove `(w_{n+1})^2/2`. However, -R is generally not needed\nas for most data with/without `(w_{n+1})^2/2` give similar performances.\n\nThe primal-dual relationship implies that -s 1 and -s 2 give the same\nmodel, -s 0 and -s 7 give the same, and -s 11 and -s 12 give the same.\n\nWe implement 1-vs-the rest multi-class strategy for classification.\nIn training `i` vs. `non_i`, their C parameters are `(weight from -wi)*C`\nand C, respectively. If there are only two classes, we train only one\nmodel. Thus `weight1*C` vs. `weight2*C` is used. See examples below.\n\nWe also implement multi-class SVM by Crammer and Singer (-s 4):\n\n    min_{w_m, \\xi_i}  0.5 \\sum_m ||w_m||^2 + C \\sum_i \\xi_i\n        s.t.  w^T_{y_i} x_i - w^T_m x_i \u003e= \\e^m_i - \\xi_i \\forall m,i\n\n    where e^m_i = 0 if y_i  = m,\n          e^m_i = 1 if y_i != m,\n\nHere we solve the dual problem:\n\n    min_{\\alpha}  0.5 \\sum_m ||w_m(\\alpha)||^2 + \\sum_i \\sum_m e^m_i alpha^m_i\n        s.t.  \\alpha^m_i \u003c= C^m_i \\forall m,i , \\sum_m \\alpha^m_i=0 \\forall i\n\n    where w_m(\\alpha) = \\sum_i \\alpha^m_i x_i,\n    and C^m_i = C if m  = y_i,\n        C^m_i = 0 if m != y_i.\n\n`predict` Usage\n===============\n\n    Usage: predict [options] test_file model_file output_file\n    options:\n    -b probability_estimates: whether to output probability estimates, 0 or 1 (default 0); currently for logistic regression only\n    -q : quiet mode (no outputs)\n\nNote that -b is only needed in the prediction phase. This is different\nfrom the setting of LIBSVM.\n\nExamples\n========\n\n    \u003e train data_file\n\nTrain linear SVM with L2-loss function.\n\n    \u003e train -s 0 data_file\n\nTrain a logistic regression model.\n\n    \u003e train -s 21 -n 0.1 data_file\n\nTrain a linear one-class SVM which selects roughly 10% data as outliers.\n\n    \u003e train -v 5 -e 0.001 data_file\n\nDo five-fold cross-validation using L2-loss SVM.\nUse a smaller stopping tolerance 0.001 than the default\n0.1 if you want more accurate solutions.\n\n    \u003e train -C data_file\n\nConduct cross validation many times by L2-loss SVM\nand find the parameter C which achieves the best cross\nvalidation accuracy.\n\n    \u003e train -C -s 0 -v 3 -c 0.5 -e 0.0001 data_file\n\nFor parameter selection by -C, users can specify other\nsolvers (currently -s 0, -s 2 and -s 11 are supported) and\ndifferent number of CV folds. Further, users can use\nthe -c option to specify the smallest C value of the\nsearch range. This option is useful when users want to\nrerun the parameter selection procedure from a specified\nC under a different setting, such as a stricter stopping\ntolerance -e 0.0001 in the above example. Similarly, for\n-s 11, users can use the -p option to specify the\nmaximal p value of the search range.\n\n    \u003e train -c 10 -w1 2 -w2 5 -w3 2 four_class_data_file\n\nTrain four classifiers:\n    positive        negative        Cp      Cn\n    class 1         class 2,3,4.    20      10\n    class 2         class 1,3,4.    50      10\n    class 3         class 1,2,4.    20      10\n    class 4         class 1,2,3.    10      10\n\n    \u003e train -c 10 -w3 1 -w2 5 two_class_data_file\n\nIf there are only two classes, we train ONE model.\nThe C values for the two classes are 10 and 50.\n\n    \u003e predict -b 1 test_file data_file.model output_file\n\nOutput probability estimates (for logistic regression only).\n\nLibrary Usage\n=============\n\nThese functions and structures are declared in the header file `linear.h`.\nYou can see `train.c` and `predict.c` for examples showing how to use them.\nWe define LIBLINEAR_VERSION and declare `extern int liblinear_version;`\nin linear.h, so you can check the version number.\n\n- Function: `model* train(const struct problem *prob,\n                const struct parameter *param);`\n\n    This function constructs and returns a linear classification\n    or regression model according to the given training data and\n    parameters.\n\n    `struct problem` describes the problem:\n\n        struct problem\n        {\n            int l, n;\n            int *y;\n            struct feature_node **x;\n            double bias;\n        };\n\n    where `l` is the number of training data. If bias \u003e= 0, we assume\n    that one additional feature is added to the end of each data\n    instance. `n` is the number of feature (including the bias feature\n    if bias \u003e= 0). `y` is an array containing the target values. (integers\n    in classification, real numbers in regression) And `x` is an array\n    of pointers, each of which points to a sparse representation (array\n    of feature_node) of one training vector.\n\n    For example, if we have the following training data:\n\n        LABEL       ATTR1   ATTR2   ATTR3   ATTR4   ATTR5\n        -----       -----   -----   -----   -----   -----\n        1           0       0.1     0.2     0       0\n        2           0       0.1     0.3    -1.2     0\n        1           0.4     0       0       0       0\n        2           0       0.1     0       1.4     0.5\n        3          -0.1    -0.2     0.1     1.1     0.1\n\n    and bias = 1, then the components of problem are:\n\n        l = 5\n        n = 6\n\n        y -\u003e 1 2 1 2 3\n\n        x -\u003e [ ] -\u003e (2,0.1) (3,0.2) (6,1) (-1,?)\n             [ ] -\u003e (2,0.1) (3,0.3) (4,-1.2) (6,1) (-1,?)\n             [ ] -\u003e (1,0.4) (6,1) (-1,?)\n             [ ] -\u003e (2,0.1) (4,1.4) (5,0.5) (6,1) (-1,?)\n             [ ] -\u003e (1,-0.1) (2,-0.2) (3,0.1) (4,1.1) (5,0.1) (6,1) (-1,?)\n\n    `struct parameter` describes the parameters of a linear classification or regression model:\n\n        struct parameter\n        {\n                int solver_type;\n\n                /* these are for training only */\n                double eps;             /* stopping tolerance */\n                double C;\n                double nu;              /* one-class SVM only */\n                int nr_weight;\n                int *weight_label;\n                double* weight;\n                double p;\n                double *init_sol;\n        };\n\n    solver_type can be one of L2R_LR, L2R_L2LOSS_SVC_DUAL, L2R_L2LOSS_SVC, L2R_L1LOSS_SVC_DUAL, MCSVM_CS, L1R_L2LOSS_SVC, L1R_LR, L2R_LR_DUAL, L2R_L2LOSS_SVR, L2R_L2LOSS_SVR_DUAL, L2R_L1LOSS_SVR_DUAL, ONECLASS_SVM.\n  for classification\n    - `L2R_LR`                L2-regularized logistic regression (primal)\n    - `L2R_L2LOSS_SVC_DUAL`   L2-regularized L2-loss support vector classification (dual)\n    - `L2R_L2LOSS_SVC`        L2-regularized L2-loss support vector classification (primal)\n    - `L2R_L1LOSS_SVC_DUAL`   L2-regularized L1-loss support vector classification (dual)\n    - `MCSVM_CS`              support vector classification by Crammer and Singer\n    - `L1R_L2LOSS_SVC`        L1-regularized L2-loss support vector classification\n    - `L1R_LR`                L1-regularized logistic regression\n    - `L2R_LR_DUAL`           L2-regularized logistic regression (dual)\n  for regression\n    - `L2R_L2LOSS_SVR`        L2-regularized L2-loss support vector regression (primal)\n    - `L2R_L2LOSS_SVR_DUAL`   L2-regularized L2-loss support vector regression (dual)\n    - `L2R_L1LOSS_SVR_DUAL`   L2-regularized L1-loss support vector regression (dual)\n  for outlier detection\n    - `ONECLASS_SVM`          one-class support vector machine (dual)\n\n    C is the cost of constraints violation.\n    p is the sensitiveness of loss of support vector regression.\n    nu in ONECLASS_SVM approximates the fraction of data as outliers.\n    eps is the stopping criterion.\n\n    nr_weight, weight_label, and weight are used to change the penalty\n    for some classes (If the weight for a class is not changed, it is\n    set to 1). This is useful for training classifier using unbalanced\n    input data or with asymmetric misclassification cost.\n\n    nr_weight is the number of elements in the array weight_label and\n    weight. Each weight[i] corresponds to weight_label[i], meaning that\n    the penalty of class weight_label[i] is scaled by a factor of weight[i].\n\n    If you do not want to change penalty for any of the classes,\n    just set nr_weight to 0.\n\n    init_sol includes the initial weight vectors (supported for only some\n    solvers). See the explanation of the vector w in the model\n    structure.\n\n    *NOTE* To avoid wrong parameters, check_parameter() should be\n    called before train().\n\n    struct model stores the model obtained from the training procedure:\n\n        struct model\n        {\n                struct parameter param;\n                int nr_class;           /* number of classes */\n                int nr_feature;\n                double *w;\n                int *label;             /* label of each class */\n                double bias;\n                double rho;             /* one-class SVM only */\n        };\n\n     param describes the parameters used to obtain the model.\n\n     nr_class and nr_feature are the number of classes and features,\n     respectively. nr_class = 2 for regression.\n\n     The array w gives feature weights; its size is\n     nr_feature*nr_class but is nr_feature if nr_class = 2. We use one\n     against the rest for multi-class classification, so each feature\n     index corresponds to nr_class weight values. Weights are\n     organized in the following way\n\n     ```\n         +------------------+------------------+------------+\n         | nr_class weights | nr_class weights |  ...\n         | for 1st feature  | for 2nd feature  |\n         +------------------+------------------+------------+\n     ```\n\n     The array label stores class labels.\n\n     If bias \u003e= 0, x becomes [x; bias]. The number of features is\n     increased by one, so w is a (nr_feature+1)*nr_class array. The\n     value of bias is stored in the variable bias.\n\n     rho is the bias term used in one-class SVM only.\n\n- Function: `void cross_validation(const problem *prob, const parameter *param, int nr_fold, double *target);`\n\n    This function conducts cross validation. Data are separated to\n    nr_fold folds. Under given parameters, sequentially each fold is\n    validated using the model from training the remaining. Predicted\n    labels in the validation process are stored in the array called\n    target.\n\n    The format of prob is same as that for train().\n\n- Function: `void find_parameters(const struct problem *prob,\n             const struct parameter *param, int nr_fold, double start_C,\n             double start_p, double *best_C, double *best_p, double *best_score);`\n\n    This function is similar to cross_validation. However, instead of\n    conducting cross validation under specified parameters. For -s 0, 2, it\n    conducts cross validation many times under parameters C = start_C,\n    2*start_C, 4*start_C, 8*start_C, ..., and finds the best one with\n    the highest cross validation accuracy. For -s 11, it conducts cross\n    validation many times with a two-fold loop. The outer loop considers a\n    default sequence of p = 19/20*max_p, ..., 1/20*max_p, 0 and\n    under each p value the inner loop considers a sequence of parameters\n    C = start_C, 2*start_C, 4*start_C, ..., and finds the best one with the\n    lowest mean squared error.\n\n    If start_C \u003c= 0, then this procedure calculates a small enough C\n    for prob as the start_C. The procedure stops when the models of\n    all folds become stable or C reaches max_C.\n\n    If start_p \u003c= 0, then this procedure calculates a maximal p for prob as\n    the start_p. Otherwise, the procedure starts with the first\n    i/20*max_p \u003c= start_p so the outer sequence is i/20*max_p,\n    (i-1)/20*max_p, ..., 0.\n\n    The best C, the best p, and the corresponding accuracy (or MSE) are\n    assigned to *best_C, *best_p and *best_score, respectively. For\n    classification, *best_p is not used, and the returned value is -1.\n\n- Function: `double predict(const model *model_, const feature_node *x);`\n\n    For a classification model, the predicted class for x is returned.\n    For a regression model, the function value of x calculated using\n    the model is returned.\n\n- Function: `double predict_values(const struct model *model_,\n            const struct feature_node *x, double* dec_values);`\n\n    This function gives nr_w decision values in the array dec_values.\n    nr_w=1 if regression is applied or the number of classes is two. An exception is\n    multi-class SVM by Crammer and Singer (-s 4), where nr_w = 2 if there are two classes. For all other situations, nr_w is the\n    number of classes.\n\n    We implement one-vs-the rest multi-class strategy (-s 0,1,2,3,5,6,7)\n    and multi-class SVM by Crammer and Singer (-s 4) for multi-class SVM.\n    The class with the highest decision value is returned.\n\n- Function: `double predict_probability(const struct model *model_,\n            const struct feature_node *x, double* prob_estimates);`\n\n    This function gives nr_class probability estimates in the array\n    prob_estimates. nr_class can be obtained from the function\n    get_nr_class. The class with the highest probability is\n    returned. Currently, we support only the probability outputs of\n    logistic regression.\n\n- Function: `int get_nr_feature(const model *model_);`\n\n    The function gives the number of attributes of the model.\n\n- Function: `int get_nr_class(const model *model_);`\n\n    The function gives the number of classes of the model.\n    For a regression model, 2 is returned.\n\n- Function: `void get_labels(const model *model_, int* label);`\n\n    This function outputs the name of labels into an array called label.\n    For a regression model, label is unchanged.\n\n- Function: `double get_decfun_coef(const struct model *model_, int feat_idx,\n            int label_idx);`\n\n    This function gives the coefficient for the feature with feature index =\n    feat_idx and the class with label index = label_idx. Note that feat_idx\n    starts from 1, while label_idx starts from 0. If feat_idx is not in the\n    valid range (1 to nr_feature), then a zero value will be returned. For\n    classification models, if label_idx is not in the valid range (0 to\n    nr_class-1), then a zero value will be returned; for regression models\n    and one-class SVM models, label_idx is ignored.\n\n- Function: `double get_decfun_bias(const struct model *model_, int label_idx);`\n\n    This function gives the bias term corresponding to the class with the\n    label_idx. For classification models, if label_idx is not in a valid range\n    (0 to nr_class-1), then a zero value will be returned; for regression\n    models, label_idx is ignored. This function cannot be called for a one-class\n    SVM model.\n\n- Function: `double get_decfun_rho(const struct model *model_);`\n\n    This function gives rho, the bias term used in one-class SVM only. This\n    function can only be called for a one-class SVM model.\n\n- Function: `const char *check_parameter(const struct problem *prob,\n            const struct parameter *param);`\n\n    This function checks whether the parameters are within the feasible\n    range of the problem. This function should be called before calling\n    train() and cross_validation(). It returns NULL if the\n    parameters are feasible, otherwise an error message is returned.\n\n- Function: `int check_probability_model(const struct model *model);`\n\n    This function returns 1 if the model supports probability output;\n    otherwise, it returns 0.\n\n- Function: `int check_regression_model(const struct model *model);`\n\n    This function returns 1 if the model is a regression model; otherwise\n    it returns 0.\n\n- Function: `int check_oneclass_model(const struct model *model);`\n\n    This function returns 1 if the model is a one-class SVM model; otherwise\n    it returns 0.\n\n- Function: `int save_model(const char *model_file_name,\n            const struct model *model_);`\n\n    This function saves a model to a file; returns 0 on success, or -1\n    if an error occurs.\n\n- Function: `struct model *load_model(const char *model_file_name);`\n\n    This function returns a pointer to the model read from the file,\n    or a null pointer if the model could not be loaded.\n\n- Function: `void free_model_content(struct model *model_ptr);`\n\n    This function frees the memory used by the entries in a model structure.\n\n- Function: `void free_and_destroy_model(struct model **model_ptr_ptr);`\n\n    This function frees the memory used by a model and destroys the model\n    structure.\n\n- Function: `void destroy_param(struct parameter *param);`\n\n    This function frees the memory used by a parameter set.\n\n- Function: `void set_print_string_function(void (*print_func)(const char *));`\n\n    Users can specify their output format by a function. Use\n        set_print_string_function(NULL);\n    for default printing to stdout.\n\nAdditional Information\n======================\n\nIf you find LIBLINEAR helpful, please cite it as\n\n    R.-E. Fan, K.-W. Chang, C.-J. Hsieh, X.-R. Wang, and C.-J. Lin.\n    LIBLINEAR: A Library for Large Linear Classification, Journal of\n    Machine Learning Research 9(2008), 1871-1874. Software available at\n    http://www.csie.ntu.edu.tw/~cjlin/liblinear\n\nFor any questions and comments, please send your email to\ncjlin@csie.ntu.edu.tw\n","funding_links":["https://www.paypal.me/BenediktWaldvogel"],"categories":["Java"],"sub_categories":["Tools","[Tools](#tools-1)","Speech Recognition"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbwaldvogel%2Fliblinear-java","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbwaldvogel%2Fliblinear-java","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbwaldvogel%2Fliblinear-java/lists"}