{"id":37122024,"url":"https://github.com/iqiukp/svdd-matlab","last_synced_at":"2026-01-14T14:03:50.900Z","repository":{"id":201864816,"uuid":"155737808","full_name":"iqiukp/SVDD-MATLAB","owner":"iqiukp","description":"MATLAB Code for abnormal detection using Support Vector Data Description (SVDD).","archived":false,"fork":false,"pushed_at":"2022-05-12T18:08:04.000Z","size":9409,"stargazers_count":79,"open_issues_count":1,"forks_count":23,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-22T11:28:18.668Z","etag":null,"topics":["abnormal-detection","fault-detection","matlab","svdd"],"latest_commit_sha":null,"homepage":"","language":"MATLAB","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/iqiukp.png","metadata":{"files":{"readme":"README.md","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}},"created_at":"2018-11-01T15:41:08.000Z","updated_at":"2025-05-19T05:20:43.000Z","dependencies_parsed_at":null,"dependency_job_id":"41756ee9-8c30-4a73-a223-301586a0314a","html_url":"https://github.com/iqiukp/SVDD-MATLAB","commit_stats":null,"previous_names":["iqiukp/svdd-matlab"],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/iqiukp/SVDD-MATLAB","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iqiukp%2FSVDD-MATLAB","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iqiukp%2FSVDD-MATLAB/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iqiukp%2FSVDD-MATLAB/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iqiukp%2FSVDD-MATLAB/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iqiukp","download_url":"https://codeload.github.com/iqiukp/SVDD-MATLAB/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iqiukp%2FSVDD-MATLAB/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28422404,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T13:30:50.153Z","status":"ssl_error","status_checked_at":"2026-01-14T13:29:08.907Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["abnormal-detection","fault-detection","matlab","svdd"],"created_at":"2026-01-14T14:03:50.159Z","updated_at":"2026-01-14T14:03:50.892Z","avatar_url":"https://github.com/iqiukp.png","language":"MATLAB","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003cimg src=\"http://github-files-qiu.oss-cn-beijing.aliyuncs.com/SVDD-MATLAB/demo_.png\"\u003e\n\u003c/p\u003e\n\n\u003ch3 align=\"center\"\u003eSupport Vector Data Description (SVDD)\u003c/h3\u003e\n\n\u003cp align=\"center\"\u003eMATLAB Code for abnormal detection using SVDD\u003c/p\u003e\n\u003cp align=\"center\"\u003eVersion 2.2, 13-MAY-2022\u003c/p\u003e\n\u003cp align=\"center\"\u003eEmail: iqiukp@outlook.com\u003c/p\u003e\n\n\u003cdiv align=center\u003e\n\n[![View Support Vector Data Description (SVDD) on File Exchange](https://www.mathworks.com/matlabcentral/images/matlab-file-exchange.svg)](https://ww2.mathworks.cn/matlabcentral/fileexchange/69296-support-vector-data-description-svdd)\n\u003cimg src=\"https://img.shields.io/github/v/release/iqiukp/Support-Vector-Data-Description-SVDD?label=version\" /\u003e\n\u003cimg src=\"https://img.shields.io/github/repo-size/iqiukp/Support-Vector-Data-Description-SVDD\" /\u003e\n\u003cimg src=\"https://img.shields.io/github/languages/code-size/iqiukp/Support-Vector-Data-Description-SVDD\" /\u003e\n\u003cimg src=\"https://img.shields.io/github/languages/top/iqiukp/Support-Vector-Data-Description-SVDD\" /\u003e\n\u003cimg src=\"https://img.shields.io/github/stars/iqiukp/Support-Vector-Data-Description-SVDD\" /\u003e\n\u003cimg src=\"https://img.shields.io/github/forks/iqiukp/Support-Vector-Data-Description-SVDD\" /\u003e\n\u003c/div\u003e\n\n\u003chr /\u003e\n\n## ✨ MAIN FEATURES\n- SVDD model for one-class or binary classification\n- Multiple kinds of kernel functions (linear, gaussian, polynomial, sigmoid, laplacian)\n- Visualization of decision boundaries for 2D or 3D data\n- Parameter optimization using Bayesian optimization, genetic algorithm, and pParticle swarm optimization\n- Weighted SVDD model\n- Hybrid-kernel SVDD model (K =w1×K1+w2×K2+...+wn×Kn)\n\n## ⚠️ NOTICES\n- This version of this code is not compatible with the versions lower than ***R2016b***.\n- The label must be 1 for positive sample or -1 for negative sample. \n- Detailed applications please see the provided ***demonstrations***.\n- This code is for reference only.\n\n## 🔨 HOW TO USE\n\n### 👉 A simple SVDD model\nPlease see the demonstration [`📝 demo_BasicSVDD.m`](https://github.com/iqiukp/SVDD-MATLAB/blob/master/demo_BasicSVDD.m) for details.\n```MATLAB\n% generate dataset\nocdata = BinaryDataset();\nocdata.generate;\n[trainData, trainLabel, testData, testLabel] = ocdata.partition;\n\n% set parameter\nkernel = BaseKernel('type', 'gaussian', 'gamma', 0.04);\ncost = 0.3;\nsvddParameter = struct('cost', cost,...\n                       'kernelFunc', kernel);\n\n% creat an SVDD object\nsvdd = BaseSVDD(svddParameter);\n% train SVDD model\nsvdd.train(trainData, trainLabel);\n% test SVDD model\nresults = svdd.test(testData, testLabel);\n```\n- `BinaryDataset` is designed to validate the svdd model only, you can use your data and please be careful to keep the naming of variables consistent, e.g. `trainData`, `trainLabel`, `testData`, and `testLabel`.  \n- Specifically, if the data does not have labels, please change the inputs for training or testing to `svdd.train(trainData)` and `results = svdd.test(testData)`.\n\n### 👉 Parameter Optimization for SVDD model\nA class named `SvddOptimization` is defined to optimized the parameters. First define an optimization setting structure, then add it to the svdd parameter structure.The parameter optimization of the polynomial kernel function can only be achieved by using Bayesian optimization.  \nPlease see the demonstration [`📝 demo_ParameterOptimization.m`](https://github.com/iqiukp/SVDD-MATLAB/blob/master/demo_ParameterOptimization.m) for details.\n```MATLAB\n% optimization setting \noptimization.method = 'bayes'; % \noptimization.maxIteration = 20;\noptimization.display = 'on';\n% SVDD parameter\nsvddParameter = struct('cost', cost,...\n                       'kernelFunc', kernel,...\n                       'optimization', optimization);\n```\nThe full properties of optimization are\n- `method`: optimization methods,  only supported for 'bayes', 'pso', and 'ga'.\n- `variableName`: variables that are to be optimized, including 'cost', 'degree', 'offset', and 'gamma'.\n- `variableType`: variable type, specified as 'real' (real variable), 'integer' (integer variable).\n- `lowerBound`:  lower bound of variables.\n- `upperBound`:  upper bound of variables.\n- `maxIteration`: max iterations.\n- `points`: size of group or seed.\n- `display `: visualization, 'on' or 'off'.\n\n### 👉 Visualization of SVDD model\nA class named `SvddVisualization` is defined to visualize the training and test results. Based on the trained SVDD model, the ROC curve of the training results (only supported for dataset containing both positive and negetive samples) is\n```MATLAB\n% Visualization \nsvplot = SvddVisualization();\nsvplot.ROC(svdd);\n```\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"http://github-files-qiu.oss-cn-beijing.aliyuncs.com/SVDD-MATLAB/ROC-3D_.png\"\u003e\n\u003c/p\u003e\n\nThe decision boundaries (only supported for 2D/3D dataset) are\n```MATLAB\n% Visualization \nsvplot = SvddVisualization();\nsvplot.boundary(svdd);\n```\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"http://github-files-qiu.oss-cn-beijing.aliyuncs.com/SVDD-MATLAB/boundary-2D_.png\"\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://github-files-qiu.oss-cn-beijing.aliyuncs.com/SVDD-MATLAB/boundary-3D_.png\"\u003e\n\u003c/p\u003e\n\nThe distance between the test data and the hypersphere is\n```MATLAB\nsvplot.distance(svdd, results);\n```\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"http://github-files-qiu.oss-cn-beijing.aliyuncs.com/SVDD-MATLAB/distance-3D_.png\"\u003e\n\u003c/p\u003e\n\n### 👉 Binary Dataset for SVDD model\nA class named `BinaryDataset` is defined to generate and partition the 2D or 3D binary dataset.  \nPlease see the demonstration [`📝demo_BinaryDataset.m`](https://github.com/iqiukp/SVDD-MATLAB/blob/master/demo_BinaryDataset.m) for details. \n```MATLAB\nocdata = BinaryDataset();\n[data, label] = ocdata.generate;\n[trainData, trainLabel, testData, testLabel] = ocdata.partition;\n```\nThe  method `generate` is designed to generate dataset. The syntax of  `generate` is\n```MATLAB\nocdata.generate;\ndata = ocdata.generate;\n[data, label] = ocdata.generate;\n```\nThe  method `partition` is designed to partition dataset into training dataset and test dataset. The syntax of  `partition` is\n```MATLAB\n[trainData, trainLabel, testData, testLabel] = ocdata.partition;\n```\nThe full Name-Value Arguments of class `BinaryDataset` are\n- `shape`: shape of dataset, 'banana' or 'circle'.\n- `dimensionality`: dimensionality of dataset, 2 or 3.\n- `number`: number of samples per class, for example: [200, 200].\n- `display`:  visualization, 'on' or 'off'.\n- `noise`:  noise added to dataset with range [0, 1]. For example: 0.2.\n- `ratio`: ratio of the test set with range (0, 1). For example: 0.3.\n\n### 👉 Kernel funcions\nA class named `BaseKernel` is defined to compute kernel function matrix.  \nPlease see the demonstration [`📝demo_KernelFunction.m`](https://github.com/iqiukp/SVDD-MATLAB/blob/master/demo_KernelFunction.m) for details.\n```MATLAB\n%{\n        type   -\n        \n        linear      :  k(x,y) = x'*y\n        polynomial  :  k(x,y) = (γ*x'*y+c)^d\n        gaussian    :  k(x,y) = exp(-γ*||x-y||^2)\n        sigmoid     :  k(x,y) = tanh(γ*x'*y+c)\n        laplacian   :  k(x,y) = exp(-γ*||x-y||)\n    \n    \n        degree -  d\n        offset -  c\n        gamma  -  γ\n%}\nkernel = BaseKernel('type', 'gaussian', 'gamma', value);\nkernel = BaseKernel('type', 'polynomial', 'degree', value);\nkernel = BaseKernel('type', 'linear');\nkernel = BaseKernel('type', 'sigmoid', 'gamma', value);\nkernel = BaseKernel('type', 'laplacian', 'gamma', value);\n```\n### 👉 Cross Validation\nIn this code, two cross-validation methods are supported: 'K-Folds' and 'Holdout'. For example, the cross-validation of 5-Folds is\n```MATLAB\nsvddParameter = struct('cost', cost,...\n                       'kernelFunc', kernel,...\n                       'KFold', 5);\n```\nFor example, the cross-validation of the Holdout method with a ratio of 0.3 is \n```MATLAB\nsvddParameter = struct('cost', cost,...\n                       'kernelFunc', kernel,...\n                       'Holdout', 0.3);\n```\n\n### 👉 Dimensionality reduction using PCA\nFor example, reducing the data to 2 dimensions can be set as\n```MATLAB\n% SVDD parameter\nsvddParameter = struct('cost', cost,...\n                       'kernelFunc', kernel,...\n                       'PCA', 2);\n```\nPlease see the demonstration [`📝demo_demo_DimReduPCA.m`](https://github.com/iqiukp/SVDD-MATLAB/blob/master/demo_DimReduPCA.m) for details.  \n*Notice:* you only need to set PCA in svddParameter, and you don't need to process training data and test data separately. \n\n### 👉 Weighted SVDD\nAn Observation-weighted SVDD is supported in this code.  \nPlease see the demonstration [`📝demo_ObservationWeight.m`](https://github.com/iqiukp/SVDD-MATLAB/blob/master/demo_ObservationWeight.m) for details. \n```MATLAB\nweight = rand(size(trainData, 1), 1);\n% SVDD parameter\nsvddParameter = struct('cost', cost,...\n                       'kernelFunc', kernel,...\n                       'weight', weight);\n```\n*Notice:* the size of 'weigh' should be m×1， where m is the number of training samples.\n\n### 👉 Hybrid-kernel SVDD model\nA demo for SVDD using Hybrid kernel functions (K =w1×K1+w2×K2+...+wn×Kn).  \nPlease see the demonstration [`📝demo_HybridKernelSVDD.m`](https://github.com/iqiukp/SVDD-MATLAB/blob/master/demo_HybridKernelSVDD.m) for details. \n```MATLAB\nkernel_1 = BaseKernel('type', 'gaussian', 'gamma', 1);\nkernel_2 = BaseKernel('type', 'polynomial', 'degree', 3);\nkernelWeight = [0.5, 0.5];\ncost = 0.9;\n\nsvddParameter = struct('cost', cost,...\n                       'kernelFunc', [kernel_1, kernel_2],...\n                       'kernelWeight', kernelWeight);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiqiukp%2Fsvdd-matlab","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fiqiukp%2Fsvdd-matlab","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiqiukp%2Fsvdd-matlab/lists"}