{"id":22193039,"url":"https://github.com/nyan-left/mse-ts","last_synced_at":"2025-07-28T20:08:54.599Z","repository":{"id":57304030,"uuid":"340818730","full_name":"nyan-left/mse-ts","owner":"nyan-left","description":"Node package for a mean squared error estimation function + type definitions.","archived":false,"fork":false,"pushed_at":"2021-02-21T09:01:14.000Z","size":137,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-07T04:07:15.011Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/nyan-left.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-02-21T04:42:19.000Z","updated_at":"2021-02-21T09:01:16.000Z","dependencies_parsed_at":"2022-09-01T22:40:52.091Z","dependency_job_id":null,"html_url":"https://github.com/nyan-left/mse-ts","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/nyan-left/mse-ts","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nyan-left%2Fmse-ts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nyan-left%2Fmse-ts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nyan-left%2Fmse-ts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nyan-left%2Fmse-ts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nyan-left","download_url":"https://codeload.github.com/nyan-left/mse-ts/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nyan-left%2Fmse-ts/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267577975,"owners_count":24110350,"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-07-28T02:00:09.689Z","response_time":68,"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":"2024-12-02T12:46:18.182Z","updated_at":"2025-07-28T20:08:54.575Z","avatar_url":"https://github.com/nyan-left.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":" \u003ch1 align=\"center\"\u003eMean Squared Error\u003c/h1\u003e\n\u003cp align=\"center\"\u003e\nMean Squared Error estimation function + type definitions.\u003cbr /\u003e\n  \u003cimg src=\"https://wikimedia.org/api/rest_v1/media/math/render/svg/e258221518869aa1c6561bb75b99476c4734108e\" /\u003e\n\u003c/p\u003e\n\n[![Build](https://github.com/nyan-left/mse-ts/actions/workflows/test.yml/badge.svg)](https://github.com/nyan-left/mse-ts/actions/workflows/test.yml)\n\n## Installing\n\n```bash\n$ npm install mse-ts\n```\n\n## Importing the package\n\n#### Using import\n\n```ts\nimport mse from 'mse-ts';\n```\n\n#### Using require\n\n```js\nconst mse = require('mse-ts');\n```\n\n## Usage\n\n#### Calculating MSE - Example 1\n\n```ts\nimport mse from 'mse-ts';\n\nconst y_true = [3, -0.5, 2, 7];\nconst y_pred = [2.5, 0.0, 2, 8];\n\nconst meanSquaredError = mse(y_true, y_pred);\nconsole.log(meanSquaredError);\n```\n\noutput\n\n```shell\n0.375\n```\n\n#### Calculating MSE - Example 2\n\n\u003c!-- This example is from https://github.com/bytespider/mse --\u003e\n\n```ts\nimport mse from 'mse-ts';\n\n\nconst y_true = [\n  188, 100, 114, 171, 171, 173, 230, 149,\n  191,  81,  61,  62, 127, 217,  62,  81,\n  178, 159, 245,  18,   9,  86, 201, 166,\n  122, 210,   4, 182,  15,  18, 135, 203,\n  222, 134, 154,  21,  71, 217,  48, 153,\n  113, 234, 207, 119,  51,  61, 149, 222,\n  186,  38, 158,  79, 185,   1, 118, 222,\n  22, 137, 110, 206,  94, 120, 163, 241\n];\nconst y_pred = [\n  188, 100, 114, 171, 171, 173, 230, 149,\n  191,  81,  61,  62, 123, 217,  62,  81,\n  178, 159, 245,  18,   9,  86, 201, 166,\n  122, 210,   4, 200,  15,  18, 135, 203,\n  222, 134, 154,  21,  71, 217,  48, 153,\n  113, 234, 207, 119,  51,  61, 149, 222,\n  186,  38, 158,  79, 185,   1, 118, 222,\n  22, 137, 110, 206,  94, 120, 163, 241\n];\nconst meanSquaredError = mse(y_true, y_pred);\n\nif (meanSquaredError \u003c\u003e 0) {\n    console.log('data sets are different by ' + meanSquaredError);\n}\n\n```\n\noutput\n\n```shell\n'data sets are different by 5.3125'\n```\n\n#### Steps\n\nYou may provide a custom step value\n\n```ts\nimport mse from 'mse-ts';\n\nconst y_true = [3, -0.5, 2, 7];\nconst y_pred = [2.5, 0.0, 2, 8];\n\nconst meanSquaredError = mse(y_true, y_pred, { step: 2 });\nconsole.log(meanSquaredError);\n```\n\noutput\n\n```shell\n0.0625\n```\n\n## Caveats\n\n- The length of `y_true` should always be higher than or equal to `y_pred`. Non-compliance will result in an `yPred at index i is undefined` error\n- Passing in empty arrays will return `NaN`\n\n## More info\n\nFind out more about the applications of MSE over on Wikipedia: https://en.wikipedia.org/wiki/Mean_squared_error\n\n## license\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnyan-left%2Fmse-ts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnyan-left%2Fmse-ts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnyan-left%2Fmse-ts/lists"}