{"id":23080613,"url":"https://github.com/chen0040/js-regression","last_synced_at":"2025-10-13T10:32:20.070Z","repository":{"id":57283518,"uuid":"91542364","full_name":"chen0040/js-regression","owner":"chen0040","description":"Package provides javascript implementation of linear regression and logistic regression","archived":false,"fork":false,"pushed_at":"2017-11-23T03:53:05.000Z","size":1536,"stargazers_count":30,"open_issues_count":3,"forks_count":7,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-08-22T05:24:42.171Z","etag":null,"topics":["binary-classification","javascript","linear-regression","linear-regression-models","logistic-regression","mlr","nodejs"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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}},"created_at":"2017-05-17T06:41:45.000Z","updated_at":"2024-12-21T02:08:13.000Z","dependencies_parsed_at":"2022-09-04T20:22:20.900Z","dependency_job_id":null,"html_url":"https://github.com/chen0040/js-regression","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/chen0040/js-regression","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chen0040%2Fjs-regression","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chen0040%2Fjs-regression/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chen0040%2Fjs-regression/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chen0040%2Fjs-regression/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chen0040","download_url":"https://codeload.github.com/chen0040/js-regression/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chen0040%2Fjs-regression/sbom","scorecard":{"id":275934,"data":{"date":"2025-08-11","repo":{"name":"github.com/chen0040/js-regression","commit":"dee8266e5e9cf01d35b9539a99265f67cb90a595"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"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":"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":"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":"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":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"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":"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":"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":"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":"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":"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"}}]},"last_synced_at":"2025-08-17T14:23:35.184Z","repository_id":57283518,"created_at":"2025-08-17T14:23:35.184Z","updated_at":"2025-08-17T14:23:35.184Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279014647,"owners_count":26085555,"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-13T02:00:06.723Z","response_time":61,"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":["binary-classification","javascript","linear-regression","linear-regression-models","logistic-regression","mlr","nodejs"],"created_at":"2024-12-16T13:15:38.608Z","updated_at":"2025-10-13T10:32:20.054Z","avatar_url":"https://github.com/chen0040.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# js-regression\nPackage provides javascript implementation of linear regression and logistic regression\n\n[![Build Status](https://travis-ci.org/chen0040/js-regression.svg?branch=master)](https://travis-ci.org/chen0040/js-regression) [![Coverage Status](https://coveralls.io/repos/github/chen0040/js-regression/badge.svg?branch=master)](https://coveralls.io/github/chen0040/js-regression?branch=master) \n\n# Install\n\n```bash\nnpm install js-regression\n```\n\n# Usage\n\n### Linear Regression\n\nThe sample code below illustrates how to run the multiple linear regression (polynomial in this case):\n\n```javascript\nvar jsregression = require('js-regression');\n\n// === training data generated from y = 2.0 + 5.0 * x + 2.0 * x^2 === //\nvar data = [];\nfor(var x = 1.0; x \u003c 100.0; x += 1.0) {\n  var y = 2.0 + 5.0 * x + 2.0 * x * x + Math.random() * 1.0;\n  data.push([x, x * x, y]); // Note that the last column should be y the output\n}\n\n// === Create the linear regression === //\nvar regression = new jsregression.LinearRegression({\n  alpha: 0.001, // \n  iterations: 300,\n  lambda: 0.0\n});\n// can also use default configuration: var regression = new jsregression.LinearRegression(); \n\n// === Train the linear regression === //\nvar model = regression.fit(data);\n\n// === Print the trained model === //\nconsole.log(model);\n\n\n// === Testing the trained linear regression === //\nvar testingData = [];\nfor(var x = 1.0; x \u003c 100.0; x += 1.0) {\n  var actual_y = 2.0 + 5.0 * x + 2.0 * x * x + Math.random() * 1.0;\n  var predicted_y = regression.transform([x, x * x]);\n  console.log(\"actual: \" + actual_y + \" predicted: \" + predicted_y); \n}\n```\n\n### Logistic Regression\n\nThe sample code below illustrates how to run the logistic regression on the iris datsets to classify whether a data row belong to species Iris-virginica:\n\n```javascript\nvar jsregression = require('js-regression');\nvar iris = require('js-datasets-iris');\n\n// === Create the linear regression === //\nvar logistic = new jsregression.LogisticRegression({\n   alpha: 0.001,\n   iterations: 1000,\n   lambda: 0.0\n});\n// can also use default configuration: var logistic = new jsregression.LogisticRegression(); \n\n// === Create training data and testing data ===//\niris.shuffle();\n\nvar trainingDataSize = Math.round(iris.rowCount * 0.8);\nvar trainingData = [];\nvar testingData = [];\nfor(var i=0; i \u003c iris.rowCount ; ++i) {\n   var row = [];\n   row.push(iris.data[i][0]); // sepalLength;\n   row.push(iris.data[i][1]); // sepalWidth;\n   row.push(iris.data[i][2]); // petalLength;\n   row.push(iris.data[i][3]); // petalWidth;\n   row.push(iris.data[i][4] == \"Iris-virginica\" ? 1.0 : 0.0); // output which is 1 if species is Iris-virginica; 0 otherwise\n   if(i \u003c trainingDataSize) {\n        trainingData.push(row);\n   } else {\n       testingData.push(row);\n   }\n}\n\n\n// === Train the logistic regression === //\nvar model = logistic.fit(trainingData);\n\n// === Print the trained model === //\nconsole.log(model);\n\n// === Testing the trained logistic regression === //\nfor(var i=0; i \u003c testingData.length; ++i){\n   var probabilityOfSpeciesBeingIrisVirginica = logistic.transform(testingData[i]);\n   var predicted = logistic.transform(testingData[i]) \u003e= logistic.threshold ? 1 : 0;\n   console.log(\"actual: \" + testingData[i][4] + \" probability of being Iris-virginica: \" + probabilityOfSpeciesBeingIrisVirginica);\n   console.log(\"actual: \" + testingData[i][4] + \" predicted: \" + predicted);\n}\n\n```\n\n### Multi-Class Classification using One-vs-All Logistic Regression\n\nThe sample code below illustrates how to run the multi-class classifier on the iris datasets to classifiy the species of each data row:\n\n```javascript\nvar classifier = new jsregression.MultiClassLogistic({\n   alpha: 0.001,\n   iterations: 1000,\n   lambda: 0.0\n});\n\niris.shuffle();\n\nvar trainingDataSize = Math.round(iris.rowCount * 0.9);\nvar trainingData = [];\nvar testingData = [];\nfor(var i=0; i \u003c iris.rowCount ; ++i) {\n   var row = [];\n   row.push(iris.data[i][0]); // sepalLength;\n   row.push(iris.data[i][1]); // sepalWidth;\n   row.push(iris.data[i][2]); // petalLength;\n   row.push(iris.data[i][3]); // petalWidth;\n   row.push(iris.data[i][4]); // output is species\n   if(i \u003c trainingDataSize){\n        trainingData.push(row);\n   } else {\n       testingData.push(row);\n   }\n}\n\n\nvar result = classifier.fit(trainingData);\n\nconsole.log(result);\n\nfor(var i=0; i \u003c testingData.length; ++i){\n   var predicted = classifier.transform(testingData[i]);\n   console.log(\"actual: \" + testingData[i][4] + \" predicted: \" + predicted);\n}\n```\n\n### Usage In HTML\n\nInclude the \"node_modules/js-regression/build/jsregression.min.js\" (or \"node_modules/js-regression/src/jsregression.js\") in your HTML \\\u003cscript\\\u003e tag\n\nThe codes in the following html files illustrates how to use them in html pages:\n\n* [example-binary-classifier.html](https://rawgit.com/chen0040/js-regression/master/example-binary-classifier.html)\n* [example-multi-class-classifier.html](https://rawgit.com/chen0040/js-regression/master/example-multi-class-classifier.html)\n* [example-regression.html](https://rawgit.com/chen0040/js-regression/master/example-regression.html)\n* [example-regression-2.html](https://rawgit.com/chen0040/js-regression/master/example-regression-2.html)\n* [example-regression-3.html](https://rawgit.com/chen0040/js-regression/master/example-regression-3.html)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchen0040%2Fjs-regression","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchen0040%2Fjs-regression","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchen0040%2Fjs-regression/lists"}