{"id":15057202,"url":"https://github.com/hanb16/mkloneclasssvm.jl","last_synced_at":"2026-02-16T02:09:51.838Z","repository":{"id":242674144,"uuid":"809846121","full_name":"hanb16/MKLOneClassSVM.jl","owner":"hanb16","description":"A Julia package for multiple kernel learning based one-class support vector machine.","archived":false,"fork":false,"pushed_at":"2024-12-24T09:02:15.000Z","size":361,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-09-05T22:50:17.125Z","etag":null,"topics":["julia","machine-learning","optimization"],"latest_commit_sha":null,"homepage":"","language":"Julia","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hanb16.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"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,"zenodo":null}},"created_at":"2024-06-03T15:00:12.000Z","updated_at":"2025-02-19T14:58:40.000Z","dependencies_parsed_at":"2025-05-06T16:04:33.918Z","dependency_job_id":"b0f4618f-4b8e-46ab-831a-846a00139515","html_url":"https://github.com/hanb16/MKLOneClassSVM.jl","commit_stats":null,"previous_names":["hanb16/mklocsvm.jl","hanb16/mkloneclasssvm.jl"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/hanb16/MKLOneClassSVM.jl","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hanb16%2FMKLOneClassSVM.jl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hanb16%2FMKLOneClassSVM.jl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hanb16%2FMKLOneClassSVM.jl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hanb16%2FMKLOneClassSVM.jl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hanb16","download_url":"https://codeload.github.com/hanb16/MKLOneClassSVM.jl/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hanb16%2FMKLOneClassSVM.jl/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279001299,"owners_count":26083059,"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-09T02:00:07.460Z","response_time":59,"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":["julia","machine-learning","optimization"],"created_at":"2024-09-24T22:03:51.729Z","updated_at":"2025-10-09T11:41:37.745Z","avatar_url":"https://github.com/hanb16.png","language":"Julia","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MKLOneClassSVM.jl\n`MKLOneClassSVM.jl` is a Julia package for multiple kernel learning (MKL) based one-class support vector machine (OneClassSVM). \n\n\n## Usage\n\n### Installation\n``` julia\nusing Pkg\nPkg.add(\"MKLOneClassSVM\")\nPkg.add(\"GLMakie\") # if the user wants visualization\n```\n\n### Using pacakges\n``` julia\nusing MKLOneClassSVM\nusing GLMakie\n```\n\n### Data loading\nNote that each column of the training data corresponds to an observation of the input features.\n``` julia\nu1 = 0.5 .+ 4 * rand(300)\nu2 = 2 ./ u1 + 0.3 * randn(300)\nX = [u1'; u2']\nmklocsvmplot(X; backend=GLMakie)\n```\n\n\u003cp align=center\u003e\n  \u003cimg src=\"/assets/data.png\" width=70%\u003e\n\u003c/p\u003e\n\n### Creating candidate basis kernels\nThis package reexports [`KernelFunctions.jl`](https://github.com/JuliaGaussianProcesses/KernelFunctions.jl.git), which allows the user to generate various basis kernels conveniently:\n\n``` julia\nKernels = [\n    CosineKernel(),\n    ExponentialKernel(),\n    GammaExponentialKernel(), \n    gaborkernel(),\n    MaternKernel(),\n    Matern32Kernel(),\n    PiecewisePolynomialKernel(; dim=2, degree=2),\n    RationalKernel(),\n    RationalQuadraticKernel(),\n    GammaRationalKernel(),\n    GaussianKernel(),\n    RBFKernel(),\n    gaborkernel()\n]\n```\n\n### Multiple kernel learning\nThe user can chose different algorithms to train the MKL model, e.g., `QCQP()` to solve the dual problem directly (which is a quadratically constrained quadratic program) or `HessianMKL()` to alternately optimize the kernel coefficients according to the second order information and solve a standard single kernel OCSVM. Here we choose the latter algorithm:\n``` julia\n# algor = QCQP(verbose=false)\nalgor = HessianMKL(verbose=false)\nmodel = mklocsvmtrain(Kernels, X; algorithm=algor, ν=0.01, μ=0.5);\n```\n\nPlease see the [paper](https://doi.org/10.1016/j.ejor.2020.11.027) for more information about the algorithms and the statistical meaning of the hyper-parameters.\n\n### Visualization of the model\n\n``` julia\nmklocsvmplot(model; backend=GLMakie)\n```\n\n\u003cp align=center\u003e\n  \u003cimg src=\"/assets/result.png\" width=70%\u003e\n\u003c/p\u003e\n\nMore information about the trained model can be retrieved by querying corresponding fields of `model`, e.g.,\n``` julia\nmodel.SV # the indeces of all support vectors\nmodel.SK # the indeces of all support kernels\n```\n\n### Prediction\n\n``` julia\nu1 = 0.5 .+ 4 * rand(10)\nu2 = 2 ./ u1 + 0.3 * randn(10)\nX_test = [u1'; u2']\nmklocsvmpredict(model, X_test)\n```\n\nThe decision function, if needed, can be obtained by\n``` julia\ny = decision_function(model)\ny(X_test)\n```\n\n### Other utilities\n\n#### To train the model distributedly\nWhen there are lots of candidate basis kernels, sometimes it may be a beter practice to group the kernels into batches first, then train them distributedly and finally take the intersection of all trained models as the resulting decision set.\n\n``` julia\nusing Distributed\naddprocs(5)\n@everywhere using MKLOneClassSVM\nusing GLMakie\n\nnum_batch = 3\nKernels_inbat = group_kernels(Kernels, num_batch; mode=\"randomly\")\nmodel = pmap(\n    ks -\u003e mklocsvmtrain(ks, X; algorithm=algor, ν=0.01/num_batch, μ=0.5), \n    Kernels_inbat\n)\nmklocsvmplot(model; backend=GLMakie)\n```\n\n\u003cp align=center\u003e\n  \u003cimg src=\"/assets/result_dis.png\" width=70%\u003e\n\u003c/p\u003e\n\n\n#### To construct a convex polyhedral set\nBy utilizting the Directional Projection Distance Kernel (DPDK) presented in the [paper](https://doi.org/10.1016/j.ejor.2020.11.027) or a new Directional Nullspace Projection Norm Kernel (DNPNK), the user will be able to construct a convex polytopic set. The corresponding functionalities have been integrated into the `mklocsvmtrain` function. \n\n``` julia\nmodel = mklocsvmtrain(X, 50; kernel=\"DPDK\", algorithm=algor, q_mode=\"randomly\", ν=0.01, μ=0.05)\nmklocsvmplot(model; backend=GLMakie)\n```\n\u003cp align=center\u003e\n  \u003cimg src=\"/assets/DPDK.png\" width=70%\u003e\n\u003c/p\u003e\n\nThis is also allowed to train distributedly for acceleration under some situations:\n``` julia\nmodel = mklocsvmtrain(X, 50; kernel=\"DPDK\", algorithm=algor, q_mode=\"randomly\", ν=0.01, μ=0.05, num_batch=5)\nmklocsvmplot(model; backend=GLMakie)\n```\n\u003cp align=center\u003e\n  \u003cimg src=\"/assets/DPDK_dis.png\" width=70%\u003e\n\u003c/p\u003e\n\nThe model can be converted into other types for further usage:\n``` julia\nconvert_to_jumpmodel(model; form=\"linear\", varname=:u)\nconvert_to_polyhedron(model; eliminated=true)\n```\n\n## Citing\nIf you use `MKLOneClassSVM.jl`, we ask that you please cite this [repository](https://github.com/hanb16/MKLOneClassSVM.jl.git) and the following [paper](https://doi.org/10.1016/j.ejor.2020.11.027):\n``` bibtex\n@article{han2021multiple,\n  title={Multiple kernel learning-aided robust optimization: Learning algorithm, computational tractability, and usage in multi-stage decision-making},\n  author={Han, Biao and Shang, Chao and Huang, Dexian},\n  journal={European Journal of Operational Research},\n  volume={292},\n  number={3},\n  pages={1004--1018},\n  year={2021},\n  publisher={Elsevier}\n}\n```\n\n## Acknowledgments\nBy default, this package implicitly uses [`KernelFunctions.jl`](https://github.com/JuliaGaussianProcesses/KernelFunctions.jl.git), open source solvers [`HiGHS.jl`](https://github.com/jump-dev/HiGHS.jl.git) and [`Ipopt.jl`](https://github.com/jump-dev/Ipopt.jl.git), and the single kernel SVM solver [`LIBSVM.jl`](https://github.com/JuliaML/LIBSVM.jl.git). Thanks for these useful packages, although the user is also allowed to replace them with other alternatives.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhanb16%2Fmkloneclasssvm.jl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhanb16%2Fmkloneclasssvm.jl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhanb16%2Fmkloneclasssvm.jl/lists"}