{"id":23080620,"url":"https://github.com/chen0040/java-local-outlier-factor","last_synced_at":"2025-09-13T13:32:19.565Z","repository":{"id":85884398,"uuid":"91698933","full_name":"chen0040/java-local-outlier-factor","owner":"chen0040","description":"Package implements a number local outlier factor algorithms for outlier detection and finding anomalous data","archived":false,"fork":false,"pushed_at":"2017-06-07T00:46:24.000Z","size":120,"stargazers_count":12,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-15T22:50:07.211Z","etag":null,"topics":["anomaly-detection","clustering","local-outlier-factor","outlier-detection","outliers","unsupervised-learning"],"latest_commit_sha":null,"homepage":null,"language":"Java","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/chen0040.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":"2017-05-18T13:49:48.000Z","updated_at":"2025-05-27T08:40:21.000Z","dependencies_parsed_at":null,"dependency_job_id":"3d8809b9-21bc-43df-8488-75ed983a4109","html_url":"https://github.com/chen0040/java-local-outlier-factor","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/chen0040/java-local-outlier-factor","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chen0040%2Fjava-local-outlier-factor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chen0040%2Fjava-local-outlier-factor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chen0040%2Fjava-local-outlier-factor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chen0040%2Fjava-local-outlier-factor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chen0040","download_url":"https://codeload.github.com/chen0040/java-local-outlier-factor/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chen0040%2Fjava-local-outlier-factor/sbom","scorecard":{"id":114132,"data":{"date":"2025-08-11","repo":{"name":"github.com/chen0040/java-local-outlier-factor","commit":"2abd6e250717ba35cef0997cde1c997070e06e19"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.3,"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":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"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":"Dangerous-Workflow","score":-1,"reason":"no workflows found","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/21 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":"Binary-Artifacts","score":9,"reason":"binaries present in source code","details":["Warn: binary detected: .mvn/wrapper/maven-wrapper.jar: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":"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":"Maintained","score":0,"reason":"0 commit(s) and 0 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":"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":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"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":"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: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE: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":"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"}},{"name":"Vulnerabilities","score":5,"reason":"5 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-2qrg-x229-3v8q","Warn: Project is vulnerable to: GHSA-65fg-84f6-3jq3","Warn: Project is vulnerable to: GHSA-f7vh-qwp3-x37m","Warn: Project is vulnerable to: GHSA-fp5r-v3w9-4333","Warn: Project is vulnerable to: GHSA-w9p3-5cr8-m3jj"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-15T22:50:07.773Z","repository_id":85884398,"created_at":"2025-08-15T22:50:07.774Z","updated_at":"2025-08-15T22:50:07.774Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274969301,"owners_count":25383116,"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-09-13T02:00:10.085Z","response_time":70,"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":["anomaly-detection","clustering","local-outlier-factor","outlier-detection","outliers","unsupervised-learning"],"created_at":"2024-12-16T13:15:46.564Z","updated_at":"2025-09-13T13:32:19.552Z","avatar_url":"https://github.com/chen0040.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# java-local-outlier-factor\nPackage implements a number local outlier factor algorithms for outlier detection and finding anomalous data\n\n[![Build Status](https://travis-ci.org/chen0040/java-local-outlier-factor.svg?branch=master)](https://travis-ci.org/chen0040/java-local-outlier-factor) [![Coverage Status](https://coveralls.io/repos/github/chen0040/java-local-outlier-factor/badge.svg?branch=master)](https://coveralls.io/github/chen0040/java-local-outlier-factor?branch=master) \n\n\n# Features\n\n* LOF\n* LDOF (Local Density Outlier Factor)\n* LOCI (Local outlier correlation integral)\n* CBLOF (Cluster-based LOF)\n\n# Install\n\nAdd the following dependency to your POM file:\n\n```xml\n\u003cdependency\u003e\n  \u003cgroupId\u003ecom.github.chen0040\u003c/groupId\u003e\n  \u003cartifactId\u003ejava-local-outlier-factor\u003c/artifactId\u003e\n  \u003cversion\u003e1.0.4\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n\n# Usage\n\nThe anomaly detection algorithms takes data that is prepared and stored in a data frame (Please refers to this [link](https://github.com/chen0040/java-data-frame) on how to create a data frame from file or from scratch)\n\nAll LOF algorithms variants use unsupervised-learning for training.\n\nThe following method trains an algorithm:\n\n```java\nlof.fitAndTransform(dataFrame);\n```\n\nThe following method returns true if the dataRow (which is a row in a data frame) taken in is an outlier:\n\n```java\nboolean isOutlier = lof.isAnomaly(dataRow);\n```\n\n### Local Outlier Factor (LOF)\n\nTo create and train the LOF, run the following code:\n\n```java\nLOF method = new LOF();\nmethod.setMinPtsLB(3);\nmethod.setMinPtsUB(15);\nmethod.setThreshold(0.2);\nDataFrame resultantTrainedData = method.fitAndTransform(trainingData);\nSystem.out.println(resultantTrainedData.head(10));\n```\n\n \nTo test the trained method on new data, run:\n\n```java\nboolean outlier = method.isAnomaly(dataRow);\n```\n\n### Cluster-Based Local Outlier Factor (CBLOF)\n\nThe create and train the LOF, run the following code:\n\n```java\nCBLOF method = new CBLOF();\nDataFrame resultantTrainedData = method.fitAndTransform(trainingData);\nSystem.out.println(resultantTrainedData.head(10));\n```\n \nTo test the trained method on new data, run:\n\n```java\nboolean outlier = method.isAnomaly(dataRow);\n```\n\nThe problem that we will be using as demo as the following anomaly detection problem:\n\n![scki-learn example for one-class](http://scikit-learn.org/stable/_images/sphx_glr_plot_oneclass_001.png)\n\n\n### LOF \n\nBelow is the sample code which illustrates how to use LOF to detect outliers in the above problem:\n\n```java\nDataQuery.DataFrameQueryBuilder schema = DataQuery.blank()\n      .newInput(\"c1\")\n      .newInput(\"c2\")\n      .newOutput(\"anomaly\")\n      .end();\n\nSampler.DataSampleBuilder negativeSampler = new Sampler()\n      .forColumn(\"c1\").generate((name, index) -\u003e randn() * 0.3 + (index % 2 == 0 ? -2 : 2))\n      .forColumn(\"c2\").generate((name, index) -\u003e randn() * 0.3 + (index % 2 == 0 ? -2 : 2))\n      .forColumn(\"anomaly\").generate((name, index) -\u003e 0.0)\n      .end();\n\nSampler.DataSampleBuilder positiveSampler = new Sampler()\n      .forColumn(\"c1\").generate((name, index) -\u003e rand(-4, 4))\n      .forColumn(\"c2\").generate((name, index) -\u003e rand(-4, 4))\n      .forColumn(\"anomaly\").generate((name, index) -\u003e 1.0)\n      .end();\n\nDataFrame data = schema.build();\n\ndata = negativeSampler.sample(data, 20);\ndata = positiveSampler.sample(data, 20);\n\nSystem.out.println(data.head(10));\n\nLOF method = new LOF();\nmethod.setParallel(true);\nmethod.setMinPtsLB(3);\nmethod.setMinPtsUB(10);\nmethod.setThreshold(0.5);\nDataFrame learnedData = method.fitAndTransform(data);\n\nBinaryClassifierEvaluator evaluator = new BinaryClassifierEvaluator();\n\nfor(int i = 0; i \u003c learnedData.rowCount(); ++i){\n boolean predicted = learnedData.row(i).categoricalTarget().equals(\"1\");\n boolean actual = data.row(i).target() == 1.0;\n evaluator.evaluate(actual, predicted);\n logger.info(\"predicted: {}\\texpected: {}\", predicted, actual);\n}\n```\n\n### Cluster-Based LOF \n\nBelow is the sample code which illustrates how to use CBLOF to detect outliers in the above problem:\n\n```java\nDataQuery.DataFrameQueryBuilder schema = DataQuery.blank()\n      .newInput(\"c1\")\n      .newInput(\"c2\")\n      .newOutput(\"anomaly\")\n      .end();\n\nSampler.DataSampleBuilder negativeSampler = new Sampler()\n      .forColumn(\"c1\").generate((name, index) -\u003e randn() * 0.3 + (index % 2 == 0 ? -2 : 2))\n      .forColumn(\"c2\").generate((name, index) -\u003e randn() * 0.3 + (index % 2 == 0 ? -2 : 2))\n      .forColumn(\"anomaly\").generate((name, index) -\u003e 0.0)\n      .end();\n\nSampler.DataSampleBuilder positiveSampler = new Sampler()\n      .forColumn(\"c1\").generate((name, index) -\u003e rand(-4, 4))\n      .forColumn(\"c2\").generate((name, index) -\u003e rand(-4, 4))\n      .forColumn(\"anomaly\").generate((name, index) -\u003e 1.0)\n      .end();\n\nDataFrame data = schema.build();\n\ndata = negativeSampler.sample(data, 200);\ndata = positiveSampler.sample(data, 200);\n\nSystem.out.println(data.head(10));\n\n\nCBLOF method = new CBLOF();\nmethod.setParallel(false);\nDataFrame learnedData = method.fitAndTransform(data);\n\nBinaryClassifierEvaluator evaluator = new BinaryClassifierEvaluator();\n\nfor(int i = 0; i \u003c learnedData.rowCount(); ++i){\n boolean predicted = learnedData.row(i).categoricalTarget().equals(\"1\");\n boolean actual = data.row(i).target() == 1.0;\n evaluator.evaluate(actual, predicted);\n logger.info(\"predicted: {}\\texpected: {}\", predicted, actual);\n}\n\nevaluator.report();\n```\n\n### LDOF\n\nBelow is the sample code which illustrates how to use LDOF to detect outliers in the above problem:\n\n```java\nDataQuery.DataFrameQueryBuilder schema = DataQuery.blank()\n      .newInput(\"c1\")\n      .newInput(\"c2\")\n      .newOutput(\"anomaly\")\n      .end();\n\nSampler.DataSampleBuilder negativeSampler = new Sampler()\n      .forColumn(\"c1\").generate((name, index) -\u003e randn() * 0.3 + (index % 2 == 0 ? -2 : 2))\n      .forColumn(\"c2\").generate((name, index) -\u003e randn() * 0.3 + (index % 2 == 0 ? -2 : 2))\n      .forColumn(\"anomaly\").generate((name, index) -\u003e 0.0)\n      .end();\n\nSampler.DataSampleBuilder positiveSampler = new Sampler()\n      .forColumn(\"c1\").generate((name, index) -\u003e rand(-4, 4))\n      .forColumn(\"c2\").generate((name, index) -\u003e rand(-4, 4))\n      .forColumn(\"anomaly\").generate((name, index) -\u003e 1.0)\n      .end();\n\nDataFrame data = schema.build();\n\ndata = negativeSampler.sample(data, 20);\ndata = positiveSampler.sample(data, 20);\n\nSystem.out.println(data.head(10));\n\nLDOF method = new LDOF();\nDataFrame learnedData = method.fitAndTransform(data);\n\nBinaryClassifierEvaluator evaluator = new BinaryClassifierEvaluator();\nfor(int i = 0; i \u003c learnedData.rowCount(); ++i) {\n boolean predicted = learnedData.row(i).categoricalTarget().equals(\"1\");\n boolean actual = data.row(i).target() == 1.0;\n\n evaluator.evaluate(actual, predicted);\n logger.info(\"predicted: {}\\texpected: {}\", predicted, actual);\n}\n\nevaluator.report();\n```\n\n### LOCI\n\nBelow is the sample code which illustrates how to use LOCI to detect outliers in the above problem:\n\n```java\nDataQuery.DataFrameQueryBuilder schema = DataQuery.blank()\n      .newInput(\"c1\")\n      .newInput(\"c2\")\n      .newOutput(\"anomaly\")\n      .end();\n\nSampler.DataSampleBuilder negativeSampler = new Sampler()\n      .forColumn(\"c1\").generate((name, index) -\u003e randn() * 0.3 + (index % 2 == 0 ? -2 : 2))\n      .forColumn(\"c2\").generate((name, index) -\u003e randn() * 0.3 + (index % 2 == 0 ? -2 : 2))\n      .forColumn(\"anomaly\").generate((name, index) -\u003e 0.0)\n      .end();\n\nSampler.DataSampleBuilder positiveSampler = new Sampler()\n      .forColumn(\"c1\").generate((name, index) -\u003e rand(-4, 4))\n      .forColumn(\"c2\").generate((name, index) -\u003e rand(-4, 4))\n      .forColumn(\"anomaly\").generate((name, index) -\u003e 1.0)\n      .end();\n\nDataFrame data = schema.build();\n\ndata = negativeSampler.sample(data, 20);\ndata = positiveSampler.sample(data, 20);\n\nSystem.out.println(data.head(10));\n\nLOCI method = new LOCI();\nmethod.setAlpha(0.5);\nmethod.setKSigma(3);\nDataFrame learnedData = method.fitAndTransform(data);\n\nBinaryClassifierEvaluator evaluator = new BinaryClassifierEvaluator();\n\nfor(int i = 0; i \u003c learnedData.rowCount(); ++i){\n boolean predicted = learnedData.row(i).categoricalTarget().equals(\"1\");\n boolean actual = data.row(i).target() == 1.0;\n evaluator.evaluate(actual, predicted);\n logger.info(\"predicted: {}\\texpected: {}\", predicted, actual);\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchen0040%2Fjava-local-outlier-factor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchen0040%2Fjava-local-outlier-factor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchen0040%2Fjava-local-outlier-factor/lists"}