{"id":32178268,"url":"https://github.com/cjlin1/libsvm","last_synced_at":"2025-10-21T20:52:42.604Z","repository":{"id":10537151,"uuid":"12731904","full_name":"cjlin1/libsvm","owner":"cjlin1","description":"LIBSVM -- A Library for Support Vector Machines","archived":false,"fork":false,"pushed_at":"2025-05-12T04:54:27.000Z","size":9740,"stargazers_count":4644,"open_issues_count":112,"forks_count":1637,"subscribers_count":294,"default_branch":"master","last_synced_at":"2025-07-13T23:02:40.574Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://www.csie.ntu.edu.tw/~cjlin/libsvm/","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/cjlin1.png","metadata":{"files":{"readme":"README","changelog":null,"contributing":null,"funding":null,"license":null,"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,"zenodo":null}},"created_at":"2013-09-10T14:32:07.000Z","updated_at":"2025-07-10T04:10:04.000Z","dependencies_parsed_at":"2023-01-13T16:00:01.679Z","dependency_job_id":"66f71806-ab2d-4c17-a99b-ed0f17b434cb","html_url":"https://github.com/cjlin1/libsvm","commit_stats":{"total_commits":1074,"total_committers":61,"mean_commits":17.60655737704918,"dds":0.3780260707635009,"last_synced_commit":"aed66346593ec0e075f38eda10fef0c1fb132692"},"previous_names":[],"tags_count":41,"template":false,"template_full_name":null,"purl":"pkg:github/cjlin1/libsvm","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cjlin1%2Flibsvm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cjlin1%2Flibsvm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cjlin1%2Flibsvm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cjlin1%2Flibsvm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cjlin1","download_url":"https://codeload.github.com/cjlin1/libsvm/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cjlin1%2Flibsvm/sbom","scorecard":{"id":284289,"data":{"date":"2025-08-11","repo":{"name":"github.com/cjlin1/libsvm","commit":"65367d015d9e368cc79f5c56924455c3a4fb5e48"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.5,"checks":[{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 1 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Binary-Artifacts","score":0,"reason":"binaries present in source code","details":["Warn: binary detected: java/libsvm.jar:1","Warn: binary detected: windows/libsvm.dll:1","Warn: binary detected: windows/libsvmread.mexw64:1","Warn: binary detected: windows/libsvmwrite.mexw64:1","Warn: binary detected: windows/svm-predict.exe:1","Warn: binary detected: windows/svm-scale.exe:1","Warn: binary detected: windows/svm-toy.exe:1","Warn: binary detected: windows/svm-train.exe:1","Warn: binary detected: windows/svmpredict.mexw64:1","Warn: binary detected: windows/svmtrain.mexw64:1"],"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/wheel.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/wheel.yml:21: update your workflow using https://app.stepsecurity.io/secureworkflow/cjlin1/libsvm/wheel.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/wheel.yml:30: update your workflow using https://app.stepsecurity.io/secureworkflow/cjlin1/libsvm/wheel.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/wheel.yml:42: update your workflow using https://app.stepsecurity.io/secureworkflow/cjlin1/libsvm/wheel.yml/master?enable=pin","Info:   0 out of   2 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   1 third-party GitHubAction dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: COPYRIGHT:0","Info: FSF or OSI recognized license: BSD 3-Clause \"New\" or \"Revised\" License: COPYRIGHT:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}}]},"last_synced_at":"2025-08-17T16:50:55.408Z","repository_id":10537151,"created_at":"2025-08-17T16:50:55.408Z","updated_at":"2025-08-17T16:50:55.408Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":280333492,"owners_count":26312845,"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","status":"online","status_checked_at":"2025-10-21T02:00:06.614Z","response_time":58,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2025-10-21T20:52:41.682Z","updated_at":"2025-10-21T20:52:42.585Z","avatar_url":"https://github.com/cjlin1.png","language":"Java","readme":"Libsvm is a simple, easy-to-use, and efficient software for SVM\nclassification and regression. It solves C-SVM classification, nu-SVM\nclassification, one-class-SVM, epsilon-SVM regression, and nu-SVM\nregression. It also provides an automatic model selection tool for\nC-SVM classification. This document explains the use of libsvm.\n\nLibsvm is available at\nhttp://www.csie.ntu.edu.tw/~cjlin/libsvm\nPlease read the COPYRIGHT file before using libsvm.\n\nTable of Contents\n=================\n\n- Quick Start\n- Installation and Data Format\n- `svm-train' Usage\n- `svm-predict' Usage\n- `svm-scale' Usage\n- Tips on Practical Use\n- Examples\n- Precomputed Kernels\n- Library Usage\n- Java Version\n- Building Windows Binaries\n- Additional Tools: Sub-sampling, Parameter Selection, Format checking, etc.\n- MATLAB/OCTAVE Interface\n- Python Interface\n- Additional Information\n\nQuick Start\n===========\n\nIf you are new to SVM and if the data is not large, please go to\n`tools' directory and use easy.py after installation. It does\neverything automatic -- from data scaling to parameter selection.\n\nUsage: easy.py training_file [testing_file]\n\nMore information about parameter selection can be found in\n`tools/README.'\n\nInstallation and Data Format\n============================\n\nOn Unix systems, type `make' to build the `svm-train', `svm-predict',\nand `svm-scale' programs. Run them without arguments to show the\nusages of them.\n\nOn other systems, consult `Makefile' to build them (e.g., see\n'Building Windows binaries' in this file) or use the pre-built\nbinaries (Windows binaries are in the directory `windows').\n\nThe format of training and testing data files is:\n\n\u003clabel\u003e \u003cindex1\u003e:\u003cvalue1\u003e \u003cindex2\u003e:\u003cvalue2\u003e ...\n.\n.\n.\n\nEach line contains an instance and is ended by a '\\n' character. \nWhile there can be no feature values for a sample (i.e., a row of all zeros), \nthe \u003clabel\u003e column must not be empty. For \u003clabel\u003e in the training set, \nwe have the following cases.\n\n* classification: \u003clabel\u003e is an integer indicating the class label\n  (multi-class is supported).\n\n* For regression, \u003clabel\u003e is the target value which can be any real\n  number.\n\n* For one-class SVM, \u003clabel\u003e has no effect and can be any number.\n\nIn the test set, \u003clabel\u003e is used only to calculate accuracy or\nerrors. If it's unknown, any number is fine. For one-class SVM, if\nnon-outliers/outliers are known, their labels in the test file must be\n+1/-1 for evaluation. The \u003clabel\u003e column is read using strtod() provided by \nthe C standard library. Therefore, \u003clabel\u003e values that are numerically \nequivalent will be treated the same (e.g., +01e0 and 1 count as the same class).\n\nThe pair \u003cindex\u003e:\u003cvalue\u003e gives a feature (attribute) value: \u003cindex\u003e is\nan integer starting from 1 and \u003cvalue\u003e is a real number. The only\nexception is the precomputed kernel, where \u003cindex\u003e starts from 0; see\nthe section of precomputed kernels. Indices must be in ASCENDING\norder.\n\nA sample classification data included in this package is\n`heart_scale'. To check if your data is in a correct form, use\n`tools/checkdata.py' (details in `tools/README').\n\nType `svm-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 `svm-predict heart_scale.t\nheart_scale.model output' to see the prediction accuracy. The `output'\nfile contains the predicted class labels.\n\nFor classification, if training data are in only one class (i.e., all\nlabels are the same), then `svm-train' issues a warning message:\n`Warning: training data in only one class. See README for details,'\nwhich means the training data is very unbalanced. The label in the\ntraining data is directly returned when testing.\n\nThere are some other useful programs in this package.\n\nsvm-scale:\n\n\tThis is a tool for scaling input data file.\n\nsvm-toy:\n\n\tThis is a simple graphical interface which shows how SVM\n\tseparate data in a plane. You can click in the window to\n\tdraw data points. Use \"change\" button to choose class\n\t1, 2 or 3 (i.e., up to three classes are supported), \"load\"\n\tbutton to load data from a file, \"save\" button to save data to\n\ta file, \"run\" button to obtain an SVM model, and \"clear\"\n\tbutton to clear the window.\n\n\tYou can enter options in the bottom of the window, the syntax of\n\toptions is the same as `svm-train'.\n\n\tNote that \"load\" and \"save\" consider dense data format both in\n\tclassification and the regression cases. For classification,\n\teach data point has one label (the color) that must be 1, 2,\n\tor 3 and two attributes (x-axis and y-axis values) in\n\t[0,1). For regression, each data point has one target value\n\t(y-axis) and one attribute (x-axis values) in [0, 1).\n\n\tType `make' in respective directories to build them.\n\n\tYou need Qt library to build the Qt version.\n\t(available from http://www.trolltech.com)\n\n\tYou need GTK+ library to build the GTK version.\n\t(available from http://www.gtk.org)\n\n\tThe pre-built Windows binaries are in the `windows'\n\tdirectory. We use Visual C++ on a 64-bit machine.\n\n`svm-train' Usage\n=================\n\nUsage: svm-train [options] training_set_file [model_file]\noptions:\n-s svm_type : set type of SVM (default 0)\n\t0 -- C-SVC\t\t(multi-class classification)\n\t1 -- nu-SVC\t\t(multi-class classification)\n\t2 -- one-class SVM\n\t3 -- epsilon-SVR\t(regression)\n\t4 -- nu-SVR\t\t(regression)\n-t kernel_type : set type of kernel function (default 2)\n\t0 -- linear: u'*v\n\t1 -- polynomial: (gamma*u'*v + coef0)^degree\n\t2 -- radial basis function: exp(-gamma*|u-v|^2)\n\t3 -- sigmoid: tanh(gamma*u'*v + coef0)\n\t4 -- precomputed kernel (kernel values in training_set_file)\n-d degree : set degree in kernel function (default 3)\n-g gamma : set gamma in kernel function (default 1/num_features)\n-r coef0 : set coef0 in kernel function (default 0)\n-c cost : set the parameter C of C-SVC, epsilon-SVR, and nu-SVR (default 1)\n-n nu : set the parameter nu of nu-SVC, one-class SVM, and nu-SVR (default 0.5)\n-p epsilon : set the epsilon in loss function of epsilon-SVR (default 0.1)\n-m cachesize : set cache memory size in MB (default 100)\n-e epsilon : set tolerance of termination criterion (default 0.001)\n-h shrinking : whether to use the shrinking heuristics, 0 or 1 (default 1)\n-b probability_estimates : whether to train a model for probability estimates, 0 or 1 (default 0)\n-wi weight : set the parameter C of class i to weight*C, for C-SVC (default 1)\n-v n: n-fold cross validation mode\n-q : quiet mode (no outputs)\n\n\noption -v randomly splits the data into n parts and calculates cross\nvalidation accuracy/mean squared error on them.\n\nSee libsvm FAQ for the meaning of outputs.\n\n`svm-predict' Usage\n===================\n\nUsage: svm-predict [options] test_file model_file output_file\noptions:\n-b probability_estimates: whether to predict probability estimates, 0 or 1 (default 0).\n\nmodel_file is the model file generated by svm-train.\ntest_file is the test data you want to predict.\nsvm-predict will produce output in the output_file.\n\n`svm-scale' Usage\n=================\n\nUsage: svm-scale [options] data_filename\noptions:\n-l lower : x scaling lower limit (default -1)\n-u upper : x scaling upper limit (default +1)\n-y y_lower y_upper : y scaling limits (default: no y scaling)\n-s save_filename : save scaling parameters to save_filename\n-r restore_filename : restore scaling parameters from restore_filename\n\nSee 'Examples' in this file for examples.\n\nTips on Practical Use\n=====================\n\n* Scale your data. For example, scale each attribute to [0,1] or [-1,+1].\n* For C-SVC, consider using the model selection tool in the tools directory.\n* nu in nu-SVC/one-class-SVM/nu-SVR approximates the fraction of training\n  errors and support vectors.\n* If data for classification are unbalanced (e.g. many positive and\n  few negative), try different penalty parameters C by -wi (see\n  examples below).\n* Specify larger cache size (i.e., larger -m) for huge problems.\n\nExamples\n========\n\n\u003e svm-scale -l -1 -u 1 -s range train \u003e train.scale\n\u003e svm-scale -r range test \u003e test.scale\n\nScale each feature of the training data to be in [-1,1]. Scaling\nfactors are stored in the file range and then used for scaling the\ntest data.\n\n\u003e svm-train -s 0 -c 5 -t 2 -g 0.5 -e 0.1 data_file\n\nTrain a classifier with RBF kernel exp(-0.5|u-v|^2), C=5, and\nstopping tolerance 0.1.\n\n\u003e svm-train -s 3 -p 0.1 -t 0 data_file\n\nSolve SVM regression with linear kernel u'v and epsilon=0.1\nin the loss function.\n\n\u003e svm-train -c 10 -w1 1 -w-2 5 -w4 2 data_file\n\nTrain a classifier with penalty 10 = 1 * 10 for class 1, penalty 50 =\n5 * 10 for class -2, and penalty 20 = 2 * 10 for class 4.\n\n\u003e svm-train -s 0 -c 100 -g 0.1 -v 5 data_file\n\nDo five-fold cross validation for the classifier using\nthe parameters C = 100 and gamma = 0.1\n\n\u003e svm-train -s 0 -b 1 data_file\n\u003e svm-predict -b 1 test_file data_file.model output_file\n\nObtain a model with probability information and predict test data with\nprobability estimates\n\nPrecomputed Kernels\n===================\n\nUsers may precompute kernel values and input them as training and\ntesting files.  Then libsvm does not need the original\ntraining/testing sets.\n\nAssume there are L training instances x1, ..., xL and.\nLet K(x, y) be the kernel\nvalue of two instances x and y. The input formats\nare:\n\nNew training instance for xi:\n\n\u003clabel\u003e 0:i 1:K(xi,x1) ... L:K(xi,xL)\n\nNew testing instance for any x:\n\n\u003clabel\u003e 0:? 1:K(x,x1) ... L:K(x,xL)\n\nThat is, in the training file the first column must be the \"ID\" of\nxi. In testing, ? can be any value.\n\nAll kernel values including ZEROs must be explicitly provided.  Any\npermutation or random subsets of the training/testing files are also\nvalid (see examples below).\n\nNote: the format is slightly different from the precomputed kernel\npackage released in libsvmtools earlier.\n\nExamples:\n\n\tAssume the original training data has three four-feature\n\tinstances and testing data has one instance:\n\n\t15  1:1 2:1 3:1 4:1\n\t45      2:3     4:3\n\t25          3:1\n\n\t15  1:1     3:1\n\n\tIf the linear kernel is used, we have the following new\n\ttraining/testing sets:\n\n\t15  0:1 1:4 2:6  3:1\n\t45  0:2 1:6 2:18 3:0\n\t25  0:3 1:1 2:0  3:1\n\n\t15  0:? 1:2 2:0  3:1\n\n\t? can be any value.\n\n\tAny subset of the above training file is also valid. For example,\n\n\t25  0:3 1:1 2:0  3:1\n\t45  0:2 1:6 2:18 3:0\n\n\timplies that the kernel matrix is\n\n\t\t[K(2,2) K(2,3)] = [18 0]\n\t\t[K(3,2) K(3,3)] = [0  1]\n\nLibrary Usage\n=============\n\nThese functions and structures are declared in the header file\n`svm.h'.  You need to #include \"svm.h\" in your C/C++ source files and\nlink your program with `svm.cpp'. You can see `svm-train.c' and\n`svm-predict.c' for examples showing how to use them. We define\nLIBSVM_VERSION and declare `extern int libsvm_version;' in svm.h, so\nyou can check the version number.\n\nBefore you classify test data, you need to construct an SVM model\n(`svm_model') using training data. A model can also be saved in\na file for later use. Once an SVM model is available, you can use it\nto classify new data.\n\n- Function: struct svm_model *svm_train(const struct svm_problem *prob,\n\t\t\t\t\tconst struct svm_parameter *param);\n\n    This function constructs and returns an SVM model according to\n    the given training data and parameters.\n\n    struct svm_problem describes the problem:\n\n\tstruct svm_problem\n\t{\n\t\tint l;\n\t\tdouble *y;\n\t\tstruct svm_node **x;\n\t};\n\n    where `l' is the number of training data, and `y' is an array containing\n    their target values. (integers in classification, real numbers in\n    regression) `x' is an array of pointers, each of which points to a sparse\n    representation (array of svm_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    then the components of svm_problem are:\n\n    l = 5\n\n    y -\u003e 1 2 1 2 3\n\n    x -\u003e [ ] -\u003e (2,0.1) (3,0.2) (-1,?)\n         [ ] -\u003e (2,0.1) (3,0.3) (4,-1.2) (-1,?)\n         [ ] -\u003e (1,0.4) (-1,?)\n         [ ] -\u003e (2,0.1) (4,1.4) (5,0.5) (-1,?)\n         [ ] -\u003e (1,-0.1) (2,-0.2) (3,0.1) (4,1.1) (5,0.1) (-1,?)\n\n    where (index,value) is stored in the structure `svm_node':\n\n\tstruct svm_node\n\t{\n\t\tint index;\n\t\tdouble value;\n\t};\n\n    index = -1 indicates the end of one vector. Note that indices must\n    be in ASCENDING order.\n\n    struct svm_parameter describes the parameters of an SVM model:\n\n\tstruct svm_parameter\n\t{\n\t\tint svm_type;\n\t\tint kernel_type;\n\t\tint degree;\t/* for poly */\n\t\tdouble gamma;\t/* for poly/rbf/sigmoid */\n\t\tdouble coef0;\t/* for poly/sigmoid */\n\n\t\t/* these are for training only */\n\t\tdouble cache_size; /* in MB */\n\t\tdouble eps;\t/* stopping criteria */\n\t\tdouble C;\t/* for C_SVC, EPSILON_SVR, and NU_SVR */\n\t\tint nr_weight;\t\t/* for C_SVC */\n\t\tint *weight_label;\t/* for C_SVC */\n\t\tdouble* weight;\t\t/* for C_SVC */\n\t\tdouble nu;\t/* for NU_SVC, ONE_CLASS, and NU_SVR */\n\t\tdouble p;\t/* for EPSILON_SVR */\n\t\tint shrinking;\t/* use the shrinking heuristics */\n\t\tint probability; /* do probability estimates */\n\t};\n\n    svm_type can be one of C_SVC, NU_SVC, ONE_CLASS, EPSILON_SVR, NU_SVR.\n\n    C_SVC:\t\tC-SVM classification\n    NU_SVC:\t\tnu-SVM classification\n    ONE_CLASS:\t\tone-class-SVM\n    EPSILON_SVR:\tepsilon-SVM regression\n    NU_SVR:\t\tnu-SVM regression\n\n    kernel_type can be one of LINEAR, POLY, RBF, SIGMOID.\n\n    LINEAR:\tu'*v\n    POLY:\t(gamma*u'*v + coef0)^degree\n    RBF:\texp(-gamma*|u-v|^2)\n    SIGMOID:\ttanh(gamma*u'*v + coef0)\n    PRECOMPUTED: kernel values in training_set_file\n\n    cache_size is the size of the kernel cache, specified in megabytes.\n    C is the cost of constraints violation.\n    eps is the stopping criterion. (we usually use 0.00001 in nu-SVC,\n    0.001 in others). nu is the parameter in nu-SVM, nu-SVR, and\n    one-class-SVM. p is the epsilon in epsilon-insensitive loss function\n    of epsilon-SVM regression. shrinking = 1 means shrinking is conducted;\n    = 0 otherwise. probability = 1 means model with probability\n    information is obtained; = 0 otherwise.\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    *NOTE* Because svm_model contains pointers to svm_problem, you can\n    not free the memory used by svm_problem if you are still using the\n    svm_model produced by svm_train().\n\n    *NOTE* To avoid wrong parameters, svm_check_parameter() should be\n    called before svm_train().\n\n    struct svm_model stores the model obtained from the training procedure.\n    It is not recommended to directly access entries in this structure.\n    Programmers should use the interface functions to get the values.\n\n\tstruct svm_model\n\t{\n\t\tstruct svm_parameter param;\t/* parameter */\n\t\tint nr_class;\t\t/* number of classes, = 2 in regression/one class svm */\n\t\tint l;\t\t\t/* total #SV */\n\t\tstruct svm_node **SV;\t\t/* SVs (SV[l]) */\n\t\tdouble **sv_coef;\t/* coefficients for SVs in decision functions (sv_coef[k-1][l]) */\n\t\tdouble *rho;\t\t/* constants in decision functions (rho[k*(k-1)/2]) */\n\t\tdouble *probA;\t\t/* pairwise probability information */\n\t\tdouble *probB;\n\t\tdouble *prob_density_marks;\t/*probability information for ONE_CLASS*/\n\t\tint *sv_indices;        /* sv_indices[0,...,nSV-1] are values in [1,...,num_traning_data] to indicate SVs in the training set */\n\n\t\t/* for classification only */\n\n\t\tint *label;\t\t/* label of each class (label[k]) */\n\t\tint *nSV;\t\t/* number of SVs for each class (nSV[k]) */\n\t\t\t\t\t/* nSV[0] + nSV[1] + ... + nSV[k-1] = l */\n\t\t/* XXX */\n\t\tint free_sv;\t\t/* 1 if svm_model is created by svm_load_model*/\n\t\t\t\t\t/* 0 if svm_model is created by svm_train */\n\t};\n\n    param describes the parameters used to obtain the model.\n\n    nr_class is the number of classes for classification. It is a\n    non-negative integer with special cases of 0 (no training data at\n    all) and 1 (all training data in one class). For regression and\n    one-class SVM, nr_class = 2.\n\n    l is the number of support vectors. SV and sv_coef are support\n    vectors and the corresponding coefficients, respectively. Assume there are\n    k classes. For data in class j, the corresponding sv_coef includes (k-1) y*alpha vectors,\n    where alpha's are solutions of the following two class problems:\n    1 vs j, 2 vs j, ..., j-1 vs j, j vs j+1, j vs j+2, ..., j vs k\n    and y=1 for the first j-1 vectors, while y=-1 for the remaining k-j\n    vectors. For example, if there are 4 classes, sv_coef and SV are like:\n\n        +-+-+-+--------------------+\n        |1|1|1|                    |\n        |v|v|v|  SVs from class 1  |\n        |2|3|4|                    |\n        +-+-+-+--------------------+\n        |1|2|2|                    |\n        |v|v|v|  SVs from class 2  |\n        |2|3|4|                    |\n        +-+-+-+--------------------+\n        |1|2|3|                    |\n        |v|v|v|  SVs from class 3  |\n        |3|3|4|                    |\n        +-+-+-+--------------------+\n        |1|2|3|                    |\n        |v|v|v|  SVs from class 4  |\n        |4|4|4|                    |\n        +-+-+-+--------------------+\n\n    See svm_train() for an example of assigning values to sv_coef.\n\n    rho is the bias term (-b). probA and probB are parameters used in\n    probability outputs. If there are k classes, there are k*(k-1)/2\n    binary problems as well as rho, probA, and probB values. They are\n    aligned in the order of binary problems:\n    1 vs 2, 1 vs 3, ..., 1 vs k, 2 vs 3, ..., 2 vs k, ..., k-1 vs k.\n\n    sv_indices[0,...,nSV-1] are values in [1,...,num_traning_data] to\n    indicate support vectors in the training set.\n\n    label contains labels in the training data.\n\n    nSV is the number of support vectors in each class.\n\n    free_sv is a flag used to determine whether the space of SV should\n    be released in free_model_content(struct svm_model*) and\n    free_and_destroy_model(struct svm_model**). If the model is\n    generated by svm_train(), then SV points to data in svm_problem\n    and should not be removed. For example, free_sv is 0 if svm_model\n    is created by svm_train, but is 1 if created by svm_load_model.\n\n- Function: double svm_predict(const struct svm_model *model,\n                               const struct svm_node *x);\n\n    This function does classification or regression on a test vector x\n    given a model.\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. For an one-class model, +1 or -1 is\n    returned.\n\n- Function: void svm_cross_validation(const struct svm_problem *prob,\n\tconst struct svm_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 (of all prob's instances) in the validation process are\n    stored in the array called target.\n\n    The format of svm_prob is same as that for svm_train().\n\n- Function: int svm_get_svm_type(const struct svm_model *model);\n\n    This function gives svm_type of the model. Possible values of\n    svm_type are defined in svm.h.\n\n- Function: int svm_get_nr_class(const svm_model *model);\n\n    For a classification model, this function gives the number of\n    classes. For a regression or an one-class model, 2 is returned.\n\n- Function: void svm_get_labels(const svm_model *model, int* label)\n\n    For a classification model, this function outputs the name of\n    labels into an array called label. For regression and one-class\n    models, label is unchanged.\n\n- Function: void svm_get_sv_indices(const struct svm_model *model, int *sv_indices)\n\n    This function outputs indices of support vectors into an array called sv_indices.\n    The size of sv_indices is the number of support vectors and can be obtained by calling svm_get_nr_sv.\n    Each sv_indices[i] is in the range of [1, ..., num_traning_data].\n\n- Function: int svm_get_nr_sv(const struct svm_model *model)\n\n    This function gives the number of total support vector.\n\n- Function: double svm_get_svr_probability(const struct svm_model *model);\n\n    For a regression model with probability information, this function\n    outputs a value sigma \u003e 0. For test data, we consider the\n    probability model: target value = predicted value + z, z: Laplace\n    distribution e^(-|z|/sigma)/(2sigma)\n\n    If the model is not for svr or does not contain required\n    information, 0 is returned.\n\n- Function: double svm_predict_values(const svm_model *model,\n\t\t\t\t    const svm_node *x, double* dec_values)\n\n    This function gives decision values on a test vector x given a\n    model, and return the predicted label (classification) or\n    the function value (regression).\n\n    For a classification model with nr_class classes, this function\n    gives nr_class*(nr_class-1)/2 decision values in the array\n    dec_values, where nr_class can be obtained from the function\n    svm_get_nr_class. The order is label[0] vs. label[1], ...,\n    label[0] vs. label[nr_class-1], label[1] vs. label[2], ...,\n    label[nr_class-2] vs. label[nr_class-1], where label can be\n    obtained from the function svm_get_labels. The returned value is\n    the predicted class for x. Note that when nr_class = 1, this\n    function does not give any decision value.\n\n    For a regression model, dec_values[0] and the returned value are\n    both the function value of x calculated using the model. For a\n    one-class model, dec_values[0] is the decision value of x, while\n    the returned value is +1/-1.\n\n- Function: double svm_predict_probability(const struct svm_model *model,\n\t    const struct svm_node *x, double* prob_estimates);\n\n    This function does classification or regression on a test vector x\n    given a model with probability information.\n\n    For a classification model with probability information, this\n    function gives nr_class probability estimates in the array\n    prob_estimates. nr_class can be obtained from the function\n    svm_get_nr_class. The class with the highest probability is\n    returned. For one-class SVM, the array prob_estimates contains\n    two elements for probabilities of normal instance/outlier,\n    while for regression, the array is unchanged. For both one-class\n    SVM and regression, the returned value is the same as that of\n    svm_predict.\n\n- Function: const char *svm_check_parameter(const struct svm_problem *prob,\n                                            const struct svm_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    svm_train() and svm_cross_validation(). It returns NULL if the\n    parameters are feasible, otherwise an error message is returned.\n\n- Function: int svm_check_probability_model(const struct svm_model *model);\n\n    This function checks whether the model contains required\n    information to do probability estimates. If so, it returns\n    +1. Otherwise, 0 is returned. This function should be called\n    before calling svm_get_svr_probability and\n    svm_predict_probability.\n\n- Function: int svm_save_model(const char *model_file_name,\n\t\t\t       const struct svm_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 svm_model *svm_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 svm_free_model_content(struct svm_model *model_ptr);\n\n    This function frees the memory used by the entries in a model structure.\n\n- Function: void svm_free_and_destroy_model(struct svm_model **model_ptr_ptr);\n\n    This function frees the memory used by a model and destroys the model\n    structure. It is equivalent to svm_destroy_model, which\n    is deprecated after version 3.0.\n\n- Function: void svm_destroy_param(struct svm_parameter *param);\n\n    This function frees the memory used by a parameter set.\n\n- Function: void svm_set_print_string_function(void (*print_func)(const char *));\n\n    Users can specify their output format by a function. Use\n        svm_set_print_string_function(NULL);\n    for default printing to stdout.\n\n    Please note that this function is not thread-safe. When multiple threads load or\n    use the same dynamic library (for example, libsvm.so.4), they actually share the\n    same memory space of the dynamic library, which results in all threads modifying\n    the same static function pointer, svm_print_string, in svm.cpp when they call this\n    function.\n\n    For example, suppose we have threads A and B. They call this function sequentially\n    and pass their own thread-local print_func into it. After that, they both call (*svm_print_string)(str)\n    once. When the last thread finishes setting it (say B), svm_print_string is set to\n    B.print_func. Now, if thread A wants to access svm_print_string, it is actually\n    accessing B.print_func rather than A.print_func, which is incorrect since we expect\n    to use the functionality of A.print_func.\n\n    Even if A.print_func and B.print_func have identical functionality, it is still risky.\n    Suppose svm_print_string is now set to B.print_func, and B deletes B.print_func after\n    finishing its work. Later, thread A calls svm_print_string, but the address points to,\n    which is B.print_func, has already been deleted. This invalid memory access will crash\n    the program. To mitigate this issue, in this example, you should ensure that A.print_func\n    and B.print_func remain valid after threads finish their work. For example, in Python,\n    you can assign them as global variables.\n\nJava Version\n============\n\nThe pre-compiled java class archive `libsvm.jar' and its source files are\nin the java directory. To run the programs, use\n\njava -classpath libsvm.jar svm_train \u003carguments\u003e\njava -classpath libsvm.jar svm_predict \u003carguments\u003e\njava -classpath libsvm.jar svm_toy\njava -classpath libsvm.jar svm_scale \u003carguments\u003e\n\nNote that you need Java 1.5 (5.0) or above to run it.\n\nYou may need to add Java runtime library (like classes.zip) to the classpath.\nYou may need to increase maximum Java heap size.\n\nLibrary usages are similar to the C version. These functions are available:\n\npublic class svm {\n\tpublic static final int LIBSVM_VERSION=336;\n\tpublic static svm_model svm_train(svm_problem prob, svm_parameter param);\n\tpublic static void svm_cross_validation(svm_problem prob, svm_parameter param, int nr_fold, double[] target);\n\tpublic static int svm_get_svm_type(svm_model model);\n\tpublic static int svm_get_nr_class(svm_model model);\n\tpublic static void svm_get_labels(svm_model model, int[] label);\n\tpublic static void svm_get_sv_indices(svm_model model, int[] indices);\n\tpublic static int svm_get_nr_sv(svm_model model);\n\tpublic static double svm_get_svr_probability(svm_model model);\n\tpublic static double svm_predict_values(svm_model model, svm_node[] x, double[] dec_values);\n\tpublic static double svm_predict(svm_model model, svm_node[] x);\n\tpublic static double svm_predict_probability(svm_model model, svm_node[] x, double[] prob_estimates);\n\tpublic static void svm_save_model(String model_file_name, svm_model model) throws IOException\n\tpublic static svm_model svm_load_model(String model_file_name) throws IOException\n\tpublic static String svm_check_parameter(svm_problem prob, svm_parameter param);\n\tpublic static int svm_check_probability_model(svm_model model);\n\tpublic static void svm_set_print_string_function(svm_print_interface print_func);\n}\n\nThe library is in the \"libsvm\" package.\nNote that in Java version, svm_node[] is not ended with a node whose index = -1.\n\nUsers can specify their output format by\n\n\tyour_print_func = new svm_print_interface()\n\t{\n\t\tpublic void print(String s)\n\t\t{\n\t\t\t// your own format\n\t\t}\n\t};\n\tsvm.svm_set_print_string_function(your_print_func);\n\nHowever, similar to the C version, it is not thread-safe. Please check the\nusage of C version svm_set_print_string_function() for details.\n\nBuilding Windows Binaries\n=========================\n\nWindows binaries are available in the directory `windows'. To re-build\nthem via Visual C++, use the following steps:\n\n1. Open a DOS command box (or Visual Studio Command Prompt) and change\nto libsvm directory. If environment variables of VC++ have not been\nset, type\n\n\"C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Auxiliary\\Build\\vcvars64.bat\"\n\nYou may have to modify the above command according which version of\nVC++ or where it is installed.\n\n2. Type\n\nnmake -f Makefile.win clean all\n\n3. (optional) To build shared library libsvm.dll, type\n\nnmake -f Makefile.win lib\n\n4. (optional) To build 32-bit windows binaries, you must\n\t(1) Setup \"C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Auxiliary\\Build\\vcvars32.bat\" instead of vcvars64.bat\n\t(2) Change CFLAGS in Makefile.win: /D _WIN64 to /D _WIN32\n\nAnother way is to build them from Visual C++ environment. See details\nin libsvm FAQ.\n\n- Additional Tools: Sub-sampling, Parameter Selection, Format checking, etc.\n============================================================================\n\nSee the README file in the tools directory.\n\nMATLAB/OCTAVE Interface\n=======================\n\nPlease check the file README in the directory `matlab'.\n\nPython Interface\n================\n\nSee the README file in python directory.\n\nAdditional Information\n======================\n\nIf you find LIBSVM helpful, please cite it as\n\nChih-Chung Chang and Chih-Jen Lin, LIBSVM : a library for support\nvector machines. ACM Transactions on Intelligent Systems and\nTechnology, 2:27:1--27:27, 2011. Software available at\nhttp://www.csie.ntu.edu.tw/~cjlin/libsvm\n\nLIBSVM implementation document is available at\nhttp://www.csie.ntu.edu.tw/~cjlin/papers/libsvm.pdf\n\nFor any questions and comments, please email cjlin@csie.ntu.edu.tw\n\nAcknowledgments:\nThis work was supported in part by the National Science\nCouncil of Taiwan via the grant NSC 89-2213-E-002-013.\nThe authors thank their group members and users\nfor many helpful discussions and comments. They are listed in\nhttp://www.csie.ntu.edu.tw/~cjlin/libsvm/acknowledgements\n\n","funding_links":[],"categories":["Machine Learning","进程间通信","II. Databases, search engines, big data and machine learning","Uncategorized","人工智能"],"sub_categories":["机器学习","8. Machine Learning","Uncategorized"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcjlin1%2Flibsvm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcjlin1%2Flibsvm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcjlin1%2Flibsvm/lists"}